Taktaal19th August 2007, 16:30
This is a little newbie guide I started working on, just displaying how to convert a VC1/DD+ HD-DVD into a standard format mkv without using any all-in-one tools. Maybe it can help you to get going with HD reencoding.
Getting the Software
VirtualDub
VirtualDub download (at SourceForge) - virtualdub.org
Avisynth
http://avisynth.org/mediawiki/Main_Page
FFmpeg with E-AC3
FFmpeg & Mplayer compiles w/ E-AC3 support - Doom9's Forum
GraphEdit
GraphEdit | Software - Digital Digest
Windows Media Player 11
http://www.microsoft.com/windows/win...&qstechnology=
x264.exe
x264 revision 747
EvoDemux
http://pel.hu/down/EVOdemux.exe
Haali Splitter
Haali Media Splitter
MKVToolnix
mkvtoolnix -- Matroska tools for Linux/Unix and Windows
Ripping the HD DVD
This (
HD-DVD (and Blu-Ray) decrypting tools - Doom9's Forum) is a good thread explaining the different options to copy a HD-DVD movie to hard disk and decrypt it.
Demuxing the movie
At this point you should have the whole HD-DVD in a directory on your PC. The most important part is a bunch of .EVO files in a HVDVD_TS subfolder. There will probably be 1-3 Multi-GB files with names like FEATURE_n.EVO (the main movie) and a couple smaller EVOs that include things like the menu and extras.
What we're interested in mostly is the main movie. So start EVODemux, load the FEATURE_1.EVO, and wait until the program has stopped parsing the file. Scroll down and check if the movie length is correct.
http://taktaal.net/gfx/demux1.png
If it isn't you need to go to the Options tab, and set "Continue with second EVO".
Write down how many calculated frames the movie has, we're going to need that number later. In fact it's probably a good idea to copy&paste the whole movie info into a text file for later use.
Do not use the "Read XPL" feature. It's currently bugged in EVODemux and will cause problems later.
Now it's time to see what type of tracks we have in the movie. EVODemux will give you all the info, so just scroll down in the text, and take note of the information there. In this sample case, we have one VC-1 video track, three DD+/E-AC3 5.1 channel audio tracks (number 0 to 2) and one DD/AC3 stereo track with the number 3.
Usually, the commentary track is the lowest quality and has the highest number so this is clearly track 3. Track 0 is probably the english one as it usually comes first on US or UK releases, and 1/2 are the french/spanish ones.
http://taktaal.net/gfx/demux2.png
After that, go to the Video/Audio tab, and check all checkboxes that you want in the final movie. Press "Rebuild"
http://taktaal.net/gfx/demux3.png
After this, you should have in your output directory a 10-20 GB big .EVO file containing the complete movie and all wanted audio tracks in one continuous file. It's a good idea to rename it to a better name too.
http://taktaal.net/gfx/demux4.png
Converting the audio
Some of the tracks might already be in the AC3 format. We don't need to convert those as they are already compatible with all standard movie players.
For those, just check them in the Video/Audio tab of Evodemux, and press "Demux".
http://taktaal.net/gfx/audio1.png
The E-AC3 tracks have to be reencoded to a more sensible audio format in order to be compatible with a wide choice of players. AC3 is a good choice of course to convert to.
The program we're going to use here is the new version of FFMPEG with E-AC3 support.
To convert the default audio track, use the command
ffmpeg -i input.evo -vn -acodec ac3 -ab 448k output.ac3
FFMPEG unfortunately tends to number the audio tracks in a different way than Evodemux, so take note from the output that follows this command to see what the tracks are numbered like.
http://taktaal.net/gfx/audio2.png
Here, we see that the commentary is actually the track 0:1, spanish and french are 0:2 and 0:3 (sometimes the secondary audio tracks are stored at a lower bitrate) and english is 0:4.
So we modify our ffmpeg command to use the -map option to select the correct audio track, and export each track with their own command
ffmpeg -i serenity.evo -map 0:4 -vn -acodec ac3 -ab 448k serenity.en.ac3
ffmpeg -i serenity.evo -map 0:2 -vn -acodec ac3 -ab 448k serenity.fr.ac3
ffmpeg -i serenity.evo -map 0:3 -vn -acodec ac3 -ab 448k serenity.es.ac3
When converting E-AC3 tracks you'll probably get a lot of warnings because ffmpeg support for the format is still in beta.
Converting the video
Once you have installed all the necessary filters and software, converting a HD-DVD movie isn't any different than doing the GraphEdit -> Avisynth -> VirtualDub path with regular DVDs.
First, we have to build a GraphEdit graph. Open the software, but don't drag&drop the EVO into it. That will open it with the default filter which will probably be Sonic Cineplayer and that's bugged and will lead to desynchronized audio.
Instead, choose "Graph" -> "Insert Filters...", then choose "DirectShow Filters" -> "Haali Media Splitter" and insert that. You'll get a popup asking you for a file to split, select the .EVO that you rebuilt earlier
http://taktaal.net/gfx/video1.png
Next, insert the "WMVideo Decoder DMO" Filter, and connect the EVO file with the decoder
http://taktaal.net/gfx/video2.png
If you get an error here, you forgot upgrading WMP to version 11.
Save the graph.
Next, create an AviSynth script to load the graph. A very basic sample:
DirectShowSource("serenity.grf", fps=23.976, framecount=171229, audio=false)
What's important here is that you have to manually set the movie to the correct framerate (always 23.976 for HD-DVDs) and set the correct framecount according to the number EVODemux calculated for you earlier. If you don't set those two options you'll get a bugged encode.
Also you can add dozens of other AviSynth options here like cropping away black bars, make sure the movie dimensions are dividable by 16, filtering away movie grain, scaling for mobile devices etc. Those options are out of scope for this guide and you should refer to the AviSynth Wiki (
http://avisynth.org/mediawiki/Main_Page) for them.
Save the Avisynth script.
Right here, you can basically use any software you want that supports .AVS sources. We're going to use the x264 command line encoding tool, alternatively you could also use VirtualDub for Xvid or the WMVideo encoder for making a WMV.
x264 --bitrate 8000 --progress --threads auto -b 3 --b-bias 5 --b-pyramid --weightb --b-rdo --bime -8 -t 1 -o NUL serenity.avs
x264 --bitrate 8000 --progress --threads auto -b 3 --b-bias 5 --b-pyramid --weightb --b-rdo --bime -8 -t 1 -o serenity.mkv serenity.avs
Those two lines make a decent two pass x264 encode in just a few hours. You have to obviously adjust the input/output files, and can do the same with the bitrate as well as any other option if you want. Save this as a .bat file and run it by double clicking.
If you want higher image quality, the following is a slower but better quality set of options
x264 --pass 1 --bitrate 8000 --bframes 3 --b-pyramid --direct auto --deblock -3:-3 --subme 1 --analyse none --me dia --threads auto --thread-input --progress --no-psnr --no-ssim -o NUL serenity.avs
x264 --pass 2 --bitrate 8000 --ref 5 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --direct auto --deblock -3:-3 --subme 7 --analyse all -8 --trellis 1 --me umh --threads auto --thread-input --progress --no-psnr --no-ssim -o serenity.mkv serenity.avs
Reencoding the video with these settings will probably take around a full day on an average dual core computer.
Of course, a whole book could be written on the pro- and contra of various x264 settings, try looking in the MPEG 4 AVC forum (
MPEG-4 AVC - Doom9's Forum) for more discussion about it.
If you want to try out the encode, you can add a
Trim(0, 3000)
line to the .avs script to just encode the first 3000 frames (2 minutes) of the movie. This makes it possible to fiddle with the quality settings without spending hours on each encode.
Remuxing everything again
Load the recompressed mkv movie and the ac3 audio(s) into MKVmerge.
Set an output filename, and press "Start muxing".
Dealing with audio sync issues
There's mainly two ways to deal with audio sync problems.
First find out what kind of offset you have. Try to measure by how much the audio is out of sync at the start, and how much at the end. Try looking for things that have both clearly visible and audible parts. Gunshots are good, slamming doors, scene changes from a noisy to a quiet place, etc.
If the audio offset is the same at the start as at the end, it's probably the fault of a strange EVO that's not fully supported by the programs we're using. You can however fix that by repairing it while muxing the final mkv. If you select your audio track in mkvmerge, you can set a delay to that track.
http://taktaal.net/gfx/sync1.png
If the audio happens before the video, use positive numbers, otherwise negative. Try to measure it exactly because a human can notice a 1 frame desync, perhaps not consciously, but it will make the movie feel strange in a way.
If the movie starts out synchronized, but gets desynced over time, two things could have happened. Either you forgot the fps=23.976 setting in AviSynth, in which case you can add a 1001/1000 value in the "Stretch by" field in mkvmerge to fix it.
Or you used Sonic Cineplayer as decoder, in which case you're screwed and you need to reencode the movie again. At least I've never found a way to reliable fix such an audio track because it seems to speed up and slow down at random points.
Subtitles
To come
Chapters
To come