Sunday, October 21, 2007

DVD authoring

Recently downloaded a video in MKV format. MKV is quite a popular format when distributing video contents. One of the reasons is that MKV is extremely flexible. It can virtually mix any video/audio content in it. But this also posts a challenge when converting it.

First, let's check what is in the MKV file so that we know what to do. mkvtoolnix is a handy tool for that. Use the mkvmerge command to see the file structure:

mkvmerge -i 5Centimeter.mkv


And this is the output for my MKV file:

File '5Centimeter.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)
Track ID 3: subtitles (S_VOBSUB)
Track ID 4: subtitles (S_TEXT/ASS)


Here is the analysis:


  • The first track is the video in MPEG4 format. We will need to convert it to MPEG2 for DVD

  • The second track is the audio in AC3 format. We can just reuse it in the DVD. No conversion required

  • The video is a Japanese anime and track 3 is the subtitle file

  • Someone is nice enough to include a translation of the subtitle in Simplified Chinese format in track 4. But note that it is in text format . So we will need to convert it into image format for the DVD


Initially I thought I could use avi2dvd to do most of the conversion jobs since it supports MKV format and subtitle generation etc. But after several days of struggle, I concluded that it can't handle Chinese subtitle nicely. So instead, I just used it to do the video and audio conversion, format/frame rate changes, pull down etc tedious tasks and generate a "DVD ready" ISO for me, without the subtitles.

avi2dvd is actually an GUI for many freeware programs. There are many options to choose from. BTW, I used the HCenc encoder, which is slow (almost 3 hours to encode the 1 hour video on my 3200+) but is supposed to give good result.



Once we have the ISO file, we need to demux it. This is to get the converted video (and audio) files so that we can multiplex them with the subtitles. I used VobEdit for that.

The subtitle requires lots of work here. First, use mkvmerge to extract the text from track 4 into a file. It is in SRT format with GB encoding. As I couldn't find a freeware tool that can handle SRT directly for DVD authoring, so here is the process on how to convert it into SUP format:

  • Since I prefer to read Traditional Chinese, so I used ConvertZ to convert the content into Big5.

  • Use Subtitle Workshop to convert the SRT file into Substation Alpha (SSA) format




  • Use MaestroSBT to convert the SSA file into SON, with the text rendered as bitmap. Choose the output to be 4-bit compressed bitmap files. Since I am rendering Chinese text with Big5 encoding, I changed the default font setting. Also need to adjust the margin etc. In the Color Rendering section, I chose "Two colors for text, one for outline, no antialias". Note down the color used. We will need this info later.




  • Use son2vobsub to convert the SON file to SUB format

  • Use SubToSup to convert the SUB file into SUP format


... and finally... we have a usable subtitle file... orz...

Next, use IfoEdit for the final mutliplexing. Choose "DVD Author" -> "Author new DVD". Select the video, audio and subtitle files. Set the correct language for the audio and subtitle. Then click OK to generate the DVD files (those VOB, IFO etc files).



Then a little trick. Since the subtitle is generate in specific colors, we need to set it in the IFO file so that it can overlay nicely on the video. In IfoEdit, select the "VTS_PGCITI"->"VTS_PGC_1" node. Then look for the "Color 0 Y Cr CB", "Color 1 Y Cr CB" etc entries. They are the color codes for the subtitle:

Color 0 = Background
Color 1 = Outline
Color 2 = Letters
Color 3 = Anti-alias


Here are the codes for different colors:

White: EB 80 80
Brown: 30 B8 6D
Black: 10 80 80
Green: 50 50 5A
Oliv: 71 89 47
Naval: 1C 76 B8
Púrple: 3D AF A5
Turquese: 5D 47 92
Grey: 7D 80 80
Silver: B4 80 80
Red: 51 EF 5A
Lime: 90 22 35
Yellow: D2 92 10
Blue: 28 6D EF
Fucsia: 6A DD CA
Aqua: A9 10 A5




Change the values to reflect the colors used when we generate the subtitle images using MaestroSBT. Click "Save" to update the IFO. Then click "Disc Image" to generate the final ISO.

Preview the ISO. To get the position right, I needed to re-generate the subtitle file a few times... orz. When everything is OK, use a burning program (e.g. DVD Decryptor) to burn the image to a DVD-R... and we are done!

1 comment:

Unknown said...

Video clips for DVD are finished and now is the time to putt everything together. DVD authoring is the process of creating a DVD video that can be played on a DVD player. CD & DVD Copies