Skip to content
streamneo.
Tools12 min read

FFmpeg Command to Stream a Playlist on YouTube Live

Build an FFmpeg concat playlist, loop it to YouTube Live, and check ingest credentials, output settings and stream health.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

To stream a local playlist to YouTube Live with FFmpeg, put the media paths in a concat-demuxer text file, then pass that file to FFmpeg and send its encoded output to the ingest URL and stream key for your live stream. The template below repeats the playlist, but looping the input does not guarantee gapless transitions or uninterrupted delivery.

You will need FFmpeg installed on the machine that can read the media files, a current ingest URL and stream key from YouTube Live Control Room, and an upload connection that can sustain the output you choose. Test the actual files and command before relying on it for a long-running channel.

Prepare a concat-demuxer playlist file

Create a plain text file named playlist.txt in the directory where you plan to run FFmpeg. Add one file line for each item, in the order you want it played:

file 'video1.mp4'
file 'video2.mp4'
file 'video3.mp4'

The concat demuxer reads these entries as a sequence of inputs. Use paths that are valid from FFmpeg’s working directory: relative paths are resolved from where the command runs, not necessarily from the folder where you happened to create the list. For fewer surprises, keep the playlist file beside the media or use full paths, such as file '/home/channel/videos/morning.mp4'.

The shown -safe 0 option in the command below permits paths that the concat demuxer would otherwise reject under its safe-path rules. That is useful with absolute paths, but it is not a substitute for checking every path yourself. Do not treat a playlist file received from someone else as trustworthy: inspect its entries before running it, especially if it contains unexpected paths.

Paths containing apostrophes need careful quoting in concat format. If your filenames use apostrophes, unusual characters, or platform-specific path syntax, check FFmpeg’s concat-demuxer documentation rather than guessing at escaping. The official FFmpeg documentation describes the concat demuxer and its file directives. Start with a short list of ordinary filenames if you are learning the workflow.

Check the files and playlist order

Open playlist.txt and read it from top to bottom. Confirm the first item is the intended opening, the sequence is correct, and every referenced file exists and can be read by the account running FFmpeg. A typo may stop the process before a feed is sent; an inaccessible file can interrupt playback later when FFmpeg reaches it.

Do not assume that any collection of media files can be joined cleanly just because each file plays on its own. The files may have different codecs, video dimensions, frame rates, audio streams, or channel layouts. The concat demuxer works best when the relevant stream layouts are compatible. When they are not, encoding the output as in the template can help produce a consistent output format, but it does not make every input combination valid. Inspect files and test the whole sequence.

For a channel made from several clips, check more than the first and last item. Listen for an unexpectedly loud transition, missing audio, black frames, wrong orientation, or a clip that is shorter than expected. A devotional playlist might combine a long bhajan video with a brief title card; a title card with no audio can create a quiet interval even though the video feed continues. The guide to looping a YouTube playlist as a 24/7 livestream explores the broader programming choice, while this article concentrates on the local FFmpeg input sequence.

If your files are large or the machine struggles to read them, reduce unnecessary source complexity before building a long playlist. The advice in how to make video files smaller for a YouTube 24/7 stream is relevant when storage, decoding load, or upload capacity becomes the practical constraint.

Get the current YouTube ingest URL and key

Open YouTube Studio and enter the Live Control Room for the stream you intend to start. Copy the ingest URL and the stream key associated with that stream. Do not take a key from an old note or copy a value from an unrelated event: the destination and key must match the configured stream.

YouTube’s API documentation represents the ingest address and stream name separately. Some encoders have separate fields for URL and key; when a tool expects one destination, YouTube documents the combined form as STREAM_URL/STREAM_NAME. For FFmpeg, the template uses that combined form at the end of the command. Replace both placeholders with the current values from Live Control Room; they are not literal settings to paste unchanged. See YouTube’s liveStreams documentation for the ingest URL and stream-name fields.

Use RTMPS when YouTube provides it and your FFmpeg build supports it. YouTube describes RTMPS as encrypted delivery in its live encoder settings guidance. If FFmpeg reports that it cannot open the destination, first check whether you copied the correct protocol and URL, then confirm the installed build can use that protocol.

Treat the stream key as a password. Do not put a real key in a public script repository, tutorial, screenshot, or shared command history. Shell history can retain a pasted command, so consider how your account and machine handle it. If the key is exposed, reset it in Live Control Room and update the destination used by FFmpeg; YouTube’s stream key help page covers the credential and its management. Keep the key out of the playlist file, which should only contain media paths.

Build the FFmpeg command

Here is a template based on H.264 video and AAC audio. It is illustrative, not tested against your files or system. Replace playlist.txt, the encoding settings where needed, and the final destination with values appropriate to your setup:

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \\
  -c:v libx264 -preset veryfast -b:v 5M -maxrate 5M -bufsize 10M \\
  -g 60 -c:a aac -b:a 128k -ar 44100 \\
  -f flv "RTMPS_INGEST_URL/STREAM_KEY"

The backslashes continue the command across lines in common Unix shells. If you use a shell that does not recognise that syntax, put the command on one line or use that shell’s continuation rules. Windows Command Prompt, for example, does not use the same backslash line continuation. The quoted destination prevents shell interpretation of special characters in the URL or key.

-f concat -i playlist.txt tells FFmpeg to read the playlist through the concat demuxer. -safe 0 allows the path forms described above. -re reads input at its native rate rather than consuming files as quickly as the machine can process them, which is appropriate for a real-time feed from files. The output options after -i apply to the stream FFmpeg sends.

-c:v libx264 encodes video with H.264 using the libx264 encoder. -c:a aac encodes audio to AAC. Encoding instead of copying arbitrary input streams gives you a defined output codec, though it uses processing capacity and still requires compatible and decodable inputs. -f flv selects the container used for this RTMP-family output. Check that your installed FFmpeg includes the encoder you name; builds can differ.

The example sets a video bitrate and buffer values, and gives audio a bitrate and sample rate. They are examples, not guarantees of quality or suitability for every source. The final argument is the destination: put the current RTMPS ingest URL, a slash, and the stream key between the quotation marks if your encoder configuration expects a combined field. Never publish a command containing your live key.

If you need a different output size or frame rate, add appropriate output options and test the result. One command should not be treated as a universal preset for portrait clips, mixed frame rates, silent files, or a low-capacity connection. If your workflow also depends on timed changes to content, see how to set Indian Standard Time video schedules in an FFmpeg YouTube stream; scheduling content and maintaining a live encoder feed are related but distinct tasks.

Repeat the playlist without mistaking it for reliability

-stream_loop -1 tells FFmpeg to repeat the input indefinitely. In this command, the input is the concat-demuxer playlist, so FFmpeg is asked to return to the playlist after it reaches its end. The option does not repair unreadable files, harmonise mismatched streams, or ensure that the transition between the last and first items has no pause or visible change.

A loop describes what the player does with local input; it does not describe whether an audience always receives a live feed. The process can stop if the computer loses power, FFmpeg exits with an error, the network drops, or YouTube rejects the feed. A local loop also cannot guarantee that two adjacent files have matching picture or sound. Think of it as repeat behaviour, not a promise of continuous delivery.

For a short test, run the command and watch the terminal for errors as it progresses through the first transition. Leave it running long enough to verify that it reaches the end of the list and begins again. Check that the sequence restarts in the expected order and that audio and video remain present. A successful first minute is not proof that a much longer session will remain available.

If you are moving from a manually operated computer to an always-on channel, decide who will notice and respond if the process or connection stops. A person watching the machine can restart it, but that depends on their availability. When the pain is having to keep a home or shop computer on and manually recover a dropped feed, StreamNeo can run an uploaded video as a YouTube live stream with the computer switched off and automatically monitored and restarted if it drops. It is YouTube-only, so this is not a general-purpose destination for other platforms.

Choose and check output settings

Choose resolution, frame rate, and bitrate together. A larger picture or higher frame rate needs more data, and your upload connection must sustain the chosen output while leaving room for normal variation. YouTube’s current encoder guidance gives these H.264 examples:

Output profile YouTube minimum video bitrate YouTube recommended video bitrate
720p at 30 fps 3 Mbps 8 Mbps
1080p at 30 fps 5 Mbps 14 Mbps
1080p at 60 fps 6 Mbps 17 Mbps

These figures are YouTube’s encoder guidance, not a promise that a connection at the listed rate will deliver a stable feed or that every source will look good. YouTube advises choosing a reliable quality for the available connection. In the command, -b:v 5M is an example rather than a universal setting; it is below YouTube’s recommended 720p30 value in the table, so do not copy it blindly if you are targeting that profile. Check YouTube’s current table for the codec, resolution, and frame rate you actually plan to use.

YouTube’s guidance calls for constant bitrate, recommends keyframes every two seconds, and says the interval should not exceed four seconds. With 30 fps output, -g 60 requests a GOP of 60 frames, corresponding to two seconds if the output really is 30 fps. If your output frame rate differs, a fixed number of frames represents a different amount of time; align the GOP with the actual frame rate and confirm what FFmpeg produces. The simple template does not explicitly set every output property, so adapt and verify it rather than assuming source timing will match your target.

YouTube lists AAC or MP3 audio, recommends 44.1 kHz stereo, and audio bitrate guidance includes 128 Kbps for stereo. The example sets AAC, -ar 44100, and -b:a 128k, but it does not explicitly force a stereo channel layout. Inspect the output and source audio, especially if some playlist items are mono or have no audio. For a feed that should always have music or narration, a silent clip needs separate consideration; encoding options cannot create meaningful source audio that is absent.

If the connection cannot sustain a selected bitrate, lower the output demands or improve the connection before treating the stream as ready. If you change resolution, frame rate, or codec, revisit the related bitrate and keyframe settings rather than adjusting one number in isolation. A 4K 60fps Telugu movie songs loop setup is a useful example of why high-resolution, high-frame-rate ambitions need their own capacity and source checks rather than a generic command.

Test the feed in Live Control Room

Before making the playlist public, start a test with representative material: include moving video and the kind of audio the real channel will use. YouTube explicitly recommends testing with audio and movement similar to the intended live stream. A static title card or a silent clip alone will not reveal the problems that appear in the actual programme.

Watch both the FFmpeg terminal and the Live Control Room. In the terminal, look for input errors, missing streams, encoder failures, and repeated reconnect messages. In Live Control Room, check that the expected preview appears, the stream health is acceptable, and there are no warnings you have overlooked. YouTube’s guidance recommends monitoring stream health and messages during the event; a running command does not by itself confirm that viewers receive the intended feed.

If YouTube does not accept the feed, check the current URL and key first, including whether the destination is joined correctly. Then check that the protocol is supported, the output codec and keyframe interval meet current guidance, and the bitrate is suitable for the configured output. These are practical checks inferred from the published ingest and encoder requirements, not a diagnosis of every rejection. Change one relevant setting at a time and retest so you know what resolved the issue.

After a successful test, keep a copy of the command with the key removed, and store any credential separately in a way appropriate to the machine and account. Record the output profile and which playlist files you tested. If you revise the files, order, or encoding options, repeat the test; the new combination may behave differently from the earlier one.

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 guarantee uninterrupted YouTube Live?

No. It tells FFmpeg to repeat the input indefinitely, but it cannot prevent a network failure, process exit, rejected ingest, or problem in one of the files. Test the complete playlist and plan how you will notice and respond to a stopped feed.

Can I use files with different codecs or resolutions?

Possibly, but do not assume they will concatenate successfully or transition cleanly. Inspect the streams and test the full list; mismatched layouts or properties may require normalising or re-encoding the media before using the playlist.

Where do I find the stream key?

Find the key and ingest URL for the intended stream in YouTube Studio’s Live Control Room. Keep the key private, and reset it there if it is exposed, then update the destination in your encoder command.

Can I copy the example bitrate and keyframe settings as they are?

Treat them as a starting example, not a universal preset. Choose settings for your resolution, frame rate, codec, source, and sustainable upload capacity, then verify the feed against YouTube’s current encoder guidance and Live Control Room feedback.

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