I wrote the following script to record an X screen for a specified amount of time, to make sure that it's lossless I've separated it into two steps
- record for the specified amount in a codec that requires almost no compression (so there's no overhead that might cause frames to be dropped)
- re-encode the original video into HEVC to make the filesize significantly smaller
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -vsync 1 -f x11grab -probesize 128M -s 1920x1080 -r 60 -i :0.0 -qscale 0 -vcodec huffyuv -t 00:01:13 "$video.avi" # record the screen losslessly
ffmpeg -hwaccel cuvid -vsync 1 -i "$video.avi" -map 0:0 -c:v:0 hevc_nvenc -crf 23 -preset medium "$video-clean.mp4"
This works just like I expect it to some of the time, but very often it drops a lot of frames (I've seen as many as 10000 frames dropped on occasion)
The gpu is a 1080 TI that's being used just for rendering an X server with a chrome window and recording it, according to nvidia-smi
the usage never goes to higher than 50% even in the most extreme cases.
I don't know what else to try, I thought about using a ramdisk to write the file to as it might be an IO problem, but ffmpeg refuses to write to tmpfs (for some reason I can't explain)
question from:
https://stackoverflow.com/questions/65925501/get-consistent-60fps-while-recording-x-screen-with-ffmpeg 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…