How to Concatenate TS Files on macOS with FFmpeg
This guide explains how to quickly merge and concatenate multiple TS
(MPEG Transport Stream) video files on macOS using FFmpeg. By utilizing
the stream copy feature (-c copy), you can join your video
clips instantly without re-encoding, which preserves the original video
and audio quality and saves significant processing time.
Prerequisite: Install FFmpeg on macOS
Before starting, ensure you have FFmpeg installed. The easiest way to install it on macOS is via Homebrew. Open your Terminal application and run:
brew install ffmpegMethod 1: Using the FFmpeg Concat Protocol (Best for a Few Files)
Because TS is a container format designed for streaming, you can
easily feed multiple files directly into FFmpeg using the
concat protocol. This is the fastest method if you only
have a few files to merge.
Open Terminal and navigate to the folder containing your TS files using the
cdcommand:cd /path/to/your/folderRun the following command, separating each file name with a pipe symbol (
|):ffmpeg -i "concat:file1.ts|file2.ts|file3.ts" -c copy output.ts
-i "concat:file1.ts|file2.ts|...": Tells FFmpeg to read the listed input files sequentially.-c copy: Instructs FFmpeg to copy the video and audio streams directly without re-encoding them.output.ts: The final concatenated file.
Method 2: Using the FFmpeg Concat Demuxer (Best for Many Files)
If you have a large number of TS files, typing them out manually becomes impractical. The concat demuxer reads a text list of your files and merges them in order.
Open Terminal and navigate to your TS files’ directory:
cd /path/to/your/folderGenerate a text file containing the paths of all
.tsfiles in alphabetical order by running this command:printf "file '%s'\n" *.ts > filelist.txtThis creates a file named
filelist.txtformatted like this:file 'file1.ts' file 'file2.ts' file 'file3.ts'Run the FFmpeg command to concatenate the files listed in the text file:
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.ts
-f concat: Specifies the concat demuxer format.-safe 0: Allows the use of relative and absolute file paths in the text list.-i filelist.txt: Sets the input as the text list you generated.-c copy: Stream-copies the contents, joining the files instantly.
Once the process finishes, you will find your merged
output.ts file in the same directory.