To send several video files in sequence from an EC2 machine to YouTube Live, FFmpeg can read a text playlist using its concat demuxer. The playlist controls file order; it does not make clips with different codecs, stream layouts, or time bases compatible.
The reliable starting point is to inspect the files, decide whether they can be concatenated as they are, and prepare a common format for any that cannot. Then connect FFmpeg to the ingest URL and stream key shown in YouTube Live Control Room, and test the transitions before relying on the process unattended.
Prepare the EC2 FFmpeg environment
Treat the EC2 machine as the place where files are read and the outgoing live feed is encoded or passed through. Before building a playlist, confirm that FFmpeg is installed, that the instance can read every source file, and that the FFmpeg build includes the protocols and encoders your eventual output needs. The example later in this article is a command skeleton, not a tested deployment or a universal command.
Keep the source files in a known directory and use paths that remain valid after a restart. Check file names carefully, including spaces and letter case. On a Linux filesystem, Clip.mp4 and clip.mp4 may be different names. If the files are on a mounted volume, verify that the mount is available to the process that will run FFmpeg rather than assuming an interactive login and a background service see the same paths.
For an unattended stream, also decide how the process is started again after a machine reboot and where you will read its logs. That is separate from concat: the playlist does not supervise FFmpeg or repair a missing input. If you are choosing EC2 because the stream needs to run while your own computer is off, compare the operating trade-offs in this guide to a low-cost cloud server for an ambient stream. Instance capacity depends on whether you copy streams or encode them, the source and target formats, and whether other work shares the machine. There is no sound instance-size recommendation without those details.
Create a concat-demuxer list file
The concat demuxer reads a plain-text file whose entries identify the media files in sequence. Create a file such as playlist.txt and put one file directive on each line:
file '/path/to/video-01.mp4'
file '/path/to/video-02.mp4'
file '/path/to/video-03.mp4'
The order of the directives is the playback order. Use the FFmpeg concat demuxer documentation as the reference for its syntax and constraints, and keep the list file separate from the media files so it is easy to inspect and update. This is not an M3U file or a YouTube playlist: it is an input description that FFmpeg reads locally.
A relative path is resolved in relation to the list file, which can make a playlist easier to move as a unit. An absolute path is explicit but ties the list to that location on the machine. Whichever style you choose, test that FFmpeg can open every entry under the account and working directory used by the actual stream process.
The option -safe 0 is often shown in concat examples because it allows paths the demuxer otherwise rejects as unsafe. It should not be treated as a fix for bad paths or untrusted input. Use it only when you control the playlist file and have checked what it names; never let outside users supply a list that your process executes without review.
Add each clip with a file directive
Each clip gets its own file line. Avoid trying to cram several paths onto one directive, and do not rely on alphabetic file sorting unless that is truly the order you want. A list named video-1, video-10, video-2 may not sort in the human order you expect, so write the order deliberately and review it before streaming.
A conceptual command using that list looks like this:
ffmpeg -re -f concat -safe 0 -i /path/to/playlist.txt \
-c:v libx264 -c:a aac \
-f flv "$YOUTUBE_INGEST_URL/$YOUTUBE_STREAM_KEY"
This only illustrates where the playlist input and output destination fit. It is not validated as a complete command for a particular EC2 instance or YouTube event. Before using a command, choose the output codec, bitrate, resolution, frame rate, audio handling, keyframe behaviour, and any filters based on the media and the current YouTube requirements. A stream-copy workflow would use different output options and only makes sense when the input streams already satisfy the target and concat requirements.
The -re option reads media at a real-time pace rather than consuming a file as quickly as possible. It does not mean the stream will stay live indefinitely or automatically loop the playlist. A finite concat list ends when its listed files are exhausted. If you intend a recurring channel, establish separately how the list repeats or how a new run begins, and test that behaviour; do not assume that a playlist file itself creates a permanent loop.
Check codecs, layouts, and time bases
The central compatibility check is not whether every file ends in .mp4. The extension says little about the actual streams inside. FFmpeg's documented concat operation expects the files to have matching streams, codecs, and time bases. Different dimensions, pixel formats, frame rates, audio layouts, or timestamp patterns can be signs that direct concatenation needs more inspection or preparation.
Inspect each input with a media probe such as ffprobe and record the video codec, dimensions, frame rate, pixel format, audio codec, sample rate, channel layout, and duration. Compare the results side by side. Pay particular attention to files that came from different cameras, editing exports, or online sources: two files labelled H.264 may still have differing stream parameters that matter to a sequential FFmpeg input.
| Choice | When it fits | Main trade-off |
|---|---|---|
| Use the concat demuxer with existing files | The files meet the documented compatibility assumptions and the intended output settings | Less preparation, but mismatches can cause errors or unwanted transitions |
| Normalise or transcode clips first | The files differ in properties you need to make consistent | Adds a preparation step and encoding work, but gives you a common target to inspect |
| Stream copy at output | Inputs already match each other and the chosen delivery format | Reduces encoding work, but cannot correct incompatible streams or change their properties |
| Re-encode for output | You need to standardise output or meet selected delivery settings | Uses compute and can introduce quality loss; test the actual result |
A single list file cannot reconcile different time bases or silently turn unlike audio layouts into one consistent stream. Also check duration metadata: FFmpeg uses durations when adjusting timestamps between files, and inaccurate durations can create timestamp artifacts at transitions. If the next clip starts with a jump, repeated frame, or audio disturbance, compare its reported duration and timestamps with the media itself instead of changing YouTube settings first.
For a broader fixed-output workflow, the 1080p and fixed-frame-rate playlist guide can help frame the choices. It does not remove the need to verify your particular source clips.
Normalise incompatible clips when needed
When clips differ in stream properties, prepare them to a deliberate common target before making the concat list. For example, decide on one frame size, frame rate, video codec, audio codec, sample rate, and channel layout that suit the planned broadcast. The precise values depend on the source content and the output settings selected for the YouTube stream; there is no one profile that is right for every channel.
Normalisation may mean re-encoding video, resampling or remapping audio, correcting rotation, or fitting different aspect ratios into a consistent canvas. Decide whether to preserve the entire frame with letterboxing or crop content to fill the canvas. Preview the result, particularly when the source has subtitles, devotional lyrics, product details, or news text near the edges. A technically consistent file can still be a poor editorial fit if important content is cut off or scaled too small.
You can keep the originals and write normalised copies to a separate directory. Then probe the copies and build the concat list from those, not from a mixture of original and prepared versions. This makes it easier to identify which stage caused a problem and lets you regenerate one clip without losing the source. Community discussions often recommend pre-transcoding heterogeneous media as a practical approach, but the compatibility basis should remain the FFmpeg documentation, not an assumption that a particular conversion guarantees a clean join.
Re-encoding costs time and compute compared with copying compatible streams. On EC2, validate CPU load and sustained outbound network throughput with the chosen clips and settings. YouTube recommends upload capacity with a margin of 20% over the combined primary and backup stream bitrate; for a single-feed setup, treat that as guidance to leave headroom rather than as evidence that a given instance or path will sustain the feed. If your concern is a home-origin stream, the BSNL broadband jitter and packet-loss troubleshooting guide covers a different part of the path; it does not substitute for testing EC2 egress.
Set the YouTube ingest URL and stream key
Create or open the live event in YouTube Live Control Room and use the ingest URL and stream key displayed there. The URL identifies the ingest endpoint; the key identifies where YouTube should accept the encoder feed. YouTube explains how to manage live stream settings, including the stream key. Prefer the RTMPS URL when it is available and supported by the FFmpeg build and workflow. YouTube recommends RTMPS because it encrypts the ingest connection in transit; see its RTMPS setup instructions.
Treat the key as a credential. Do not commit it to a playlist file, public script, shared screenshot, or a log that other people can read. In the command skeleton, environment variables are shown to make the secret's location visible without writing a real key into the example. Protect whatever method you use to provide the key, and reset it through YouTube if it is exposed. Verify the exact URL format shown for your event rather than copying an endpoint from an old command.
YouTube's encoder guidance varies by codec, resolution, and frame rate. For example, its H.264 1080p30 row lists 5 Mbps minimum and 14 Mbps recommended; those values are recommendations for that specific row, not a universal bitrate or a promise of delivery. Check the current live encoder settings for the format you intend to send. The guidance also covers frame-rate limits, audio formats, and keyframe intervals, so set output parameters from the relevant row rather than carrying over settings from a different resolution or codec.
The selected output container and codecs must also be compatible with the YouTube ingest workflow. In the conceptual example, -f flv indicates the output format associated with an RTMP-style feed, but the full output configuration still needs to match the chosen endpoint and the FFmpeg build. Confirm protocol support and do a controlled test before an unattended run.
Test transitions and playlist behaviour
Test the playlist end to end with the exact files, output settings, and destination you plan to use. Watch and listen through every transition, not just the first few seconds of the first clip. Check for a frozen or repeated frame, a change in aspect ratio, silence, audio level shifts, timestamp warnings, and whether the next file begins where you expect. A clean first transition does not prove that every later pair is compatible.
Review FFmpeg output for input-open failures, timestamp messages, and encoder errors. If a transition fails, reproduce it with the two neighbouring files in a short test list. That narrows down whether the issue is specific to a pair, a bad path, or the overall output setup. Re-check reported durations where timestamps look wrong, since duration values influence timestamp adjustment between files.
Test whether the list ends, repeats, or needs an external restart in the way you intend. If you are building a channel that must continue beyond one finite sequence, define the repeat or scheduling behaviour explicitly and observe it in a test. YouTube says streams under 12 hours are automatically archived in its encoder setup guidance, but do not extrapolate that into an archive promise for a longer broadcast. Check current Live Control Room behaviour for the duration you plan.
During the test, watch the YouTube preview and the EC2 process, then verify that the event reaches the expected live state. Network headroom and encoder capacity are different failure points: stable outbound bandwidth does not prove the CPU can encode the selected settings, and spare CPU does not prove the network path is stable. StreamNeo can remove the specific burden of keeping your own computer running by turning an uploaded file into a YouTube-only 24/7 stream, but it is not a replacement for validating a multi-file FFmpeg workflow on EC2.
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 the concat list make different video files compatible?
No. It specifies order, not conversion. FFmpeg documents matching streams, codecs, and time bases for concat demuxer use, so inspect the files and normalise them first when their properties differ.
Can I use -c copy to avoid encoding?
Only when the inputs already meet the concat requirements and the output is suitable for the YouTube ingest settings you selected. Stream copy cannot fix mismatched streams, change resolution, or standardise frame rate. Test the exact sequence before relying on it.
Does the playlist repeat automatically for a 24/7 stream?
A concat list describes the files to read in order; it does not by itself promise an endless loop. Decide how repetition or restarting should work, then test that behaviour with the same process you intend to run unattended.
What should I check if the second clip starts with a timestamp jump?
First check the adjacent files' stream properties and duration metadata, then inspect FFmpeg's timestamp messages. FFmpeg uses file durations to adjust timestamps between concatenated inputs, so inaccurate duration information can contribute to artifacts.