More optomized ffmpeg command

This commit is contained in:
Ian Keane 2026-09-16 13:23:19 -04:00
parent ac992a756e
commit 14b2982c8b

View file

@ -95,11 +95,22 @@
<p>If you're on X11 (or a Wayland session with Xwayland exposing <p>If you're on X11 (or a Wayland session with Xwayland exposing
<code>:0.0</code>), this captures your screen + default audio <code>:0.0</code>), this captures your screen + default audio
directly, no extra tools needed:</p> directly, no extra tools needed:</p>
<pre>ffmpeg -f x11grab -framerate 30 -i :0.0 -f pulse -i default -c:v libx264 -preset veryfast -tune zerolatency -pix_fmt yuv420p -c:a aac -b:a 128k -f flv "&lt;url you were given&gt;"</pre> <pre>ffmpeg -f x11grab -framerate 30 -i :0.0 -f pulse -i default -c:v libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -c:a aac -b:a 128k -f flv "&lt;url you were given&gt;"</pre>
<p>Swap <code>-preset veryfast</code> for <code>ultrafast</code> on <p><code>-preset ultrafast</code> keeps CPU usage low for real-time
weaker machines, or <code>fast</code>/<code>medium</code> if you software encoding — if you're dropping frames on a weaker machine,
have CPU to spare. RTMP/FLV requires H.264 video and AAC audio — try lowering <code>-framerate</code> (e.g. <code>20</code>) rather
other codecs won't work here.</p> than the resolution, which tends to look better for the same CPU
savings. If you have a GPU with VAAPI support, hardware encoding is
far less CPU-intensive — replace the video input/encode portion
with:</p>
<pre>ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -framerate 30 -i :0.0 -f pulse -i default -vf 'format=nv12,hwupload' -c:v h264_vaapi -b:v 4M -c:a aac -b:a 128k -f flv "&lt;url you were given&gt;"</pre>
<p>(adjust <code>/dev/dri/renderD128</code> if you have multiple GPUs —
check <code>ls /dev/dri</code>.) RTMP/FLV requires H.264 video and
AAC audio —
some distro ffmpeg builds (e.g. Slackware) ship without these
encoders for licensing reasons; check with
<code>ffmpeg -encoders | grep -E "libx264|aac"</code>, or use OBS
instead, which bundles its own encoder support.</p>
<h3>Option C: ffmpeg with a file/other source</h3> <h3>Option C: ffmpeg with a file/other source</h3>
<p>For rebroadcasting a pre-recorded file or another running stream <p>For rebroadcasting a pre-recorded file or another running stream
instead of capturing your screen:</p> instead of capturing your screen:</p>