Skip to content
streamneo.
Setup Guides12 min read

How to Loop a Video on YouTube Live with FFmpeg Concat Demuxer

Build an ffconcat playlist, check stream compatibility and pace a repeating FFmpeg input for YouTube Live.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

To loop a video or a playlist on YouTube Live with FFmpeg, create an ffconcat text file, feed it to the concat demuxer, and put -stream_loop -1 and -re before the input. Then encode a compatible live output and send it to the RTMPS endpoint and stream key shown in YouTube Live Control Room.

The concat demuxer joins files virtually rather than making a new joined file first, but it expects their streams to match. Treat the command below as a starting pattern, not a universal preset: adapt paths, ingest details and encoding choices to your files, FFmpeg build, connection and YouTube’s current requirements.

Check the files and playback order

Start by deciding exactly what the viewer should hear and see. A single video can be looped repeatedly; a playlist can present several files in a set order before starting again. Put the intended order in writing before creating the playlist, especially if a devotional programme, news loop or study station has segments that should not be shuffled.

Inspect every source file, not just the first one. Check that it has the expected video and audio, that playback is not corrupt, and that its duration and ending are sensible. A file that opens in a desktop player is not necessarily suitable as part of a concat-demuxer input: the files must expose compatible streams, as covered below.

FFmpeg must also be installed in a build with the output encoder and muxer you intend to use. Run ffmpeg -version to identify the installed build. If you use a particular encoder such as libx264, check that the build includes it; encoder names and available options depend on how FFmpeg was packaged.

For a basic inspection, ffprobe can report streams and their properties:

ffprobe -v error -show_streams -show_format -of json video.mp4

Compare the output for every file in the planned sequence. Note the number of audio and video streams, their codecs, dimensions, frame rates and time bases. Also listen through the joins you expect to use. A short silence, abrupt cut or change of loudness can be a content decision, but it is better to notice it before going live.

If you are selecting source material for an always-on music channel, the practical considerations in setting up a YouTube music stream from a PC in India provide useful context around preparing a continuous programme. For this FFmpeg workflow, however, the file order and stream properties are the decisive first checks.

Create an ffconcat playlist

The playlist is a plain UTF-8 text file. Its first line must be exactly ffconcat version 1.0; put one file directive on each following line. For one source, save a file such as playlist.ffconcat with this content, replacing the example path:

ffconcat version 1.0
file '/path/to/video.mp4'

For several sources, add one directive for each file in playback order:

ffconcat version 1.0
file '/media/programme/opening.mp4'
file '/media/programme/main-set.mp4'
file '/media/programme/closing.mp4'

Those paths are examples, not locations to copy literally. Use paths that exist on the computer running FFmpeg, and take care with spaces, quotes and special characters. Consult FFmpeg’s concat demuxer documentation for the playlist syntax and escaping rules. A malformed path can prevent FFmpeg from opening a file, while an incorrect order can produce a technically valid but editorially wrong programme.

The -safe option affects which paths the demuxer accepts. Prefer safe, straightforward relative paths where practical. If your controlled playlist needs absolute paths or another form rejected by the safe-path rules, -safe 0 may be necessary. Use it only for a playlist you created and trust: do not pass an untrusted playlist to FFmpeg with relaxed path checks.

The demuxer uses file duration information to place successive inputs on the timeline. If duration metadata is inaccurate, a later segment may begin at an unexpected timestamp, creating a gap or a boundary artefact. FFmpeg’s playlist format supports a duration directive when you need to override a file’s stored duration. Use a duration only when you have established the correct value; guessing can move the problem rather than fix it.

Confirm compatible streams across files

A concat playlist does not make unlike media compatible. FFmpeg’s documentation states that the files must have the same streams, codecs and time bases, among other properties. Compare the probe output and verify that each file has the same stream layout and compatible properties before you rely on the demuxer.

For example, a sequence where one file has H.264 video and AAC audio but another has a different video codec or an extra audio stream may not behave as expected. Differences in frame rate, dimensions, sample rate, pixel format or time base can also matter. Do not assume that two .mp4 extensions mean the contents match; a container name does not establish matching streams.

There are two sensible routes. If all inputs already match, the concat demuxer is useful for presenting them as one virtual input without first joining and re-encoding the files. If they do not match, normalise them so the streams agree, or use FFmpeg’s concat filter as part of a re-encoding workflow. The filter provides more control over changes such as scaling and audio resampling, at the cost of processing the media and choosing output settings.

Situation Practical approach Trade-off
Files have matching streams and time bases Use the concat demuxer playlist Avoids a pre-join re-encode, but does not repair mismatches
Files differ in stream layout or media properties Normalise first, or use the concat filter and re-encode More control over output consistency, with extra processing and quality decisions
A join has a gap or artefact Check file duration and timestamps; use an accurate duration override if appropriate Requires finding the source of the timeline error rather than hiding it

If only one file is being repeated, compatibility between multiple files is not an issue, but the file must still decode correctly and suit the output you plan to send. For several files, test transitions as well as each file individually. The guidance in troubleshooting pre-recorded videos that do not play on YouTube is relevant if a source seems sound locally but fails once used in a live workflow; here, also check the FFmpeg input and concat requirements.

Pace and repeat the input correctly

The input options have different jobs. -stream_loop -1 tells FFmpeg to repeat the input indefinitely. -re reads file input at its native rate, which is useful when a file is being sent as a live feed: without pacing, a local file can be read faster than real time, rather than delivered in time with its playback.

Both options belong before the -i they apply to. With the concat demuxer, a basic input pattern is:

ffmpeg -stream_loop -1 -re -f concat -safe 0 -i playlist.ffconcat \
  ...output-options... -f flv 'rtmps://STREAM_URL/STREAM_KEY'

The ellipsis is explanatory and is not a complete command. Replace it with suitable output options and your own RTMPS URL and stream key. Omit -safe 0 if you do not need it for your paths. FFmpeg’s command-line documentation explains option placement and input looping; verify the syntax against the version installed on your machine.

For a playlist of compatible files, the demuxer presents the list as the input, and the input-loop option repeats that input rather than requiring you to add each file forever. Test whether the final-to-first transition is acceptable. Looping repeats content; it does not create a smooth musical or visual transition where the last frame and first frame differ.

Do not confuse a process that is still running with a properly paced stream. Check that timestamps progress and that the outgoing feed is arriving as live media. A wrong duration estimate or damaged timestamp at a file boundary can affect continuity even if FFmpeg continues running. If you need to adjust durations, establish them from the media rather than inserting arbitrary values.

Choose encoding settings for YouTube Live

The output encoder settings should reflect the actual source, desired resolution and frame rate, available upload capacity and YouTube’s current guidance. YouTube’s encoder settings guidance lists supported choices and bitrate recommendations by codec, resolution and frame rate. Check that table when you configure the stream; a bitrate that fits one resolution or frame rate may not suit another.

YouTube currently recommends keyframes every two seconds and says not to exceed four seconds. For a fixed output frame rate, the GOP length in frames is approximately the frame rate multiplied by the keyframe interval in seconds. Thus an illustrative -g 60 is a two-second GOP only at 30 frames per second; it is not a universal value. Match the GOP to the output frame rate and recheck YouTube’s current recommendation.

The following is an illustrative H.264/AAC command pattern, not a tested template or a prescription for every input and connection. It uses example settings from the research notes, including a 30 fps-style keyframe count, which must be adapted:

ffmpeg -stream_loop -1 -re -f concat -safe 0 -i playlist.ffconcat \
  -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k \
  -g 60 -keyint_min 60 -sc_threshold 0 \
  -c:a aac -b:a 128k -ar 44100 \
  -f flv 'rtmps://STREAM_URL/STREAM_KEY'

Replace the example values with settings suitable for the files, output frame rate, YouTube’s current encoder table and the connection. The shown -g 60 and -keyint_min 60 imply a particular frame cadence only when the output is 30 fps. If the output frame rate differs, calculate a corresponding frame count for the desired keyframe interval. Confirm that your chosen encoder and options are present in your FFmpeg build.

As one reference point, YouTube’s current guidance gives H.264 at 1080p30 a minimum bitrate of 5 Mbps and a recommended bitrate of 14 Mbps. Those are recommendations for that particular output format, not a guarantee of quality or a command to use those values for another resolution, frame rate, codec or connection. Use the current table for your intended settings and make sure the sustained upload capacity can carry the video and audio output without saturating the connection.

A source with a different frame rate or dimensions may need scaling or frame-rate conversion; avoid changing it casually if you have not considered quality and processor load. If you encode a mismatched playlist as one output, the filter-and-re-encode path can normalise the inputs, but it adds decisions about scaling, frame rate, audio and bitrate. For a deeper look at encoder load and dropped frames, see FFmpeg NVENC settings to check when a YouTube stream drops frames. That article concerns NVENC; the general lesson here is to distinguish encoding capacity from network and source problems.

Add the RTMPS endpoint and stream key securely

In YouTube Live Control Room, select the relevant stream settings and copy the exact RTMPS server URL and stream key. YouTube recommends RTMPS, an encrypted connection for sending the broadcast. Its RTMPS guidance and stream settings help explain where to find the details and how the key is used.

Replace the placeholder output URL in the command with the exact endpoint and key supplied for your stream. Do not guess the endpoint, reuse an old value without checking, or publish a key in a public script, screenshot or support post. YouTube describes stream keys as similar to a password and address for the stream. Treat them as credentials: restrict access to the command or configuration where you store them, and reset the key if you believe it has been exposed.

The example uses the RTMPS/FLV route. This guide does not specify an HLS setup; protocol support and configuration vary, so use YouTube’s current documentation if you need a different ingest path. If a connection fails, check the exact URL, key and protocol first. YouTube’s RTMPS help also points to port 443 when investigating TLS connection errors. Avoid changing multiple unrelated settings at once, so the cause remains clear.

Verify output and monitor the broadcast

Run a short test before relying on an unattended broadcast. YouTube recommends testing with audio and movement similar to the actual stream. Confirm the preview appears, audio is audible, motion is present where expected, and the status messages in Live Control Room do not indicate an ingest or stream-health problem. Watch at least one file boundary and, for a playlist, the point where the final file returns to the first.

Keep the FFmpeg output visible during the test. Messages about an input not opening, stream mapping, encoder initialisation, timestamp discontinuities or a broken connection can narrow down the problem. If the preview is absent, check the endpoint and key. If playback is too fast or the feed is not behaving like live media, confirm -re is before the input. If output ends after one pass, confirm -stream_loop -1 is also before the relevant -i.

For buffering or poor quality, compare the configured bitrate with the current YouTube table and check whether the upload connection can sustain it. Stream health helps distinguish a connection issue from an input or encoding issue, but it cannot tell you whether the programme’s content order is right. Listen and watch for that yourself. The practical checklist in fixing dropped frames on a YouTube Live stream can help you separate common causes; change one relevant setting at a time and test again.

A process left running on a PC remains dependent on that PC, its power, its network and the FFmpeg process. If you need a continuous channel without leaving your own computer on, StreamNeo takes away the repeated task of keeping a local FFmpeg process running by turning an uploaded video into a YouTube live stream. It is YouTube-only, so it is not a substitute if you need local FFmpeg control or another platform.

YouTube says first-time live-stream enablement can take up to 24 hours, so do not plan a first broadcast on the assumption that access will be immediate. Its encoder setup guidance also says streams under 12 hours are automatically archived; do not assume the same archival behaviour for longer streams. Check YouTube’s current pages before planning around enablement or archive expectations.

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 repeat every file in my playlist?

With the concat demuxer supplied as the input, it repeats that input indefinitely, including the files listed in the playlist. Put the option before the corresponding -i, then test a full pass and the return to the first item to confirm the order and boundary behaviour.

Why use -re if the file already has a frame rate?

A file can be read from disk faster than its intended playback rate. -re paces file input at its native rate, which is useful when delivering the file as a live feed rather than letting FFmpeg consume it as quickly as the computer permits.

Can I concatenate MP4 files with different properties?

Not reliably by simply listing them in the concat demuxer. Check that streams, codecs and time bases match; if they do not, normalise the files or use a concat-filter workflow that re-encodes to consistent output.

Is the example encoding command right for my channel?

It is an illustration, not a universal configuration. Choose codec, bitrate, resolution, frame rate and GOP based on your source and connection, then compare them with YouTube’s current encoder guidance and test the resulting stream.

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 Setup Guides guides ↗ · All topics ↗