To loop recorded sermons on YouTube Live with FFmpeg, put compatible files in a plain-text concat playlist, then pass that playlist to FFmpeg with -stream_loop -1. The important check comes first: the concat demuxer expects each file to have matching streams, codecs and time bases; it does not make mismatched recordings compatible by itself.
After checking and rehearsing the files, encode the playlist to the RTMPS address and protected stream key shown in your church’s YouTube Live Control Room. Treat the command below as a template, not a universal preset: output settings must suit the source material, your encoder and the upload connection that will actually carry the broadcast.
Check that the sermon files match
The concat demuxer joins files as a continuous input; it is not a general-purpose format converter. FFmpeg’s documentation requires each file in the list to have the same streams, codecs and time bases. In practical terms, two MP4 files can look similar in a media player and still differ in a way that causes trouble when joined. One may have stereo AAC audio while another has mono audio, a different sample rate, or no audio track at all. The video may also differ in codec, frame rate, dimensions or timing.
Before writing the playlist, inspect every recording with a media-information tool or ffprobe. Compare the number and type of streams, video and audio codecs, frame rates, dimensions, audio layout and time bases. You do not need to make every file visually identical at this stage, but you do need to know whether its stream structure is compatible with the others. Pay particular attention to sermons recorded at different times or exported from different editing software.
Duration information matters too. The demuxer uses each file’s duration to position the next one on the timeline. If a recording is truncated or reports an inaccurate duration, the next file can begin at the wrong timestamp and produce a gap or an audio/video artefact. A file that plays acceptably on its own is not necessarily ready for a long concatenated broadcast. Check that each sermon reaches its genuine ending and that the reported duration is plausible.
If the stream layouts differ, do not expect the concat demuxer to repair them. You can normalise the files beforehand to the same codecs, dimensions, frame rate, audio layout and timing, or use a filter-based concat workflow that re-encodes the joined output. That extra preparation can take time and encoder capacity, and re-encoding can affect quality. The demuxer is the simpler route when the inputs already match; normalisation or filtering is the more appropriate route when they do not. For a broader recorded-service workflow, see how to stream a recorded church service without a camera.
Write the playlist in playback order
Keep the sermon files and playlist in a stable directory on the machine that will run FFmpeg. Use a drive that will remain connected for the full broadcast, and prevent the computer from sleeping or restarting unexpectedly. A playlist cannot help if the file location changes or the operating system powers down during the night.
Create a plain-text file named, for example, sermon-playlist.ffconcat. Put this exact line at the very beginning, with no blank line or other text before it:
ffconcat version 1.0
file 'sermon-01.mp4'
file 'sermon-02.mp4'
file 'sermon-03.mp4'
The line ffconcat version 1.0 lets FFmpeg recognise the format automatically. The entries that follow set the playback order, so review them as you would a service running order: opening sermon first, then the remaining recordings, and finally the sermon that should lead back to the opening file. Use paths relative to the playlist’s working directory where possible. Names with spaces or special characters need correct quoting or escaping; test the exact file before committing to a long session.
FFmpeg applies safe-path checks to concat lists by default. Relative paths using ordinary letters, numbers, periods, underscores and hyphens are the least troublesome choice. Absolute paths, protocol-like paths and some path components beginning with a period can be rejected. The -safe 0 option relaxes those checks, but only use it for a playlist you created and trust: it allows paths that the default safety checks would refuse. It is not a compatibility switch and will not fix mismatched streams.
Keep the list under version control only if doing so cannot expose private material or credentials; the playlist itself should not contain your YouTube key. If volunteers edit the order, agree who updates it and how the final version is checked. A short, clearly named playlist is easier to audit than one assembled from files scattered across removable drives. For another playlist-ending workflow and its trade-offs, see how OBS can keep streaming when a video playlist ends.
Validate the concat input before streaming
Do not discover a broken list after the church channel is already live. First open the playlist as an FFmpeg input and inspect what it presents. A basic diagnostic command is:
ffmpeg -f concat -i sermon-playlist.ffconcat -f null -
This reads the listed input and sends decoded output to a null destination rather than publishing a stream. It can reveal missing files, parse errors and some decode problems. It is not a complete guarantee that the live encode or YouTube ingest will work, so regard it as one check in a rehearsal rather than certification.
Then run a local playback or encode through at least one full cycle. Listen across every join, including the last-to-first transition. Check for an abrupt cut, a black frame, silence, a change in loudness, unexpected aspect-ratio changes or audio that drifts out of sync. Inspect the beginning of each recording as well as the end: an opening fade or slate may be intentional, but a blank interval from a faulty export should not be a surprise to viewers.
If the local test reports timestamp or duration warnings, investigate before broadcasting. Re-check the media information, verify that files are not truncated, and consider normalising the source rather than suppressing warnings. The concat demuxer places each file after the previous one using duration information, so inaccurate metadata can affect the timeline. Rehearsing the loop also tests the practical behaviour of the installed FFmpeg build and helps catch a path that works on one volunteer’s account but not another.
Configure FFmpeg for YouTube output
For a straightforward compatible playlist, a template command looks like this:
ffmpeg -re -stream_loop -1 -f concat -i sermon-playlist.ffconcat \
-c:v libx264 -preset veryfast -b:v VIDEO_BITRATE -maxrate VIDEO_BITRATE \
-bufsize VIDEO_BUFFER -g GOP_FRAMES -keyint_min GOP_FRAMES -sc_threshold 0 \
-c:a aac -b:a AUDIO_BITRATE -f flv "$YOUTUBE_RTMPS_INGEST_URL"
Here -stream_loop -1 applies to the playlist input and asks FFmpeg to repeat it indefinitely. -re paces file input in real time, which is commonly used for file-based live output. Confirm the behaviour with your installed build and rehearse before relying on it. The video and audio options encode a continuous output, which is useful when source files or the ingest requirements need a consistent output format. Re-encoding consumes processing capacity and may reduce quality, so choose settings your encoder can sustain.
The uppercase values are placeholders, not literal FFmpeg options. Set bitrate and buffer values for the chosen output, and set the GOP options in relation to a fixed output frame rate. YouTube’s live encoder settings guidance describes supported ingest formats and recommends a two-second keyframe interval, with a four-second maximum. Its recommended bitrate depends on codec, resolution and frame rate. For H.264, the current guidance includes 8 Mbps for 720p at 30 fps and 10 Mbps for 1080p at 30 fps; these are recommendations, not a promise that your connection can sustain them.
Choose output quality based on the sermon files and reliable upload capacity, not the highest number in a table. YouTube’s streaming tips advise leaving 20% upload headroom. Other household or church-office traffic can reduce the capacity available to the stream, so test at the location and time you intend to broadcast. A lower stable output is preferable to a higher setting that repeatedly strains the connection. For checking bitrate and dropped frames during a live session, see how to check FFmpeg stream bitrate and dropped frames.
If the chosen sources are incompatible, this encoding command alone does not cure the concat demuxer’s matching-stream requirement. Normalise them first or build an appropriate filter-based concat pipeline. The right choice depends on how much preparation, processing capacity and quality trade-off the church can accept. A fixed, pre-tested output profile is easier for volunteers to repeat than changing settings on the day.
Use the channel URL and protect its key
Create or select the stream in the church’s YouTube Live Control Room and copy the current ingest URL and stream key shown there. YouTube supports RTMP and RTMPS ingest; use RTMPS when it is available for the selected stream. The precise endpoint and how the key is supplied can depend on the encoder setup, so follow the values presented for that channel rather than copying an endpoint from an old tutorial.
YouTube describes a stream key as a password for the stream. Keep it out of the playlist, screenshots, public shell transcripts, shared documents and source control. Do not paste it into a public support request. If your command combines the URL and key, shell history and process listings may expose it on some systems. Where practical, use a private configuration method supported by your setup, restrict access to the machine account, and avoid leaving terminal output visible to people who do not need the credential. If the key is exposed, reset it in Live Control Room.
The command uses an environment-variable-style placeholder rather than a real key. Set the variable privately for your own session or adapt the command to the credential handling available on your system. Do not publish the completed command. Confirm that the output destination is the exact channel and scheduled event intended; sending to the wrong configured stream can create confusion even when the encoder is working correctly.
There is also a distinction between looping your input and YouTube’s own broadcast session. -stream_loop -1 repeats the local playlist, but it does not mean every scheduled YouTube event can run forever. YouTube’s current Help guidance says streams under 12 hours are automatically archived. If the church plans to run longer, decide in advance how to handle YouTube’s session limits, event continuity and any archive needs rather than assuming a single uninterrupted session will be accepted indefinitely.
Run a preflight and inspect the output
Start the encoder early enough to inspect the incoming preview before telling viewers to join. In Live Control Room, check that the correct event receives the signal and that picture and sound are present. For a scheduled stream, wait for the preview and use the Control Room’s Go live control when ready. YouTube’s encoder setup instructions describe sending the signal and checking the preview; follow the current interface, as controls can change.
Use a written preflight that a second volunteer can follow. Confirm that the machine is on mains power, sleep is disabled for the planned run, the source drive is mounted, the playlist path is correct and every file opens. Check the clock and schedule, verify the wired or chosen network connection, and make sure no pending update or restart is about to interrupt the session. Confirm that the output resolution and audio are sensible in the preview before the stream is public.
Once live, monitor YouTube’s stream health and any encoder messages. Listen on a separate device if possible, because a preview on the encoding computer may not reveal the same playback experience viewers receive. Check at the start, after a few transitions and at intervals that fit the church’s staffing. Monitoring is not a guarantee against interruption; it gives someone a chance to notice and respond to a problem.
For a church that cannot keep a workstation and volunteer available through every hour of a continuous broadcast, StreamNeo can remove the specific burden of leaving that computer running: you upload the video, connect the channel’s key, and the stream continues with the computer off. It remains a YouTube-only option, and the church still needs to prepare compatible content, confirm its channel setup and monitor the live result.
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
How do I loop a playlist on YouTube Live with FFmpeg?
Put compatible files in a concat playlist in the desired order, then place -stream_loop -1 before the playlist input in the FFmpeg command. Encode the output to the current URL and key from YouTube Live Control Room, and rehearse the joins and connection before going live.
Can I concatenate sermons with different formats?
Not reliably with the concat demuxer as-is. FFmpeg expects matching streams, codecs and time bases; normalise the files first or use a filter-based workflow when their structures differ.
Why does the playlist need accurate durations?
The demuxer uses a file’s duration to place the following file on the timeline. Incorrect duration information can introduce timestamp gaps or artefacts, so check the files and test the complete loop before streaming.
What should I do if YouTube does not show a preview?
Check that FFmpeg is running, the selected stream is the intended one, and the ingest URL and protected key match the values currently shown in Live Control Room. Inspect FFmpeg’s messages and YouTube’s stream-health notices, but do not share the key while asking for help; reset it if it may have been exposed.