ffmpegscreen-capture

Pausing a ffmpeg screen capture?


I have a script to record my screen using ffmpeg:

ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0 -c:v libx264rgb -crf 0 -preset ultrafast video.mkv

I tried using pkill -STOP ffmpeg to pause the recording and pkill -CONT ffmpeg to resume it. The command seems to work correctly, pausing the recording process and later resuming it. However on playback, instead of instantly cutting to when I resumed ffmpeg, the video freezes for the duration I pause ffmpeg. Is there a way I can prevent the video from freezing, and instantly cut to when I resume recording? (I can upload a sample clip if that would help clarify something.)


Solution

  • Use the setpts filter to make timestamps continuous.

    ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0 -vf setpts=N/FR/TB -c:v libx264rgb -crf 0 -preset ultrafast video.mkv