View Single Post
Old 15th January 2007, 09:34   #31  |  Link
Isochroma
Registered User
 
Join Date: Mar 2005
Posts: 468
Tutorial: Perfect AVC EVOB to MKV Remuxing

Note: If you have a VC-1 EVOB, see my Tutorial: Perfect VC-1 EVOB to .AVS Conversion for a frame-accurate method to demux, decode and serve VC-1 EVOBs into Avisynth.
All of you will be very pleased to know that I have in my posession a MKV file with both the original video stream of an .EVO (EVOB) in native AVC1 and audio in AC3. The avc plays with CoreAVC, and the audio with ffdshow.

There are no problems, seeking works absolutely perfectly, everything is a-ok with the streams. Oh, and playback uses at least 30-40% less CPU than playing the .EVO directly!

I will guide all those interested in replicating this achievement.

0. First, we need some software:
1. Graphedit

2. Elecard MPEG-2 Decoder and Streaming Pack

3. DVBPortal HDTV Reference Dump Filter

4. Yamb 1.6.0

5. MKVToolnix 2.0.0
(Important! You must update your MKVToolnix installation by copying the new files from the latest update package into your MKVToolnix folders, or the output fps will be wrong due to a bug in the 2.0.0 release)
1. We start by demultiplexing the AVC video stream to an elementary .264 file:


To the left, we see the property sheet for the Elecard MPEG Demultiplexer which, while not capable of reading the audio stream, can see the video stream. Connected to its output pin we find the secret sauce for my processes: the magic DVBPortal HDTV Dump filter. Make sure you name the file with a .264 extension.

2. Now we want to get that .264 Elementary Stream into a nice MKV. So the first thing one might do, is test the newly minted MKVToolnix Matroska Muxer 2.0.0, which is freshly imbued with AVC-ES support.

Alas, it works but the resultant MKV file is partially broken, and plays with all kinds of weird artifacts. So we are left with the tried and true Yamb, which does not disappoint!


First and most importantly, we have to make sure to check the Enable Import Settings box, because the AVC-ES doesn't have a framerate. You'll have to have some idea what it is, because in the next step we'll enter it. A good place to start is always 23.976.


In the above picture, in the Mux tab the Add button has been clicked, and the saved .264 file opened from a generic Open dialog window. After that happens, you are presented with the MP4Box Import Settings window, where you must enter a number in the Force FrameRate box; pictured here a value of 23.976 has been entered.

Press Ok on that button, then in the main window set a path/filename.mp4 in the Ouput line (last field). Then click Mux. An .mp4 file should appear in the location specified.

3. Next we grab the audio stream, using the Sonic demuxer this time:


Again, we use the magic DVBPortal HDTV Dump Filter to write the .ac3 file. Remember, this is something a bit more than normal AC3, it is really Dolby Digital Plus. Strangely, this is the only way to make ffdshow or Gabest's internal (MPC) filter work perfectly. Believe me, I tried every other way - even the Sonic audio decoder wouldn't work with other methods.

Notice the little yellow clock inside the DVBPortal filter box. The Sonic HD Demuxer doesn't set timestamps on the frames it delivers, so you can't yet properly use it to demux video. Presumeably, it won't do this for audio either; smart sabotage or corner-cutting minimalist programming? I'll let you be the judge. Yet, the DVBPortal filter somehow manages to do without; perhaps it is adding the missing timestamps? Those in the know may reply to enlighten me on the topic.

4. Mux.


Congratulations, you're done! Now pop some popcorn and watch the flick...

This method was easy because there's lots of support for de/remultiplexing AVC streams in free and paid software.

However, VC-1 remains the gaping hole in this process; the example trailer used here is atypical. MPEG-2 should be pretty easy, at least.

To finish, some links to the development processes which are most likely to yield a VC-1 bridge:
How to demux VC1 elementary stream from WMV file?
Mux VC1 on WMV
Muxing VC-1 in ASF
Muxing and demuxing vc-1
The first idea is to use the DVBDF to get a VC-1 ES, then using the nascent tool(s), mux to wmv. Then once we have WMV, either Gabest's or Haali's MKV DS muxers will put it into MKV. Now is the time to visit the threads below and help/encourage the developers to move in this direction; also, I will suggest to the developer of MKVToolnix to add VC-1 support.

The benefits of MKV encapsulation are significant: greater compatibility, smaller size, far better performance, easy manipulation, etc. Matroska is ultimately the Main St. of containers, so if we can get those juicy streams out of their cliquey container and into the common man's space, then many more possibilities will open up.

PS. Please PM me if you need more detailed instructions/help with the software used in this guide.

Last edited by Isochroma; 20th January 2007 at 11:09.
Isochroma is offline   Reply With Quote