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, 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?

  • No wonder sameq gave you visible distortions :) – However, trying to copy the video and audio stream does not make sense with sameq, because the latter only applies to encoding processes. When you're just copying, there's no encoding happening. How much space do you have on your drive? Would converting the video to a lossless format / intra-frame only format make sense? ffmbc seems suitable for this task. – slhck Sep 24 '12 at 21:00
  • @slhck: No, I don't have space for a lossless format or intra-frame only, and I also don't have the for that very slow conversion. Can you recommend an ffmpeg command-line which doesn't distort, but it keeps the original video stream? – pts Sep 24 '12 at 21:25
  • Seems you got it figured out already! I don't have much experience with AVCHD, so I'd probably have just converted it to high quality h.264 instead, with re-encoding, like -c:v libx264 -preset slow -profile:v high -crf 19 or even less for the CRF value. The rest comes down to experimentation I guess. AVCHD is a little pesky, plus all those different tools for reading… – slhck Sep 24 '12 at 21:41
  • @slhck: AVCHD already contains H.264 video, so there is no need to reencode it. – pts Sep 24 '12 at 23:27
  • I know, it's the container that is giving problems, as I said. – slhck Sep 25 '12 at 7:06

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.


This is not matter of software, but hardware. Your video is way too hard to decode, if you want to edit it, its nearly impossible.

What you need is to recode your files into a format which is suitable for editing, then edit it (OpenShot is a good editor and stable enough, there are more) and then you can recode it back to MPEG4/AVC.

Good codec which is open and suitable for editing is DNxHD - note when you recode files into this format, they will be MUCH MUCH bigger. In FullHD its like gigabyte for one minute, or something. There is a workaround that is called proxy editing, google that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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