Mixed MP4 and MKV files can be played in sequence as one YouTube Live broadcast from a VPS, but their extensions do not tell you whether their streams are compatible. Inspect the video and audio inside each file, make the playlist’s inputs compatible, then use FFmpeg to read the sequence in real time and send a YouTube-ready feed.
The practical workflow is to check the files, test the joins, and only then automate the broadcast. Use the RTMPS ingest URL and stream key shown in YouTube’s Live Control Room, and keep the key private. A playlist that starts successfully is not proof that its joins, audio, or network connection will hold up over a long stream.
Inspect the streams inside each file
MP4 and MKV are containers. A container holds streams and related metadata; it does not promise a particular video codec, audio codec, frame rate, resolution, or number of tracks. Two .mp4 files can differ substantially, as can an MP4 and an MKV. The extension alone is not a useful compatibility check.
Use ffprobe, which is distributed with FFmpeg, to examine files before building the playlist. For a first look at a file, run:
ffprobe -hide_banner -i "part-01.mp4"
Read the output for each video and audio stream: codec, dimensions, frame rate, sample rate, channel layout, and duration. Check whether there are multiple audio tracks, subtitles, or files with no audio. Repeat for representative files from both containers and for any that came from a different source or export process. If a file has two audio tracks while another has one, a command that blindly selects the first audio track may still work technically but play the wrong language or commentary.
For a more structured inventory, you can ask ffprobe to report stream fields in a compact format:
ffprobe -v error -show_entries stream=index,codec_type,codec_name,width,height,r_frame_rate,sample_rate,channels,time_base -of compact "part-01.mkv"
This is an inspection aid, not a validation test. A matching list of visible fields is encouraging, but it does not establish that every packet and timestamp will concatenate cleanly. Look at the actual files, and plan to test transitions before sending the output to viewers.
YouTube’s live encoder settings guidance describes accepted ingest and encoding choices. The stream you send must meet YouTube’s live requirements; a source file that plays locally is not automatically a suitable live encoder feed. Keep the source inspection and the final output settings as two separate checks.
Check concat compatibility across files
FFmpeg’s concat demuxer treats a set of inputs as sequential packets from one virtual input. For this to work reliably without re-encoding, the inputs need matching stream layouts and compatible codecs and time bases. In practice, compare the number and order of video and audio streams as well as the codecs and timing information. Files with different dimensions or frame rates may require a common output format rather than direct stream copy.
This is why conversion from MKV to MP4, or the reverse, is not a fix by itself. Changing the container does not necessarily change the video or audio codec, align the frame rates, or correct duration and timestamp problems. If sources differ in the parts that matter to the concat operation, normalise or transcode them as needed. The FFmpeg concat demuxer documentation sets out its compatibility expectations and timestamp behaviour.
When sources are already compatible and their embedded codecs suit the output, stream copy can avoid a new lossy encode and reduce CPU use. FFmpeg’s -c copy passes compressed streams along without decoding and re-encoding them. It also means you cannot resize, filter, or change the codec in that step. Copying is not a workaround for incompatible inputs.
If you need to unify the files, make a deliberate normalisation decision. For instance, you might create versions with one video codec, a shared frame size and frame rate, and a consistent audio codec and channel layout. That consumes CPU during preparation and re-encoding can reduce quality, so do it only where the source mismatch or required output setting calls for it. Test a short representative section on the VPS before preparing a full library.
The concat demuxer adjusts timestamps using the duration of each preceding file. FFmpeg warns that gaps can occur if streams inside a file do not end together, and inaccurate durations can produce artefacts at joins. Inspect duration and test a transition with both picture and sound. A long black frame, a pause, a repeated moment, or an audio cut that is easy to miss in a file preview may be obvious when played live.
Build an ordered input playlist
Create a plain-text playlist in the exact order you want viewers to see the files. Keep the playlist and media in a directory with simple relative paths owned by the account that runs FFmpeg. A basic list looks like this:
ffconcat version 1.0
file 'part-01.mp4'
file 'part-02.mkv'
file 'part-03.mp4'
The first line must be exactly ffconcat version 1.0 for automatic format recognition. The filenames above illustrate the order; use the real filenames in your directory. Paths containing spaces or special characters need correct quoting or escaping. The demuxer’s safe-path behaviour can reject unsafe paths or directives, so avoid elaborate absolute paths unless you understand the relevant options and have secured the list.
The playlist is a schedule, not a transition editor. It does not blend the end of one file into the start of the next. It presents one input after another, with timestamps based on durations. If your source files have inaccurate duration metadata, the concat format supports a duration directive, but do not add guessed values merely to make the list look tidy. Confirm any adjustment by testing the affected join.
Choose a sequence that reflects the channel’s purpose. A devotional channel might rotate a set of bhajans, while a study channel could place an introduction before longer ambience files. Check that the first file is suitable for the initial live preview and that a sequence does not inadvertently include a private recording, an editing slate, or a segment whose audio level is much louder than the rest.
If the files need different stream maps, account for that before using a single concat input. A command mapping 0:v:0 and 0:a:0 assumes each concatenated input has a first video and first audio stream. Where that assumption is false, resolve the track layout or create normalised inputs first. This is a useful place to review sound-file problems in a stream before treating silence as a YouTube ingest fault.
Read files at real-time speed
A local media file can be read as quickly as the machine permits. A live encoder must instead deliver at a pace that corresponds to the programme’s playback time. In FFmpeg, -re asks the input to be read at its native frame rate, which is useful when flow speed matters, including live streaming.
For already-compatible inputs, a schematic command is:
ffmpeg -re -f concat -safe 1 -i playlist.ffconcat \
-map 0:v:0 -map 0:a:0 -c copy \
-f flv "$YOUTUBE_RTMPS_URL/$YOUTUBE_STREAM_KEY"
This is an example to adapt, not a tested command for every FFmpeg build or YouTube endpoint. Check the output of ffprobe before using those stream maps, and change them if your files have another layout. Follow the exact URL and key arrangement displayed in Live Control Room; do not append the key blindly if the displayed endpoint already includes the necessary path.
The example also does not create an endless loop, handle every network interruption, or guarantee an unattended restart. If your broadcast should repeat, arrange the playlist or FFmpeg process to repeat according to the installed version, then test the behaviour at the end of the list. For a channel that needs to remain on after a session, plan separately for process supervision, log review, and a way to notice that the broadcast has stopped.
A VPS makes it possible to keep a programme running without leaving a personal computer on, but you still own the operational checks. Consider whether maintaining a VPS, its FFmpeg command and its restart behaviour fits your time and technical comfort. The continuous-stream guide without maintaining a server discusses the different operating burden. StreamNeo removes the need to keep that FFmpeg process running on your own VPS by letting you upload the video and run the YouTube broadcast with your computer off.
Encode to YouTube-accepted output settings
If the files are compatible and their codecs are suitable, stream copy can be a reasonable low-CPU path. If you need to change dimensions, frame rate, codec, or audio layout, decode and re-encode to a consistent output instead. Transcoding uses more CPU and can be lossy, so test the workload on the VPS with representative motion and sound before committing to a long session.
YouTube’s current guidance for RTMP/RTMPS lists H.264, H.265, or AV1 video, frame rates up to 60 fps, constant bitrate (CBR), and AAC or MP3 audio. It recommends a two-second keyframe interval and says not to exceed four seconds. For standard SDR, its guidance specifies Rec. 709 and 8-bit; its advanced audio recommendations include 44.1 kHz stereo and 128 Kbps stereo audio. Consult the current encoder settings page when choosing your actual parameters, because source material and available VPS capacity differ.
For H.264, YouTube’s published recommended video bitrates include 14 Mbps for 1080p at 30 fps and 8 Mbps for 720p at 30 fps. Those figures apply to video, not the entire outbound stream: audio and protocol overhead add to egress. YouTube also recommends 20% upload headroom. Choose a resolution and bitrate that the VPS can sustain continuously, not just during a brief test or according to an advertised port speed.
| Output choice | YouTube-recommended H.264 video bitrate | What to weigh |
|---|---|---|
| 1080p at 30 fps | 14 Mbps | More detail, with greater sustained outbound demand |
| 720p at 30 fps | 8 Mbps | Lower video bitrate, which may suit limited VPS capacity |
These are reference points from YouTube’s published guidance, not a promise that a particular VPS will sustain them. Add audio and protocol overhead, then allow the recommended headroom when assessing the connection. Check the VPS provider’s actual transfer and bandwidth terms as well as its network performance; a nominal port rate alone does not establish reliable sustained throughput. For more on the egress side of the decision, see the VPS bandwidth cost guide.
If you need to transcode, specify the video and audio encoders and the output settings explicitly rather than relying on FFmpeg defaults. A common SDR target is H.264 video with AAC audio, but the frame size, frame rate, bitrate, keyframe interval, colour settings, and audio parameters must still be selected. Benchmark an ordinary part of the sequence and leave CPU capacity for the operating system and any monitoring. A process that is already using all available CPU during quiet footage may fall behind when a scene becomes more demanding.
Send to the Live Control Room ingest URL and key
In YouTube Studio, create or schedule the stream in Live Control Room and copy the stream URL and stream key from its encoder settings. YouTube describes the key as the value that directs an encoder feed and allows YouTube to accept it. Treat it as a credential: do not put it in a public repository, a shared screenshot, or a command saved in shell history that others can read. Store it in a suitably restricted configuration or environment variable.
Prefer the RTMPS URL shown in Live Control Room. YouTube describes RTMPS as RTMP over TLS/SSL and recommends it as the encrypted ingest option. The default URL displayed in setup may be ordinary RTMP, so reveal and copy the RTMPS endpoint rather than assuming an RTMP address can simply be substituted. See YouTube’s guide to streaming with an encoder for the current setup steps.
Before making a public broadcast, confirm that the channel is eligible to stream. YouTube’s live-streaming onboarding guidance says a channel must be verified and must not have had a live-streaming restriction in the preceding 90 days; it also gives a minimum age of 16. Eligibility and account status can change, so check the current live streaming help page in YouTube Studio rather than treating an old checklist as confirmation.
Start with a private or unlisted test where appropriate. Watch the Live Control Room preview and stream health, check that audio is present and correctly selected, and let the file transition occur while you observe it. Then check playback on another device or network. A successful connection only confirms that YouTube is receiving something; it does not confirm that viewers hear the right track, that later joins are clean, or that the VPS will recover if the process or network drops.
For a 24/7 channel, write down the operational routine as well as the FFmpeg command: where the playlist lives, who can retrieve the key, how to check the preview and logs, and how to restart after a failure. A Debian FFmpeg lecture-stream walkthrough may help with the host-side setup, while this page’s file checks still apply to any operating system.
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
Can I mix MP4 and MKV files in one FFmpeg playlist?
Yes, provided the streams meet the concat demuxer’s compatibility requirements, or you normalise them first. The file extensions do not establish that compatibility, so inspect codecs, stream layouts, and timing before building the playlist.
Do I need to convert every MKV file to MP4 first?
No. A container change alone does not make mismatched codecs, dimensions, frame rates, or audio layouts compatible. Convert or transcode only when inspection and testing show that the input needs it.
Is stream copy better than transcoding for a VPS?
Stream copy can use less CPU and avoid another encode when inputs are compatible and already suitable for YouTube. Transcoding gives you control over output settings but uses more CPU and may reduce quality, so test a representative segment and choose based on the source and VPS capacity.
Does the sample command make the channel repeat and recover automatically?
No. It shows the basic shape of a real-time concat input and output feed, but looping and recovery need separate configuration and testing. Verify end-of-playlist behaviour, process supervision, and YouTube’s preview before relying on unattended operation.