1

I've got a weird issue running ffmpeg and trying to capture my screen.

When I run it with:

ffmpeg -video_size 512x383 -framerate 60 -f x11grab -i :0.0+512,203 -c:v libx264 -crf 0 -preset ultrafast -t 20 /tmp/lossless.mkv

I can capture 60fps without any issue.

However, as soon as I try to capture audio. The framerate drops to less than 30fps:

ffmpeg -video_size 512x383 -framerate 60 -f x11grab -i :0.0+512,203 -f pulse -ac 2 -i default -c:v libx264 -crf 0 -preset ultrafast -b:a 64k -t 20 /tmp/lossless_with_audio.mkv

See here for command output: https://pastebin.com/BMq38raq

glisignoli
  • 13
  • 1
  • 3
  • 1) [Get a build of ffmpeg from the current git master branch](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu). Yours is old. 2) Try adding the input option `-thread_queue_size 512` before each `-i`. The value I chose is arbitrary: you may have to adjust. Refer to the console output and look for the `Thread message queue blocking` line(s). 3) Add `-c:a copy` output option. – llogan Apr 25 '20 at 17:38

2 Answers2

0

I'd try with:

ffmpeg  -framerate 60 -f x11grab  -thread_queue_size 1024 -i :0.0 -f pulse -ac 2 -i default -c:v libx264   -acodec libmp3lame  -crf 0 -preset ultrafast -b:a 64k -t 20 /tmp/lossless_with_audio.mkv

Also, in terms of framerate, Are we talking about high motion here, such as game graphics? If not, I'd reduce the framerate to 25-30. Note that the FPS may also drop due to lack of CPU resources so you should check the utilisation.

You may also want to review https://trac.ffmpeg.org/wiki/EncodingForStreamingSites Cheers,

0

This is a very weird problem, I have the slight feeling that starting dbus helped prevent this problem.

https://stackoverflow.com/a/64080884/903004

Moritz
  • 1,590
  • 13
  • 8