익명 03:01

Is there an optimal way of capturing screen and audio for playback on the web wi...

Is there an optimal way of capturing screen and audio for playback on the web with FFmpeg?

I'm in process of updating my screenshot/screen capture script that uses ffmpeg to capture screen (and optionally audio). Note the captures are generally intended to be uploaded to the web, which is why I'm using webm format; e.g. to incorporate them in issue reports on github.

It used to work fine just fine ("fine" as in subjectively solid quality/size relation), but recently found the recordings are now super choppy — both audio and video start skipping after the first few seconds.

Example command:

ffmpeg -f x11grab -video_size 1920x1080 -i :0.0 -f pulse \
    -i alsa_output.usb-Generic_ThinkPad_Dock_USB_Audio-00.analog-stereo.monitor \
    -- output.webm

Also tried playing around with video & audio codecs (e.g. -c:v vp9 and -c:a libopus respectively), but essentially found no reasonable improvement.

Played around with following options as well (was expecting -thread_queue_size option at least to make a difference), but no joy:

-framerate 30
-thread_queue_size 4096
-preset ultrafast
-crf 20
-fragment_size 2048

Any pointers how to improve the ffmpeg command to grab video and audio for web uploads in a reasonable size/quality ratio?

Unsure what has changed compared to few years back; think last time I recorded using this command was before migrating from pulse to pipewire, although skipping audio recording still results in a choppy video.

Ideas:

  • Perhaps record lossless and post-process into a format more suitable for web?


Top Answer/Comment:

Comment: Define "optimal" and "reasonable". You capture based on your specific needs. You learn what your needs are, and you choose settings appropriate for it. If there were empirically optimal settings, these would be the defaults for the utility. Your issue is not finding optimal, though, and your use of those words distracts you. I recommend that you reconsider this situation, not as optimization, but break/fix, because something is broken. Then, EDIT your question and focus on asking how to fix the broken thing.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다