Skip to content
streamneo.
Streaming Settings10 min read

FFmpeg Command for a YouTube 24/7 Stream with AAC Audio

A practical FFmpeg loop command for YouTube Live, with guidance on adapting bitrate, frame rate, GOP, AAC audio and stream testing.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

To loop a prerecorded video into a YouTube live stream with stereo AAC audio, you can start with the FFmpeg command below. It is a 1080p30-oriented example, not a guarantee of stable streaming or a bitrate recommendation for every channel.

The example uses 4,500 kbps for its video target, while YouTube’s currently published H.264 recommendation for 1080p30 is 10 Mbps. Check YouTube’s current guidance for your intended ingest resolution and frame rate, then make sure your sustained upload connection has headroom for the setting you choose.

When this FFmpeg command fits

This command suits a prerecorded file that already has video at the resolution and frame rate you intend to send, plus an audio stream you want encoded as stereo AAC. It loops that file indefinitely and reads it at real-time speed, so FFmpeg sends a live-paced stream instead of racing through the file as fast as it can. The source file must be reachable from the machine running FFmpeg, and its timestamps and streams must be usable by the installed FFmpeg build.

It is not a general-purpose conversion recipe. The command does not resize the picture, change its frame rate, create missing audio, or rotate between different files. If you have a static image with a separate audio track, a silent stream, or a collection of episodes, you need to construct the appropriate continuous input rather than expecting this one file loop to supply what is missing. For a playlist-based devotional channel, for example, the workflow described in keeping a Hindi devotional playlist live addresses a different operating need.

A loop is also not an uptime plan. -stream_loop -1 tells FFmpeg to repeat input; it does not restart the process after a crash, repair a lost network connection, or recover a powered-off computer. For a channel expected to stay live overnight, plan separately for the computer, power, network, process supervision and someone checking stream health. If you need the local process to resume after a Windows restart, the operational issue is closer to the one covered in resuming a yoga stream after a restart.

The starting command and what to replace

ffmpeg -re -stream_loop -1 -i input.mp4 \
  -c:v libx264 -preset veryfast \
  -b:v 4500k -maxrate 4500k -bufsize 9000k \
  -g 60 -keyint_min 60 -sc_threshold 0 -pix_fmt yuv420p \
  -c:a aac -b:a 128k -ar 44100 \
  -f flv "rtmps://SERVER/STREAM_KEY"

Replace input.mp4 with the path to your video file. Replace the destination with the RTMPS server URL and stream key displayed in YouTube Live Control Room. Keep the stream key private: anyone who obtains it may be able to send a broadcast to your channel. Do not paste it into a public post, a shared screenshot or a command history that other people can read.

The line breaks and backslashes are shell continuation syntax for Unix-like terminals. If you use a Windows command prompt, the continuation character differs; the options themselves remain FFmpeg options. You can also put the command on one line, taking care not to remove spaces between arguments or the quotation marks around the destination.

-re and -stream_loop -1 are input options, so they appear before -i. The former reads the file at its native rate for live-like pacing; the latter repeats the input indefinitely. The encoder options after -i govern the outgoing stream. The exact command has not been tested against your file, network, FFmpeg build or YouTube channel, so run a test rather than assuming that copied syntax proves a successful broadcast.

Video codec, resolution and bitrate

-c:v libx264 selects FFmpeg’s H.264 encoder. The bitrate-related options make this a bitrate-targeted configuration: -b:v sets the target, -maxrate caps the rate, and -bufsize sets the rate-control buffer. The example sets both target and cap to 4500 kbps and uses a 9000 kbps buffer. Those values are included to make the command concrete, not because one value suits every resolution or upload connection.

YouTube publishes bitrate guidance by codec, ingest resolution and frame rate. Its current H.264 table lists 720p30 at 3 Mbps minimum and 8 Mbps recommended; 1080p30 at 5 Mbps minimum and 10 Mbps recommended; 1080p60 at 6 Mbps minimum and 17 Mbps recommended; 1440p30 at 7 Mbps minimum and 21 Mbps recommended; and 4K30 at 11 Mbps minimum and 42 Mbps recommended. These figures are YouTube’s published settings, not a promise that a particular internet connection can sustain them. Check the current YouTube live encoder settings table before deployment, because published guidance can change.

Intended H.264 ingest YouTube minimum YouTube recommended
720p30 3 Mbps 8 Mbps
1080p30 5 Mbps 10 Mbps
1080p60 6 Mbps 17 Mbps
1440p30 7 Mbps 21 Mbps
4K30 11 Mbps 42 Mbps

Do not select a row from the resolution you hope to achieve if the file does not actually contain that picture size and frame rate. This command does not scale or convert frame rate. Inspect the source first, and decide whether to keep its properties or explicitly add scaling and frame-rate conversion. If you choose an output frame rate, ensure the machine can encode it continuously and that the upload connection can sustain the chosen video rate plus audio and transport overhead.

A faster preset such as veryfast reduces encoding work compared with slower presets, at the cost of compression efficiency: for comparable visual quality, a faster encode can need more bitrate. If CPU use is too high, a faster preset may help, but it does not lower the bitrate requirement YouTube publishes. If bandwidth is constrained, lowering the output resolution or frame rate may be more sensible than forcing a high target that the connection cannot sustain. The right choice depends on source quality, motion, processing capacity and measured upload stability, not a universal preset.

GOP and frame-rate settings

-g 60 sets a maximum group-of-pictures interval of 60 frames, and -keyint_min 60 sets a matching minimum interval. With 30 output frames each second, 60 frames is two seconds. YouTube recommends a two-second keyframe interval and says not to exceed four seconds, so this value matches that interval only if your encoded output really is 30 fps. The -sc_threshold 0 option disables scene-change keyframe insertion, helping keep keyframe placement regular.

If your output is 25 fps, 60 frames lasts longer than two seconds. If it is 60 fps, the same interval is shorter. Work out the GOP as roughly two seconds multiplied by your chosen output frames per second, then confirm what FFmpeg is actually producing. The current YouTube settings page is the authority to recheck if the guidance changes.

This command intentionally does not use an output frame-rate option. That leaves the source rate in charge, which is appropriate only when it matches the example’s assumptions. If your source has a different rate and you decide to convert it, set that conversion deliberately and adapt the GOP at the same time; do not merely copy -g 60 and assume it means two seconds for all files.

AAC audio settings

-c:a aac encodes the input audio using FFmpeg’s native AAC encoder. -b:a 128k sets the audio bitrate to 128 kbps, and -ar 44100 sets the sample rate to 44.1 kHz. YouTube’s published stereo AAC recommendation is 128 Kbps at 44.1 kHz. The command assumes the file contains audio that can be encoded as stereo; it does not create sound if the input has no audio stream.

Listen to the source before a long run. A technically valid encode can still carry silence, an unintended language track, clipping, or a badly balanced music level. Check that the audio is actually present and that the channel layout is suitable. For a file that appears to stream with no sound, compare the input stream mapping and test steps in troubleshooting an FFmpeg loop with no YouTube audio.

If there is no audio and the intended output should be silent, or if you want a separate music track, build an explicit audio input and filter or map it as needed. The correct filter chain depends on the specific sources and intended mix. Do not assume AAC options can manufacture a usable track from a video that contains none.

Send the stream to YouTube Live

In YouTube Studio, open Live Control Room and create or select the live stream. Copy the server URL and stream key shown there, then use the supplied destination format in the command. YouTube’s encoder setup instructions describe entering those values in an encoder. Treat the key as a password: if you think it has been exposed, replace it in the control room before relying on the channel.

The -f flv option selects FFmpeg’s FLV muxer, commonly used for RTMP-family streaming. The destination here uses RTMPS, YouTube’s encrypted extension of RTMP. YouTube lists RTMP/RTMPS as supported ingest protocols and H.264 with AAC as supported encoder formats; its current page also recommends constant bitrate (CBR). The sample bitrate options are intended as a constrained rate-control setup, but settings alone cannot establish that the network or encode will remain stable.

Start the command while the stream is configured in Live Control Room, then check the incoming preview and stream health. Do not publish a long-running channel simply because FFmpeg printed that it connected. Confirm that the picture moves as expected, audio is audible and correctly aligned, and YouTube reports a healthy incoming stream. For a continuous channel, also decide who or what will notice if the FFmpeg process exits, the host loses power, or the internet connection drops. An infinite loop repeats the file; it does not provide process supervision or failover.

Remember that an indefinitely running input loop and YouTube’s archive behaviour are separate things. YouTube says streams under 12 hours are automatically archived when ended. Do not assume that a single uninterrupted stream longer than that will produce a complete archive; check current YouTube guidance if retaining the whole broadcast matters to you.

Test playback and diagnose issues

Before you depend on the setup overnight, make a representative test with the actual file and network. YouTube specifically recommends testing with audio and movement similar to the planned broadcast and monitoring stream health. A test with a static menu screen does not tell you how a fast-moving video will encode, and a test in a quiet period does not establish that your connection will behave the same during busy hours.

Use a short checklist:

  • Verify the source’s dimensions, frame rate, audio streams and playback before encoding.
  • Confirm FFmpeg can open the file and that the output uses the intended video and AAC audio.
  • Watch YouTube’s preview for picture, movement, sound, sync and any visible blockiness.
  • Check stream health for warnings, dropped frames or an unstable incoming connection.
  • Leave the test running long enough to observe the actual operating pattern, then check again after any change to bitrate, resolution, frame rate or network path.

If the preview is black, check the source path, video stream and whether the encoder reports errors. If the picture is present but audio is absent, check that the file has an audio stream and that FFmpeg has selected it; a loop does not add one. If YouTube reports an unstable connection, compare the configured rate with what your connection can sustain, then test a lower output resolution or rate rather than assuming a larger buffer will fix a weak link. For more general live playback problems, the steps in diagnosing buffering during a live stream can help separate network symptoms from source or encoder problems.

Make one change at a time and repeat the test. If you change resolution, revisit YouTube’s bitrate row; if you change frame rate, revisit both bitrate and keyframe interval. A successful test is evidence that this file and setup worked under the tested conditions, not proof of future uninterrupted operation.

Before committing, compare the operating options on the pricing page. When the file and channel are ready, start free — 24-hour trial, no card.

FAQ

Does 4,500 kbps guarantee a stable 1080p30 stream?

No. It is the example command’s starting target, not a universal or recommended 1080p30 bitrate. YouTube’s currently published H.264 recommendation for 1080p30 is 10 Mbps; choose settings from its current table and test whether your source, encoder and connection can sustain them.

Will this command convert a 720p file to 1080p?

No. It encodes the input video but does not resize it. If you need a different output resolution or frame rate, add an explicit conversion and check the matching YouTube ingest guidance before selecting bitrate and GOP values.

Does -stream_loop -1 keep a channel online if FFmpeg stops?

No. It makes FFmpeg repeat the input while that process is running. You still need a plan for a stopped process, host or power failure, network loss and monitoring.

Can I use this command with a silent video?

Not as written if the input has no audio stream, because the audio options encode a track rather than create one. Decide whether the stream should be silent or carry separate audio, then build and test an explicit audio input accordingly.

YOU’VE REACHED THE END

Keep the ideas coming.

More guides, useful tools and a little help for your next broadcast.

Back to the journal ↗
YOUR NEXT READ

A little more to explore.

More Streaming Settings guides ↗ · All topics ↗