Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make a 24/7 YouTube stream with FFmpeg, create a YouTube Live stream, copy its ingest URL and stream key, then run FFmpeg on a computer or server that stays powered and connected. For a prerecorded video, use -re to send it at its normal rate and -stream_loop -1 to repeat it indefinitely. FFmpeg can keep sending while its process and host are healthy; it does not, by itself, recover from a crashed process or failed computer.

What you need before starting

  • A YouTube account with live streaming enabled, plus a stream created in YouTube Studio’s Live Control Room.
  • FFmpeg installed on a computer or server that can remain on and connected for the broadcast.
  • A video file or other input source, and a reliable upload connection with enough capacity for the selected stream bitrate.
  • A plan to supervise FFmpeg and preserve a replay if you need one. A single looping command does not provide process supervision or recording rotation.

This example is for a prerecorded file. Live camera or other live inputs require a different FFmpeg input configuration.

Create a YouTube Live destination

  1. Open YouTube Studio and go to the Live Control Room. Enable live streaming on the account if YouTube prompts you to do so.
  2. Create or select a stream and copy the stream URL and stream key shown for the encoder. The URL identifies the ingest destination; the key authorizes the incoming feed.
  3. Keep the key private. Treat it like a password: do not include it in public scripts, screenshots, or logs. If it is exposed, replace it in YouTube Studio before continuing.
  4. Choose an appropriate privacy setting or test with an unlisted or private stream first. YouTube’s encoder workflow calls for checking the incoming preview before selecting “Go live”; auto-start and auto-stop controls may also be available in the stream settings.

Configure FFmpeg to loop a video

Run this illustrative command from a terminal, replacing input.mp4, INGEST_URL, and STREAM_KEY with your file and the destination details from YouTube:

ffmpeg -re -stream_loop -1 -i input.mp4 
  -c:v libx264 -b:v 5000k -maxrate 5000k -bufsize 10000k 
  -g 60 -c:a aac -b:a 128k 
  -f flv 'rtmp://INGEST_URL/STREAM_KEY'
  • -re paces a file input at its native rate rather than sending it as fast as FFmpeg can read it.
  • -stream_loop -1 repeats the input indefinitely. It is an input option, so it appears before -i input.mp4.
  • -c:v libx264 selects H.264 encoding. The example’s 5000k video bitrate is only an illustrative value; it is not YouTube’s recommended 1080p30 H.264 bitrate.
  • -maxrate and -bufsize constrain rate behavior. For YouTube live ingest, configure the encoder for constant bitrate (CBR) as recommended in its settings.
  • -g 60 sets a 60-frame keyframe interval. YouTube recommends a two-second keyframe interval, so 60 frames corresponds to two seconds only at 30 fps. Adjust it to match the actual frame rate.
  • -c:a aac -b:a 128k encodes audio as AAC at 128 kbps. YouTube lists AAC or MP3 for stereo audio and recommends 128 kbps at a 44.1 kHz sample rate; set the sample rate explicitly if your source or encoder output does not match.
  • -f flv selects the FLV output format used by this RTMP publishing pattern.

The command is a starting point, not a tested, universal production command. Your FFmpeg build needs the required encoders and formats, including libx264, AAC, and FLV/RTMP support. Check the installed build and test the actual file and destination before relying on a public continuous stream. FFmpeg’s documentation describes the paced-input and RTMP publishing pattern and the arrangement of input and output options: FFmpeg protocols documentation and FFmpeg command-line documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose resolution, frame rate, bitrate, and audio

Match the output to the file, encoder capability, upload capacity, and viewer needs. YouTube’s current encoder guidance supports H.264, H.265/HEVC, and AV1 ingest over RTMP/RTMPS, up to 60 fps. It recommends CBR, a two-second keyframe interval (not more than four seconds), and AAC or MP3 stereo audio at a recommended 128 kbps and 44.1 kHz. RTMPS is YouTube’s recommended secure extension to RTMP. HDR has separate requirements; do not assume these SDR examples cover an HDR workflow. See YouTube’s live encoder settings for the current guidance.

Output format YouTube-recommended H.264 bitrate
720p30 8 Mbps
720p60 8 Mbps
1080p30 14 Mbps
1080p60 17 Mbps

These are YouTube Help recommendations, not measurements of your connection. Its table gives different recommendations for AV1 and HEVC; select the row for the codec, resolution, and frame rate you actually use. If your connection cannot sustain the target bitrate, reduce resolution or frame rate rather than sending a rate your upload cannot reliably carry. YouTube automatically transcodes incoming live video into viewer output formats.

For a fixed output, budget for the video and audio together. YouTube recommends leaving 20% bandwidth headroom and accounting for both primary and backup stream bitrates if you use backup ingest. It also recommends testing upload bitrate; run a speed test and verify performance during a test stream, not just in an idle network test. More advice is available in YouTube’s live streaming tips.

Start the stream and verify it

  1. Start FFmpeg and watch its terminal output for connection errors, encoder errors, or a stalled input.
  2. In the Live Control Room, wait for YouTube’s preview and check that the picture and sound are correct. Select “Go live” when ready if the event is not set to start automatically.
  3. Open the channel or watch page and confirm playback there as well. Check audio, motion, and playback on a mobile device if that matters to your audience.
  4. Keep an eye on stream health and the FFmpeg process. A running terminal is not proof that viewers are receiving a healthy stream.
  5. If recording locally, check that the recording is being written and that available disk space is sufficient. This example does not record a separate archive.

Keep a 24/7 process operating

For the command to keep publishing, the host must remain on, FFmpeg must continue running, the input file must remain accessible, and the network must keep delivering the stream. A network disruption can interrupt delivery. The command does not restart FFmpeg after a process failure, recover a failed host, or rotate recordings; those require separate operational arrangements, such as process supervision and a verified recording plan. Test recovery behavior rather than assuming it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plan separately for the YouTube replay. YouTube Help says streams under 12 hours can be automatically archived; streams longer than 12 hours may not be captured at all. A 24/7 broadcast is longer than that window, so do not rely on YouTube to preserve it as one replay. If keeping an archive matters, use an independent local or remote recording and rotation plan, and verify it before the broadcast. See YouTube’s live stream archiving guidance.

Troubleshoot common problems

Symptom Likely cause What to check or change
YouTube does not receive a stream Wrong ingest URL or key, disabled live streaming, or an FFmpeg build without the needed output support. Copy the current destination details from the Live Control Room, confirm the account can stream, and check the FFmpeg error output and build capabilities. Keep the key private.
FFmpeg exits when the file ends The loop option is missing, placed as an output option, or not applied to the intended input. For a file input, put -stream_loop -1 before -i input.mp4; inspect the command and test it with the specific file.
Picture stutters or stream health degrades Insufficient or unstable upload capacity, or an output bitrate that is too high for the connection. Check the actual upload under load, retain YouTube’s recommended 20% headroom, and lower bitrate by reducing resolution or frame rate if necessary.
Keyframe or playback behavior is poor Keyframe interval does not match the selected frame rate or exceeds YouTube’s recommendation. Set a two-second interval; for example, 60 frames at 30 fps. YouTube advises not to exceed four seconds.
Video arrives but audio is absent or unsuitable The source has no usable audio, or the output audio codec, sample rate, or bitrate is not appropriate. Check the source and FFmpeg audio mapping, then use a supported stereo codec such as AAC or MP3 and confirm the output in YouTube’s preview.
The broadcast stops after a host or process failure The basic command has no supervisor or host recovery mechanism. Use and test a separate process-supervision and host-recovery setup, or choose a cloud service designed to keep the stream running.
No complete replay is available The 24/7 stream exceeded YouTube’s stated automatic-archive duration. Keep an independent recording and rotation plan if the full archive is important; do not depend on YouTube to capture a stream longer than 12 hours.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Copyright and channel policy still apply

Looping a file does not grant rights to its video or audio. Use material you own or are authorized to broadcast, and check the applicable rights for music, visuals, and other included content before going live. Repeating content also does not, by itself, establish that a channel meets YouTube’s monetization requirements; review YouTube’s current channel and monetization policies rather than assuming a 24/7 format qualifies. A technical connection to Live Control Room is not a policy approval.

Or let it run in the cloud

If you do not want a computer or server at home running FFmpeg continuously, StreamNeo keeps an uploaded-video YouTube stream running from the cloud. Upload a recording or build a playlist, add your YouTube stream key once, and go live. It loops the uploaded video; it does not broadcast from a camera. A slot streams the uploaded file as made, up to 4K 60fps, at one flat price per slot with no re-encode or quality tiers. It includes 10 GB storage per slot, pooled across active slots, looping and playlists, and automatic recovery if YouTube drops the stream. The first day is free with no card (one free day per account); plans can be purchased by the day, week, month, 6 months, or year, and can be cancelled any time. UPI and cards are available in India; card checkout is available worldwide. For five or more slots, contact support.

Nothing has to stay on at home; any quality up to 4K 60fps is one price; StreamNeo automatically recovers if YouTube drops; and the first day is free with no card. Monthly: $9.99 per month.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start your free StreamNeo day.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.