Concatenate TS Files with FFmpeg Copy Protocol
This article provides a quick, step-by-step guide on how to merge
multiple MPEG Transport Stream (.ts) video files into a single file
using FFmpeg. By utilizing the command-line concat protocol
alongside the stream copy function, you can join these files instantly
without re-encoding, preserving the original video and audio
quality.
To concatenate TS files using the FFmpeg command-line protocol, use the following command structure:
ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.tsHow the Command Works
-i "concat:input1.ts|input2.ts|input3.ts": This instruction tells FFmpeg to invoke theconcatprotocol. The input files are grouped inside quotation marks and separated by a pipe (|) character, prompting FFmpeg to read them sequentially as one continuous stream.-c copy: This flag instructs FFmpeg to stream-copy the video, audio, and data tracks directly without re-encoding them. This ensures the merging process completes in seconds and results in zero quality degradation.output.ts: This is the designated filename for your final, combined video file.
Important Considerations
- File Compatibility: The
concatprotocol works seamlessly with TS files because the MPEG Transport Stream container format is designed for easy splicing. However, for the output file to play correctly across all media players, all source files must share identical codecs, resolution, aspect ratio, and frame rate. - Handling Spaces in Filenames: If your filenames contain spaces, you should rename the files to remove the spaces or escape them properly to prevent command-line syntax errors.