3

I've created some time-lapse videos from photos, using this command:

ffmpeg -i IMG_%03d.JPG -s 1440x1080 -sameq video.MP4

And it worked great. Now I want to join several of these time-lapse videos to make a single, longer video (all the input videos have the exactly same format). I already tried using:

cat video1.MP4 video2.MP4 > stitch.MP4

but the output ends up being equal to video1.MP4

I don't want to transcode nor changing any parameter of the video, I just want a end-to-end stitching, as if those videos were on a playlist.

Thanks!

3 Answers 3

3

With a recent version of ffmpeg, you can use the concat demuxer. Create a file called inputs.txt containing lines like:

file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
file 'input4.mp4'

With a bash shell, you can use a for loop to create the file like so:

rm inputs.txt
for f in input{1..4}.mp4; do echo "file '$f'" >> inputs.txt; done

Then,

ffmpeg -f concat -i inputs.txt -c copy output.mp4

Since it uses -c copy, this will be completely lossless.

1

The output won't be equal to video1.mp4, but the headers/footers for the video will start and end around video1.mp4, so your player won't go into video2.mp4. Assuming the videos are the same bitrate/codec etc:

cat video1.MP4 video2.MP4 | ffmpeg -y -i - -genpts -vcodec copy -acodec copy stitch.MP4

Bear in mind that this is not necessarily the best method (would be better to make all of the time lapses at the same time in one video) as if the codec is lossy you will induce generation loss.

1
  • It doesn't work. It says it "couldn't detect codec parameters"
    – tomm89
    Feb 4, 2011 at 2:00
1

I know you said with ffmpeg but I've had good luck using mp4box for just simple stitching together of files. You can download it here.

http://gpac.wp.mines-telecom.fr/mp4box/

Here is the command line example:

mp4box -cat <file> -cat <file> dest.mp4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .