To loop a video on YouTube Live with FFmpeg on Contabo, place -stream_loop -1 before the input file, then send the resulting feed to the ingest URL and stream key shown in YouTube Live Control Room. The loop option repeats the input; it does not keep the network connection alive or restart FFmpeg after a failure.
Treat this as three separate jobs: prepare a suitable file, encode and send it from the VPS, then monitor YouTube and test recovery. Do not choose a Contabo plan based on a command example: check its current specifications and terms, then test your actual media and settings on the intended VPS.
The workflow: file, encoder and YouTube
The local media file is FFmpeg’s input. FFmpeg reads it, applies the input-loop setting and encodes or passes through streams as configured. Its output is a live feed sent to YouTube over RTMP or, preferably where available in your configuration, RTMPS. YouTube receives that feed and presents it in Live Control Room for preview and broadcast.
These parts have different failure modes. An unsuitable file can cause problems with playback, audio or processing. A wrong stream URL or key prevents YouTube from receiving the feed. A VPS may lack the resources or sustained network capacity for the chosen workload. And a healthy input loop does not by itself handle a dropped connection or a stopped process.
This guide uses a single-file example. A playlist workflow is different: if you want to rotate through separate files rather than repeat one input, see how a playlist file can run a YouTube livestream continuously. For a still-image presentation, the VPS slideshow workflow covers a different kind of input.
Before configuring the command, decide whether the stream is scheduled or intended to start immediately. YouTube’s scheduled-stream process may require you to wait for a preview and select Go live. Review the current Live Control Room controls, including auto-start and auto-stop behaviour, so the encoder’s start and stop match the stream’s lifecycle. YouTube’s encoder setup guide describes creating or selecting a stream and using its encoder details.
Prepare a local media file
Put the file on the VPS and use its full path in the command. A path such as /home/stream/video.mp4 is easier to troubleshoot than a relative path, which can point somewhere unexpected when the command is launched by a scheduled task or service. Check that the file is complete and playable before starting the broadcast; a file that works on a desktop player is not automatically a sensible long-running encoder input.
Confirm what the file contains: its video dimensions and frame rate, codec, audio codec, and whether it has an audio stream at all. You can inspect it with a media probe such as ffprobe if it is installed alongside FFmpeg. The key practical question is whether those properties fit the live output you intend to send. If you need to scale, change frame rate or transcode audio, make those choices explicit in the command rather than assuming the input already matches.
Listen to the beginning, middle and end. Check for an abrupt cut, a few seconds of silence, an unwanted slate or a moment that should not repeat. A repeated video has a visible join every time it reaches the end. If the sound or picture jumps sharply at that point, address the edit in the source file; looping does not create a seamless transition. For nature footage, the guidance on building a seamless YouTube nature loop is relevant to the editorial problem, while this article focuses on delivery.
A file without audio needs deliberate handling. Depending on the rest of your command and YouTube’s accepted output, you may need to add an audio source or generate silence. Do not assume a video-only input will produce the audio track you expect. The separate guide on adding silence to an FFmpeg YouTube stream explains that case.
Set the infinite input loop in the right place
FFmpeg’s -stream_loop controls how many times an input stream is looped. The FFmpeg command-line documentation says that -1 means infinite looping, while 0 means no loop. Because this is an input option, put it before the -i for the file it should control:
-stream_loop -1 -i /home/stream/video.mp4
Placement matters. In a longer command, options before -i apply to that input; options after the input generally configure output. Do not move -stream_loop -1 to the end of the command and expect it to loop the earlier file. If a command has multiple inputs, place the loop option immediately before the relevant -i so it is clear which input repeats.
The option repeats the media input, not the outgoing broadcast. It does not validate that the file has suitable streams, fix an edit discontinuity, reconnect to YouTube or supervise a process that exits. A loop that works locally can still fail to reach YouTube if the output configuration or network is wrong.
Here is the shape of an example command, not a tested or universal configuration:
ffmpeg -re -stream_loop -1 -i /home/stream/video.mp4 \
-c:v libx264 -preset veryfast -b:v 8M -maxrate 8M -bufsize 16M \
-r 30 -g 60 -c:a aac -b:a 128k \
-f flv "rtmps://INGEST-URL/STREAM-KEY"
It illustrates where the loop option belongs and how an output URL is supplied. The example’s encoder options are choices to inspect and adjust, not a promise that they suit your file, installed FFmpeg build, VPS or YouTube account. In particular, a named encoder such as libx264 must be available in the installed build. Confirm the command’s available options with the documentation for that build and test before relying on it.
Add YouTube’s ingest URL and stream key
In YouTube Studio, open Live Control Room and create or select the stream. Copy the server URL and stream key from the encoder settings. The URL is the destination; the key identifies the stream. YouTube describes the key as a password and address for the stream, so treat it like a password: do not publish it in a script repository, screenshot, public support post or shared command history.
In the example, replace INGEST-URL/STREAM-KEY with the exact destination format shown by YouTube. If YouTube supplies a server URL and a separate key, combine them in the manner required by the selected FFmpeg output protocol. Do not paste the literal placeholder. Avoid putting a real key in an article, shared terminal recording or command sent to someone who does not need it. If it is exposed, reset it in YouTube Studio and update the encoder configuration.
YouTube recommends RTMPS in its live encoder settings. Those settings also list supported ingest codecs and guidance for frame rate, bitrate, audio and keyframes. Use the current table as the source for output targets, rather than copying a command from a different video or assuming every codec is available in your FFmpeg build.
For a concrete comparison, YouTube’s H.264 guidance lists 1080p30 at 14 Mbps recommended video bitrate and 720p30 at 8 Mbps. It lists 128 Kbps as the recommended stereo audio bitrate. These are YouTube ingest recommendations, not an assessment of a Contabo VPS or its available upload capacity. As listed in YouTube Help’s encoder settings on 3 October 2026, they are settings guidance to check against the current page when you configure the stream.
| Output target | YouTube H.264 video bitrate guidance | What to check before choosing it |
|---|---|---|
| 1080p30 | 14 Mbps recommended | Sustained upload headroom, encoding load and the visual detail your channel needs |
| 720p30 | 8 Mbps recommended | Whether the lower resolution is acceptable and the same capacity checks |
YouTube also recommends CBR, up to 60 fps, AAC or MP3 audio, and a two-second keyframe interval that does not exceed four seconds in its current encoder guidance. Choose settings that agree with YouTube’s table and your actual content. A static devotional image with a small amount of movement and a detailed news loop with frequent scene changes can behave differently under compression; test with representative sections rather than judging from one still frame.
Run FFmpeg on the intended VPS
Install or make available an FFmpeg build on the VPS, upload the media file, and run the command there rather than on your everyday computer. That places the encode and upload on the machine you intend to keep operating. First run it in a terminal session where you can see startup messages and errors. Confirm that FFmpeg opens the file, recognises its streams and begins sending output to the expected destination.
The command’s -re flag in the example asks FFmpeg to read at the input’s native rate rather than processing the file as quickly as possible. The remaining encoding flags are illustrative. Do not infer that a particular preset, bitrate or frame rate is right for your VPS. If you use a pre-encoded file, investigate whether stream-copy output is appropriate before using it; the input and output formats, codecs and YouTube requirements all matter. Transcoding can use substantial CPU, so a successful short launch is not proof that the VPS can sustain the selected settings continuously.
Use a persistent process manager or service configuration if you need FFmpeg to remain running after you disconnect from SSH or after a machine restart. This is separate from -stream_loop: persistence tools manage the process lifecycle, while the loop option controls input repetition. Read the current documentation for the tool you choose, and make sure logs are retained somewhere you can inspect. A restarted process may also need the correct stream state in YouTube Studio before viewers see a live broadcast.
As you bring it up, verify the picture and sound in YouTube’s preview. If FFmpeg reports an encoder, file or connection error, resolve that before treating the stream as ready. Avoid repeatedly pasting a key into terminal commands where shell history is retained; use an access-controlled configuration method appropriate to your setup, and limit who can read it.
Check Contabo’s current plan and traffic terms
A command cannot tell you whether a particular Contabo plan will sustain your workload. Before buying or deploying, check the current plan-specific CPU and memory specifications, traffic allocation, network conditions and applicable use terms on Contabo’s own site or in your account. Provider offerings and terms can change, and this guide does not establish a suitable plan or continuous-transfer allowance.
Then test the intended workload on the intended VPS. Use the actual file, output codec, resolution, frame rate and bitrate you plan to run. Watch CPU and memory while FFmpeg is encoding, and observe whether the process keeps up with real time. Separately check sustained outbound network capacity. A plan’s listed resources alone do not demonstrate that your particular encode and transfer will work continuously.
YouTube advises leaving upload headroom: its streaming tips recommend a 20% margin between total stream bitrate and available upload bandwidth. That guidance concerns network capacity, not a Contabo plan guarantee. If your sustained upload is close to the stream’s total bitrate, small fluctuations can leave too little room; test from the VPS and do not treat a brief speed test as proof of long-term capacity.
When comparing output settings, weigh the image quality you need against the required bitrate and your measured sustained capacity. A lower-resolution target may reduce the network demand, but it does not automatically prove the VPS is adequate: encoding load, the file, shared resource behaviour and provider terms remain relevant. For context on the different question of running a cloud-based stream from India, see whether a 24/7 YouTube streaming service can work with an Indian VPS.
Monitor the stream and test recovery
Do a representative test before making the channel depend on the setup overnight. Include the actual audio, motion, scene changes and the file’s loop join. In Live Control Room, confirm the preview, check stream health and read any warnings. Confirm that the audio is present and intelligible, motion is smooth enough for the content, and the output settings reported by YouTube match what you intended to send.
Test the conditions that could break the broadcast rather than assuming input looping covers them. For example, observe what happens if the network connection drops briefly, the FFmpeg process exits, or the VPS reboots. YouTube’s documentation establishes the input loop behaviour, not how FFmpeg reconnects in your exact command or whether a process manager restarts it correctly. Use the documentation for the specific process-management and networking choices you adopt, then verify the result in a controlled test.
Keep a simple operating note: the file path, the stream name, where the key is stored, how to check logs, and the steps to stop or restart the encoder. Do not put the key in a note that is publicly accessible. If several people look after the channel, ensure they know how to distinguish an input-loop issue from a YouTube ingest or VPS problem.
YouTube says encoder streams shorter than 12 hours are automatically archived, according to its encoder setup guidance. That is a platform archive behaviour, not a promise that an encoder process, connection or long-running VPS session will never fail. Check the current YouTube guidance for how archives and live controls apply to your account and stream, and plan monitoring around the broadcast itself.
If keeping a personal computer switched on for the stream is the specific operational burden, StreamNeo removes that need by taking an uploaded file and running the YouTube broadcast after you provide the stream key. It is YouTube-only, so this is relevant only if a cloud-run file loop fits your channel and the way you want to operate it.
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 -stream_loop -1 loop the video forever?
It tells FFmpeg to loop the input indefinitely, and it belongs before the -i for that input. It does not promise that FFmpeg will stay running or that YouTube will keep receiving the feed.
Can I use the example command unchanged?
No. It is a shape for showing input-loop placement and an output destination, not a tested command for every file or VPS. Check your installed FFmpeg options, YouTube’s current encoder guidance, the file’s streams and the VPS’s measured capacity.
Which Contabo plan is enough for 24/7 streaming?
This guide does not name a suitable plan. Check Contabo’s current plan-specific specifications and traffic terms, then test the intended encode and sustained transfer on the plan you are considering.
Will YouTube automatically restart the stream if FFmpeg stops?
Do not assume so. YouTube receives the encoder feed, while process supervision and recovery depend on your VPS setup and command; test failure and restart behaviour before relying on it.