Skip to content
streamneo.
Streaming Settings13 min read

How to Create a Seamless Loop for YouTube Live with FFmpeg

Loop a video on YouTube Live with FFmpeg, check the edit at the join, pace playback, and handle multiple files safely.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

FFmpeg can repeat a prerecorded file indefinitely and send it to YouTube Live. The command that repeats the file does not, by itself, make the final frame flow naturally into the first, so a genuinely seamless result depends on the source edit as well as the streaming settings.

For one file, use -stream_loop -1 with -re, then encode the output for YouTube's ingest. For a playlist, check that the files are compatible before using the concat demuxer; if they are not, normalise or re-encode them instead of assuming that every MP4 can be joined safely.

What a loop does—and does not do

A loop has two separate jobs. The first is operational: keep providing frames after the file reaches its end. The second is editorial: make the transition from the last moment back to the first one feel intentional.

FFmpeg's -stream_loop -1 addresses the first job. It requests indefinite repetition of the input. It does not trim a frame, crossfade audio, correct a timestamp, or examine whether the action at the end matches the action at the beginning. The same ending is simply followed by the same beginning each time the input is repeated.

That distinction matters for a devotional video, a rain scene, a lofi animation, or a local information loop. If the final image shows a person turning away and the first image shows the same person suddenly facing the camera, the repetition will expose the cut. If the last audio sample is loud and the first sample is quiet, listeners will hear a jump even when the video looks calm.

A seamless loop is therefore usually made in the source file before FFmpeg sends it live. You might trim the opening and closing sections, alter the order of scenes, or create a deliberate audio transition in an editing application. The right choice depends on the material. A slowly moving background may tolerate a direct loop, while music, speech and a camera movement often need a more deliberate join.

The streaming command still matters. Incorrect pacing can make a file run too quickly, while poor output settings can produce buffering or warnings in YouTube Live Control Room. Treat the media edit and the live transport as related but different checks.

Check whether the source has a clean join

Before building the command, play the file through its end and back to its beginning. Do this with headphones as well as speakers, and watch the exact boundary rather than judging the clip by its opening and closing sections separately.

Look for these signs at the video boundary:

  • A change in brightness that resembles a flash.
  • A camera movement that stops abruptly and starts in a different direction.
  • A person, object or text element that changes position without a visual reason.
  • A final frame that is held for an unusual moment before the first frame appears.
  • A different frame rate, aspect ratio or timestamp behaviour at the join.

For audio, listen for a click, a short silence, a change in loudness, a reversed stereo image, or a musical phrase that begins in the wrong place. Speech is particularly difficult to loop cleanly because the end of a sentence rarely leads naturally into its beginning. A quiet ambience track may be easier, but a room tone can still change noticeably if the recording has a noise floor or air-conditioning cycle.

If the join is poor, edit the asset and render a new version. A short overlap or crossfade can help in some cases, but there is no universal duration that works for every source. A crossfade that sounds smooth on a sustained pad may blur a spoken word, soften a bell, or make a moving image appear to dissolve at the wrong point. Preserve the exact duration only if your schedule or playlist depends on it; otherwise, a cleaner edit can be more useful than a fixed runtime.

You can inspect basic media information with FFmpeg's companion tool:

ffprobe -v error -show_streams -show_format input.mp4

This helps you see the available video and audio streams, duration, frame rate and codec information. It does not decide whether the edit is aesthetically seamless. Use it alongside an actual listen and a frame-by-frame review of the boundary.

For a practical example involving a calm repeating source, the workflow in how to loop a rain sounds video on YouTube Live with OBS is relevant even though the encoder is different. The same principle applies: repetition and a clean source edit are separate concerns.

Repeat one file with FFmpeg

For a single file, this is a useful starting template:

ffmpeg -re -stream_loop -1 -i input.mp4 \
  -map 0:v:0 -map 0:a? \
  -c:v libx264 -pix_fmt yuv420p -preset veryfast \
  -c:a aac -b:a 128k \
  -f flv "<YouTube ingest URL>/<stream key>"

-stream_loop -1 belongs before the corresponding -i because it is an input option. -re tells FFmpeg to read the file at its native rate rather than pushing frames as quickly as the computer can process them. That pacing is commonly important when a file is being used as a live-style source.

The two -map options make the output selection explicit. -map 0:v:0 selects the first video stream. -map 0:a? selects the first audio stream if one exists, without failing solely because the input has no audio. If your file is silent and you need an audio track, add an intentional audio source or choose an output arrangement that matches your planned broadcast. Do not assume that optional mapping creates audio.

The codec and bitrate values in this example are illustrative, not a universal YouTube preset. libx264, AAC and an FLV output are a familiar combination for RTMP or RTMPS ingest, but you still need to choose resolution, frame rate, rate control and video bitrate for the actual file and your upload connection. Keep the stream key private and place it only in the command or application that needs it.

YouTube's encoder settings guidance lists its current ingest and encoding recommendations, including supported video and audio choices, constant bitrate guidance and keyframe timing. Check that page before committing to a preset, because platform guidance can change.

If the process stops at the first end of the file, check the option order, the FFmpeg version, and the console output. You should also confirm that frame progress continues through the repeat point. A running terminal process is not proof that the remote broadcast is healthy, so inspect the YouTube side as well.

Pace playback for YouTube Live

A file sent to an ingest endpoint is not automatically a live broadcast just because the destination is YouTube. FFmpeg must produce timestamps and frames at a sensible rate, and the output must match the format you selected for the channel.

-re is intended for file input pacing. Without it, FFmpeg may read and encode much faster than real time if the computer has spare capacity. That can exhaust the input quickly, overload the connection, or make the output unsuitable as a live feed. It is not a repair for an incorrect source frame rate, and it does not make an edit seamless.

Your main checks are:

Setting What to check Why it matters
Resolution Match the output to the source and the intended YouTube mode Scaling can consume encoding capacity and may reduce clarity
Frame rate Use a deliberate frame rate supported by the output Unexpected conversion can alter motion and timing
Video codec Follow YouTube's current encoder table for your choice Codec choice affects bitrate and compatibility
Rate control Use the mode requested in YouTube's guidance A variable output can behave differently from the intended ingest profile
Keyframes Aim for the current recommended interval and stay within the stated maximum Infrequent keyframes can create ingest or playback issues
Upload capacity Leave room for the sustained encoded stream A connection that briefly works may still fail overnight

For example, the YouTube table currently gives H.264 examples of 5 Mbps minimum and 14 Mbps recommended for 1080p at 30 fps, and 3 Mbps minimum and 8 Mbps recommended for 720p at 30 fps. It also lists 6 Mbps minimum and 17 Mbps recommended for 1080p at 60 fps. These are YouTube Help figures, accessed in 2026, and the table should be checked for the selected codec, resolution and frame rate before use.

YouTube currently recommends a two-second keyframe frequency and says it should not exceed four seconds. That is a property of the encoded output, not of the visual seam in your source. A stream can have acceptable keyframes and still show a harsh cut every time the file repeats.

If you are deciding between a smaller output and a sharper one, the YouTube resolution versus bitrate guide explains the trade-off in more detail. For a longer-running channel, also compare the settings against the practical upload and encoding limits of the machine that will remain responsible for the feed.

Inspect the audio and video boundary

A reliable seam review has three passes. First, watch the last few seconds and first few seconds together. Second, listen without looking at the screen. Third, inspect the technical timestamps and streams if the join behaves differently on air from how it behaved in the editor.

For video, step through the boundary one frame at a time if your player allows it. Ask whether the first frame is a plausible continuation of the last one. A static background may loop directly when the colours and composition are stable. An animation may need the opening and closing poses to match. A slideshow may need a fade or a repeated title card rather than a direct jump from the final slide to the first.

For audio, compare the level immediately before and after the join. A waveform that reaches a loud peak at the end and restarts at a low level can create a noticeable thump. A stereo recording can also feel wrong if the room tone changes between the two edges. If the source contains speech, make sure the first word is not cut off and that the last word does not appear to continue into an unrelated sentence.

FFmpeg can report stream and format details, but it cannot judge musical phrasing or whether an image feels continuous. Use the technical output to find likely causes of a discontinuity:

ffprobe -v error -select_streams v:0 \
  -show_entries stream=codec_name,width,height,r_frame_rate,time_base,duration \
  -of default=noprint_wrappers=1 input.mp4

If the duration is inaccurate, or if the file contains unusual timestamps, repeat the inspection after rendering a clean replacement. A timestamp problem can produce a pause or jump that looks like an editing problem. Conversely, a perfect timestamp sequence cannot remove a hard cut that was deliberately rendered into the media.

If the asset is intended for a devotional or music channel, review the first and last musical phrases before selecting the final loop. The guide to streaming meditation music 24/7 on YouTube in India is useful context for separating the content plan from the mechanics of keeping the feed running.

Loop multiple files with compatible inputs

A playlist is more complicated than repeating one file. FFmpeg's concat demuxer can join a list without re-encoding when the inputs meet its compatibility requirements, but it is not a general-purpose converter for arbitrary media.

A basic playlist file looks like this:

file '/media/part1.mp4'
file '/media/part2.mp4'
file '/media/part3.mp4'

You can pass it to FFmpeg as a concat input:

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \
  -map 0:v:0 -map 0:a? \
  -c:v libx264 -pix_fmt yuv420p -preset veryfast \
  -c:a aac -b:a 128k \
  -f flv "<YouTube ingest URL>/<stream key>"

Whether this works cleanly depends on the installed FFmpeg build and the actual inputs. The files should have matching stream layouts and compatible properties, including the codecs and timing characteristics expected by the concat demuxer. Differences in frame rate, time base, dimensions, audio layout or stream order can produce errors, timestamp gaps or visible and audible artefacts.

-safe 0 permits paths outside the concat demuxer's safe subset. Use it only with a playlist you created or inspected yourself. Do not paste untrusted file paths into a playlist and then run it with relaxed path handling.

The concat demuxer also relies on duration information. If a container reports an incorrect duration, the next file may begin too early or too late. Check suspicious files with ffprobe and render or remux a corrected version where appropriate. A playlist that runs once is not necessarily a playlist that will repeat cleanly for hours.

When files are not compatible, use the concat filter and re-encode, or normalise every file to a common format before joining. The FFmpeg FAQ distinguishes the concat filter, which is appropriate when re-encoding is needed, from the concat demuxer, which can avoid re-encoding when compatible inputs are available. The FFmpeg documentation gives the detailed constraints and syntax.

Do not treat the concat filter as an automatic seam editor either. It can join streams in a controlled filter workflow, but it does not know whether the end of one bhajan should lead into the next, whether a spoken announcement needs a pause, or whether two ambience recordings have matching room tone. Build the editorial transitions deliberately, then verify the rendered result.

Test the feed in Live Control Room

Run a preflight with the actual file, output settings, network connection and YouTube destination. YouTube's encoder guidance says to test before starting the live stream, using audio and movement representative of the planned broadcast, and to monitor stream health during the event.

In Live Control Room, check whether YouTube is receiving input and look at the messages associated with the stream. The useful details include insufficient input, bitrate, frame rate, codec and keyframe warnings. If the stream appears healthy for a short period but fails when the source repeats, watch the console and the preview across the exact boundary.

YouTube's Live API health status documentation explains the platform's health messages. It is a primary reference for interpreting configuration and input warnings, although the final diagnosis still depends on your command and media.

A sensible test checklist is:

  1. Confirm that FFmpeg can read every input and that the mapped streams exist.
  2. Watch one complete pass and the beginning of the next pass.
  3. Listen specifically for the audio transition rather than only watching the preview.
  4. Check that the output remains paced at real time.
  5. Compare resolution, frame rate, bitrate and keyframe behaviour with YouTube's current guidance.
  6. Leave the process running long enough to expose a repeat, playlist transition or timestamp issue.
  7. Record any Live Control Room message before changing several settings at once.

For a channel that must run overnight, decide what happens when the local process stops, the connection drops or the computer restarts. A VPS or spare computer gives you direct control, but it also leaves you responsible for the operating system, FFmpeg process and recovery procedure. The comparison in cheap VPS versus cloud streaming service for a 24/7 YouTube channel in India covers that operational trade-off.

If the repeated file is ready but you do not want your own computer to remain responsible for the long-running process, StreamNeo removes that particular burden by letting you upload the video, provide the YouTube stream key and leave the broadcast running with automatic monitoring and restart handling. It is still your responsibility to check the source edit, channel settings and YouTube's current requirements.

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 make a video seamless?

No. It asks FFmpeg to repeat the input indefinitely, but it does not edit the last frame into the first or repair an audio discontinuity. Review and, if needed, re-edit the source before streaming it.

Should I use -re for a prerecorded YouTube stream?

For file input used as a live-style source, -re commonly helps FFmpeg read at the file's native rate instead of sending it as quickly as possible. It does not correct an unsuitable frame rate, network problem or source seam, so check the output and YouTube's ingest guidance as well.

Can I concatenate any MP4 files with FFmpeg?

No. The concat demuxer expects compatible inputs with matching stream characteristics and reliable timing information. If the files differ, normalise them or use the concat filter with re-encoding, then inspect the transitions in the rendered result.

How do I know whether YouTube is receiving a healthy loop?

Test the actual command in Live Control Room and watch the preview and stream-health messages across a repeat point. Check the output's codec, bitrate, frame rate and keyframe behaviour against YouTube's current encoder settings, and listen for the audio boundary as well as watching the image.

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 ↗