Codec Hell: Change video container without encoding

By jayvol09 on Friday 2 November 2012 13:10
Category: -, Views: 3.713

Keywords: video compression transcoding converter container remux encode decode codec h264 MP4 AVI MKV M2TS

In this example I want to remux an MTS file into either MP4 or MKV for compatibility with certain software. Also the difference in approach between using MTS and M2TS is small if not negligible.
Incidentally a friend of mine mentioned his Samsung tv accepted MP4 but no MKVs on a USB-stick. I can imagine several situations where remuxing is all that is needed to fix a problem, while MANY people *unintentionally* resort to re-encoding the entire video - with the additional quality loss that brings.
So how hard is it to just remux a video?

A bit of video info:
All I know about video is self-taught using the web, one of the first things I learned was the difference between compression algorithm and container. Containers just glue audio, subs etc. into one file. Containers may not support certain types of compressed media; what I think that means is there is no field in the format for entering vital information needed to decode the content. Mkv is known for being flexible, the fact that it is not attached to commercial interests is probably related.
Regarding H.264 (AVC) compressed video: mp4, flv and mov are common containers on the web. Mts / m2ts are seen in personal video recordings and blu-ray related stuff.
Now a remux is just a change of container, and may entail discarding undesired or incompatible files such as audiotracks. The content that is kept is left untouched.
When people say 'that video has codec X' what they are referring to is the compression algorithm. The term codec is used incorrectly so often it has also become a synonym for the software that uses the algorithm.
To illustrate, both Xvid and Divx compressor codecs use Mpeg-4 part 2 (a.k.a. ASP) standard when encoding video, the result must be decoded in a standardized way. Hence there is more competition in the encoder software of a codec than in the decoder part.
Transcoding or re-encoding involves decoding a mediastream and then encoding it again, typically lowering the quality.

So google is my friend, right?
Most google hits for software will give a converter that re-encodes video from some dubious company with 200 similar products. Some big names in the transcoding world (windows): Handbrake, Virtualdub, avidemux, quicktime pro, Megui, MPEGStreamclip, Mediacoder, TEncoder, XMedia Recode. Some also offer editing functionality in varying degrees of elaborateness.
Mencoder and FFMpeg are popular commandline tools, often the basis of the aforementioned GUIs. Another commandline tool is MP4box, of which Yamb is a well-known GUI.
Then the well known VLC has some less-well-known converter features. So with all these choices, surely one would be smart enough to take my MTS and spit out an MKV or MP4 without encoding anything? ...Actually this was doable :).

Yamb takes a lot of formats, but not MTS. Fortunately I found TSMuxerGUI that let me demux my videostream from MTS to a .h264 file. Yamb does take .h264, so solved for mp4.
MKVmerge is a part of the mkvtoolnix package, the gui is straightforward and it accepts many formats, including MTS. I'm guessing using mkvextract on an mkv would also give a .264 file, so it may be a way around TSMuxer, if TSMuxer doesn't install or someting. Anyway, mkv solved. But for good measure, there are more ways.

Avidemux, rocks, period. Just click output:mp4 or mkv and save video. Yet I couldnt find an option to discard audio so I ended up converting to AAC for the mp4 container.
Virtualdub, used to be my 'avi joining' program of choice, but for anything h.264 you need avisynth or possibly vdubmod, so ill keep this on the shelf for those older formats until the day I decide to get into avisynth comes.
I don't like Apple so I didn't bother with Quicktime pro.
VLC can't do mkv, but mp4 and mov were available. Shame I only got a still image .mp4 from the converter in VLC 1.1.11.
More misfortune as Handbrake only wants to encode stuff before muxing. I heard it used to handle (xvid) avi but now it seems geared to encoding to h.264 formats; I'm keeping it installed anyway, probably need it in the future and it looks professional enough.
As for the other programs mentioned, it's like carrying coal to Newcastle. In other words, too many cooks spoil the broth. Or more precisely: I can't be arsed.

Xmedia recode was also a very nice experience, similar in ease to avidemux. TEncoder didn't take MTS but otherwise does do smart remuxing. MPEGstreamclip has an Appley feel to it, don't think it will just remux as I only saw encoding options. Mediacoder is an overkill GUI for various commandline tools mentioned: tsmuxer, mp4box, ffmpeg- so can't go wrong with it either.

My next challenge: turning my holiday photos into a movie.
Issues: I want lots of cool transitions, and theres several thousand photos. Oh and music.

Volgende: Photos to slideshow: options and software 11-'12 Photos to slideshow: options and software
Volgende: Automatic sampling of video files: easier said than done! 11-'12 Automatic sampling of video files: easier said than done!


Comments are closed