Sunday, April 20, 2008

DVD Encoding with Mplayer2

I recently having some problem playing the recorded TV program from my Snazio Video Capture card. The card can record to MPEG1, MPEG2 stream, and also VCD and DVD format, even the DivX format is supported. However, the generated DVD stream is not compliant with DVD format and need to be reencoded! Recorded DivX file also have problem in picture/sound synchronization.

I usually do the record using DVD format and write the raw .mpeg file to playback on my Philips DVP-3040K. It works fine unless the file size is less than 2GB, which is the limit of ISO format file size. However, some TV program in Thailand is 2 hours+ length, which usually yield about 4GB file size.

One way to fix this is to stop recording in the middle :). But that requires me to sit and wait for commercial ads to press stop. So I need some solution to quickly fix the stream and put it into DVD-Video.

I tried Cuttermaran + BatchDemux + DVDAuthorGUI and it works quite well for me. Except that the generated DVD Video can play but not seek on my DVP-3040K! (Somehow it can seek on other DVD player.......). So I need to find some other solution.

If I need to do encoding, DivX encode would be great. I had done XVID encoding and it works very well in term of quality and file size. However, the quality of generated file, when played on my DVP-3040K, will be a little bit worse than DVD-Video file, which is not too bad. The worst thing is that the player stop playing the video after about 1:30 hour of playing. I can't seek to the point after that too. I wonder why this is happening but seems DVP-3040K has some trouble with large DivX file...... (it has problem with DVD image too, can't see any file after 700th file on my DVD-Image).

So I tried TMPGenc DVD Author, a good old tool that I used for so long. There's no problem in the output but the time required to produce one takes about 2 hours, not including time to cut the commercial ad out. I want some quicker solution. Which I think I found at last......

Mplayer 1.0rc2 now can generate EDL files, a file list the start/end point to skip the play back. Combining with Mencoder, this can be used to quickly generate a DVD Video that's playable on my DVP-3040K.
mplayer -edlout edl.txt file.mpg

mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 -o C:\Temp\output.mpg -edl edl.txt TV_20080417_203429.mpg

Press "i" during play back to record start/end point of commercial ads. This is very quick and the file can also being used for other application as well (it's just a text file). The quality of encoded DVD is good enough (a little bit worse than TMPGenc). But it took only 60 minutes to encode the video on my laptop. Should be quicker on faster desktop machine.

The generated output.mpg still need to be process by TMPGenc DVD Author or DVDAuthorGUI, but it takes about 20-30 minutes to work with that (not including DVD Writing time of course). At least I find something that's working well and quick for me.