Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Downloading a video stream with curl, I ended up with ~400 *.ts files, each about 1MB in size. They are sequentially numbered video1.ts, video2.ts, ...video400.ts. I now need to concatenate them into one file, obviously in the right order (so video10.ts should be followed by video11.ts and not video110.ts).

I've tried to come up with something like "for i in *.ts; do ...." but I just can't figure it out. Also ffmepg and avconv are too complicated for me.

Who knows how to join these 400 files in the right oreder, into a new file? Thx!

share|improve this question

What sort of does the trick:

for i in `seq 1 400`; do cat "video$i.ts" >> newvideo.ts; done

but now the audio is out of sync by ~0.5s and there are ~0.5s silences every few seconds (presumably when fragments are glued together).

share|improve this answer

This is an old question but I hope the answer may add value for others.

Based on this reference, the following script will do the job, assuming ffmpeg 1.1 and later.


for i in `seq 0 $totalNumberOfTsFiles`; do echo  file "'${i}.ts'" >> Input.txt ; done
/home/hq6/bin/ffmpeg-2.3.3/ffmpeg -f concat -i Input.txt  -c copy output.ts
share|improve this answer
The entire for loop can probably be replaced by something like seq -f '%g.ts' 0 $totalNumberOfTsFiles for a similar result with a much cleaner command line. – Michael Kjörling Aug 28 '15 at 19:12

Try the following command:

cat video?.ts video??.ts video???.ts  > out.ts
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.