To combine videos in a directory into one uploadable file, write an FFmpeg concat-demuxer playlist with one entry per clip, in the order you want them played. Use stream copy only when the clips have compatible streams; otherwise, make their properties consistent and re-encode.
A directory is a place to find files, not a ready-made playlist. Check the sequence and the streams before joining, then inspect the finished file before uploading it to YouTube. This workflow creates a video file for upload; it does not create a YouTube livestream.
Choose and verify the file order
Start by deciding what the viewer should see first, second and last. Do not rely on the order shown by a file manager or returned by a directory listing: ordering can vary by tool and operating system, and alphabetical order may not match the intended sequence.
A practical approach is to give clips filenames with zero-padded numbers and a short description, such as 01_intro.mp4, 02_prayer.mp4 and 03_closing.mp4. The padding matters when you have more than nine clips: names such as 1.mp4, 10.mp4 and 2.mp4 can sort differently from the sequence you mean. Renaming is not essential, though. You can leave the source names alone and put them into the playlist explicitly.
Before running FFmpeg, read your proposed list from top to bottom. Check for missing clips, duplicates, an accidental introduction at the end, or a closing section placed in the middle. For a devotional channel, for example, you might want a short opening, then a set of bhajans, then a closing notice. A playlist file makes that editorial choice visible rather than leaving it to an implicit sort rule.
If the video is a long programme, consider whether a single combined upload is actually useful. YouTube can take time to process higher-quality versions of a long upload; its help on video processing explains why available quality options may not appear immediately. For a larger file, keep a local copy until upload and processing are complete. The guide to troubleshooting a long playlist file stuck in upload processing covers the separate upload stage.
Check stream compatibility before joining
The concat demuxer joins packets from successive inputs. It does not convert one clip's video or audio into the format used by another. FFmpeg's concat demuxer documentation states that “All files must have the same streams (same codecs, same time base, etc.).” That requirement is the key decision point for choosing a command.
Check each input's streams and properties before you try stream copy. FFprobe, distributed with FFmpeg, can show this information. For an individual file, run:
ffprobe -hide_banner -i 01_intro.mp4
Look for the video codec, dimensions, frame rate and time base, and for the audio codec, sample rate, channel count and time base. Also note whether a clip has audio at all. Two MP4 files are not necessarily compatible merely because both have the same filename extension or play on your computer.
For a quick side-by-side record, inspect every file and note its properties in a small table or text file. A mismatch in resolution, codec, frame rate, audio layout or stream count is a reason to investigate, not a guarantee that a particular command will fail in the same way every time. The demuxer expects matching stream structures and parameters; stream copy does not repair differences.
Duration metadata deserves attention as well. The concat demuxer uses input durations when adjusting timestamps. FFmpeg warns that inaccurate duration information can cause artifacts. If a source has an odd duration, a damaged index or an unexpected gap at the end, inspect its actual playback rather than assuming the displayed duration is precise.
The practical choice is between preserving already compatible packets and building a consistent new encode. If the files match and you want to avoid another lossy encoding pass, test stream copy. If they do not match, prepare them consistently first or use a filter-based workflow that re-encodes the combined result. For a live channel made from recorded footage, this is also separate from the live-broadcast setup; a 24/7 YouTube loop of recorded school performances involves keeping a broadcast running after you have prepared the media.
Create the concat-demuxer list file
Create a plain-text file named playlist.txt in the working directory. Add one file directive for each clip, in the exact sequence you checked. For portable filenames without spaces or quote characters, it can look like this:
file '01_intro.mp4'
file '02_prayer.mp4'
file '03_closing.mp4'
The list is a script for FFmpeg: each directive identifies an input, and the order of directives determines the playback order. It is not a command to join every file in the directory. That explicitness is useful when a folder also contains thumbnails, old edits, music beds or a previous output that must not be included.
You may also use the extended form, which begins with a version line:
ffconcat version 1.0
file 'clip_001.mp4'
file 'clip_002.mp4'
file 'clip_003.mp4'
Use a text editor that saves plain text, not a word processor that adds formatting. Keep the list and media together while you test, or use paths that you understand and have checked. The -safe option controls which paths the demuxer accepts. A list of simple relative names can be used with the safe-path default, -safe 1. The examples here use -safe 0 to allow paths that the default may reject; that relaxes a check, so only run it with a playlist you created and trust.
Paths with spaces or special characters need careful quoting and escaping according to FFmpeg's concat syntax. If you are not comfortable doing that, use simple filenames in a working folder rather than guessing at nested paths. Do not copy an unknown playlist from an untrusted source and run it with relaxed path checks: it may point to files outside the directory you intended to process.
Before encoding, compare the list against the files on disk. The playlist should include only the intended clips, once each, and every referenced path should exist. This check catches common mistakes more cheaply than waiting for a long encode or discovering a missing section after upload.
Join compatible files with stream copy
When the input streams match, run FFmpeg from the folder containing playlist.txt and the source clips:
ffmpeg -f concat -safe 0 -i playlist.txt -c copy combined.mp4
Here -f concat selects the concat demuxer, -i playlist.txt supplies its ordered list, and -c copy copies the encoded streams rather than decoding and encoding them again. The output container is named combined.mp4, but giving a file an MP4 extension does not make incompatible streams compatible. Use this route only after the checks above.
Stream copy is useful when preserving the encoded source and avoiding an additional quality change matters. It also avoids the work of a new encode, but it offers no chance to resize, change frame rate, alter audio channels or fix a codec mismatch. If the files do not meet the demuxer's requirements, changing the output name or adding -c copy will not normalise them. Choose preprocessing or a filter and re-encode instead.
You can use -safe 1 with simple relative paths when you want the safe-path rules applied; that is the default. The example's -safe 0 is not a general recommendation for arbitrary playlists. Keep it only when needed for paths you control, and inspect the playlist before execution.
Do not confuse this command with FFmpeg's file-level concat protocol. The protocol is limited to formats that support concatenation at the file level; it is not the general method for combining assorted videos from a directory. For a directory playlist, the concat demuxer is the relevant mechanism, with its matching-stream requirement.
If FFmpeg reports an error, or the result contains a pause, black frame or audio discontinuity, do not assume the next attempt only needs a different filename. Recheck the input properties, stream count and durations. The FFmpeg FAQ on concatenation distinguishes the demuxer approach from filter-based concatenation when re-encoding is needed.
Normalise or re-encode mismatched inputs
When the clips differ, first decide what they should have in common: output dimensions, frame rate, video pixel format, audio sample rate and channel layout. Make those decisions based on the material and intended upload rather than forcing every source blindly into a preset. Keep the original files so you can return to them if the normalised versions need adjustment.
There are two broad workflows. You can preprocess each clip into matching intermediate files, then put those files in a concat-demuxer list and stream-copy them into a final container. Or you can use FFmpeg's concat filter to join the inputs within a filter graph and encode the result. In either case, filters or re-encoding are needed to change stream properties; filtered output cannot be copied with -c copy.
The concat filter is more adaptable when clips need to be made consistent, but its graph has to account for each input's streams and properties. Inputs must be mapped and brought to compatible properties in the graph. If one clip has no audio and another has stereo audio, for example, you need to decide whether the combined video should have silence for the first segment or whether audio should be handled another way. A command assembled for a different set of clips may not make that decision correctly for yours.
If all sources are already aligned in resolution, frame rate and audio layout, an illustrative upload-oriented encode can look like this:
ffmpeg -f concat -safe 0 -i playlist.txt \\
-c:v libx264 -pix_fmt yuv420p -crf 18 -preset medium \\
-c:a aac -b:a 192k -movflags +faststart combined.mp4
This is an example, not a universal preset. The CRF value is a quality-oriented encoding choice, not a promise of a particular bitrate or file size. The command does not itself reconcile different resolutions, frame rates, channel layouts or time bases. A mixed set may need explicit preprocessing or a filter graph before the output can be expected to have consistent properties.
Re-encoding takes additional computation and may change quality and file size. It can be the right trade-off when you need one coherent output format, but there is no single setting that improves every source. For example, making low-resolution footage larger does not restore detail. Preview a short test if you are uncertain about scaling, cropping, frame-rate conversion or audio treatment, then use the settings that preserve the material appropriately.
If these clips are intended as a source for an always-on channel rather than a single upload, preparing a combined file and maintaining a live broadcast are separate jobs. The article on streaming videos to YouTube continuously from a cloud dashboard discusses that broadcast distinction. For this page, the goal remains one verified uploadable video file.
Prepare a practical YouTube upload format
For a typical upload, MP4 with H.264 video and AAC-LC audio is a practical target. YouTube's recommended upload encoding settings also recommend progressive scan, 48 kHz audio and matching the frame rate used during recording. For SDR video, the guidance recommends BT.709. These are platform recommendations, not a promise that any particular file will be accepted or that every source should be converted to the same settings.
Preserve the native frame rate and aspect ratio where possible. YouTube's supported video formats guidance explains supported formats and recommends using native frame rates and aspect ratios. Do not stretch portrait or square footage to fill a 16:9 frame. The player can adapt to the uploaded shape; padding or cropping is an editorial decision, not a requirement to distort the source.
YouTube lists reference SDR bitrates by resolution and frame-rate category. For example, its guidance gives 8 Mbps for 1080p at standard frame rates and 12 Mbps at high frame rates; for 720p it gives 5 Mbps and 7.5 Mbps respectively. Treat those as YouTube recommendations, not mandatory minimums or a guarantee of appearance. Your source quality and chosen encoder settings still matter.
For an upload, also consider whether the video has the correct colour characteristics and audio level. If a source is HDR and another is SDR, do not assume that putting them in one MP4 resolves the difference. Decide whether to preserve HDR or create a consistent SDR version, and use an appropriate conversion workflow. Similarly, listen to transitions where music or speech changes; a technically valid file can still have an abrupt level jump.
A long upload may take time to finish processing at all available qualities. Plan to upload early enough to check playback, rather than setting a public release based on the assumption that every rendition appears at once. This is particularly useful for a scheduled devotional programme or news compilation, where the final sequence and audio need to be checked before viewers arrive.
Verify the output file
Do not treat a successful FFmpeg exit as the only check. Play the output from the beginning, then inspect every join. Listen for a cut-off word, a moment of silence, an audio change in level or a sync shift. Watch for a black frame, frozen picture or sudden change in framing. These checks are practical quality control; they do not establish that YouTube will approve a particular upload.
Use FFprobe to confirm the output's duration, dimensions, frame rate, codecs and audio properties. For example:
ffprobe -hide_banner -i combined.mp4
Compare the result with your intended upload format and the properties of the source. If the output duration is unexpectedly short or long, revisit the playlist and input duration metadata. If the output lacks audio or has an unexpected channel layout, check whether the sources had different audio streams and whether your chosen workflow accounted for them.
For a very long file, test playback near the start, middle and end as well as around each join. Confirm that the beginning and ending are not clipped and that any title card or closing notice lasts as long as intended. Keep the playlist file with your notes, so you can reproduce the sequence or locate a problematic source later.
Finally, upload privately or unlisted if you need to check how the file appears in YouTube before publishing it. Review the available playback quality after processing, and check the current official upload guidance if you have unusual frame rates, HDR or other specialised source material. If you are choosing music for a channel, review the separate advice on choosing music for a live stream; combining files does not settle the rights or permissions questions for their content.
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 combine videos in a folder into one video with FFmpeg?
Write a concat-demuxer text file with one file entry for each video, in the sequence you want. Run FFmpeg with -f concat and the playlist as input; use -c copy only after confirming the streams are compatible.
Can I use a wildcard to make an FFmpeg playlist from files in a directory?
A wildcard or shell-generated list may not reflect your intended order, and shell behaviour varies. An explicit playlist is easier to inspect and reproduce, especially when the folder contains files that should not be included.
Why does concat stream copy fail on some clips?
The concat demuxer requires matching streams, including compatible codecs and time bases. Different resolutions, audio layouts or other properties may also require normalisation; use preprocessing or a concat-filter workflow with re-encoding rather than expecting stream copy to fix them.
Does this make a YouTube livestream?
No. It creates a combined video file for upload. A livestream is a separate broadcast process, and this playlist workflow does not start or maintain one.