Linux – Cut (smart edit) .mts (AVCHD Progressive) files un Ubuntu Lucid

linuxubuntu-10.04video editing

I have a bunch of .mts files containing AVCHD Progressive video recorded by a Panasonic camera, and I need software on Ubuntu Lucid with which I can remove the boring parts, and concatenate the interesting parts, all this without reencoding the video stream. It's OK for me to cut at keyframe boundary.

If Avidemux was able to open the files, it would take about 60 hours of work for me to cut the files. (At least that was it last time I tried with similar videos, but of a file format supported by Avidemux.) So I need a fast, powerful and stable video editor, because I don't want that 60 hours of work go up to 240 or even 480 hours just because the tool is too slow or unstable or has a terrible UI.

I've tried Avidemux 2.5.5 and 2.5.6, but they crash trying to open such a file, even if I convert the file to .avi first using mencoder -oac copy -ovc copy. mplayer can play the files.

I've tried Avidemux 2.6.0, which can open the file, but it cannot jump to the previous or next keyframe etc. (if I make it jump to the next keyframe, and then to the previous keyframe, it doesn't end up at the original keyframe, sometimes displays an error etc.). Also I'm not sure if Avidemux 2.6.x would let me save the result without reencoding.

I've tried Kdenlive 0.7.7.1, but playback is very choppy, and it cannot play audio at all (complaining that SDL cannot find the device; but many other programs on the system can play audio). It would be a pain to work with.

I've tried converting the .mts file to .mkv using ffmpeg -i input.mts -vcodec copy -sameq -acodec copy -f matroska output.mkv, but that caused too much visible distortions in the video in both mplayer and Avidemux.

I've tried converting the .mts file with TsRemux.exe, but Avidemux 2.5.x still can't open that file.

Is there another program to cut and concatenate the files? Is there a preprocessor which would create a file (without reencoding the video) on which Avidemux wouldn't crash?

Best Answer

Following the comments on http://ubuntuforums.org/showthread.php?t=920606 and adding mencoder I could create an .mkv which Avidemux 2.5.6 can open, cut and save without reencoding.

$ sudo apt-get install mencoder mkvtoolnix
$ mencoder -of rawaudio -ovc copy -oac copy -o raw.aud input.mts
$ mencoder -of rawvideo -ovc copy -oac copy -o raw.vid input.mts
# The 50fps has to be changed below to reflect the true video FPS.
$ mkvmerge -o output.mkv --forced-track 0:no --default-duration 0:50fps -d 0 -A -S -T --no-global-tags --no-chapters raw.vid --forced-track 0:no -a 0 -D -S -T --no-global-tags --no-chapters raw.aud --track-order 0:0,1:0
$ rm -f raw.vid raw.aud

Another option is to create an .avi using ffmpeg without reencoding. I was lucky, because Avidemux 2.5.6 could open the .avi without crashing.

$ sudo apt-get install ffmpeg
$ ffmpeg -y -vcodec copy -acodec copy -f avi -i input.mts output.avi

A two-step solution which didn't work out (because Avidemux segfaulted on opening both tmp.avi and output.mkv):

$ sudo apt-get install mencoder mkvtoolnix
$ mencoder -oac copy -ovc copy -ffourcc AVC1 -o tmp.avi input.mts
$ mkvmerge -i tmp.avi output.mkv
$ rm -f tmp.avi

I'll have to verify with lots of input files that these solutions work end-to-end (including the audio and video kept in sync even in the last file). As soon as I have the result, I'll update my answer. If you have a different answer in the meantime, please don't hesitate to post it.

Related Question