views:

233

answers:

1

I have two MTS video files, each one 2 minutes long. I need to be able to join the files together and convert the format to MPEG4. I have a suitable command line for converting MTS to MP4 but don't know how to join the files together in the first place.

Some articles on the web suggest using the CAT command, like:

cat video1.mts video2.mts > whole_video.mts

However this doesn't work and according to FFMPEG, "whole_video.mts" is only 2 minutes long, not 4 minutes.

Does anyone know how to join the files together? Is FFMPEG the best program to use to do this? Thanks in advance.

+2  A: 

It's OK, I've sorted it. Using the latest SVN versions of FFMPEG, x264 and MP4Box (GPAC), here's what I did...

Use FFMPEG to convert the MTS files to MP4 as normal:

ffmpeg -i video1.mts -vcodec libx264 -deinterlace -crf 25 -vpre hq -f mp4 -s hd480 -ab 128k -threads 0 -y 1.mp4
ffmpeg -i video2.mts -vcodec libx264 -deinterlace -crf 25 -vpre hq -f mp4 -s hd480 -ab 128k -threads 0 -y 2.mp4

Use MP4Box to join the MP4 files together:

MP4Box -cat 1.mp4 -cat 2.mp4 output.mp4

This joins the files together into "output.mp4", however when I use "ffmpeg -i output.mp4" it says the duration is longer that it should be. To fix this, I had to use FFMPEG again:

ffmpeg -i output.mp4 -vcodec copy -y final.mp4

And voila! Querying the "final.mp4" file using FFMPEG shows the correct duration and the video plays fine.

Hope this helps anyone else experiencing the same problem.

Reado