I’m having the hardest time getting things to work right with encoding variable framerate DVDs, so I’m going to do a braindump on this page and update it as I find stuff out. Please feel free to e-mail me and correct me where I’m wrong!!
Post any comments here. Thanks.
Here’s what I’ve found out, understand so far: The problem is in the fact that the framerate of some DVDs are not standard across the whole stream. Basically, your movie will start out at 29.97 frames per second, and then switch to 23.97. Then, it starts to switch back and forth again.
This is problematic for a number of reasons. For one, it throws the audio out of sync because when the encoder “probes” the video for the first time, it only looks at the framerate once, and uses that variable to decode / encode the entire file. This makes it really difficult to get the audio and video in good sync.
The only real way to “fix” this is to drop some frames, and force it to encode at a certain framerate. It’s troublesome finding just the right settings, and as far as I can tell so far, it’s also best to try your options on a case-by-case basis. There doesn’t seem to be any magic bullet that will fix all your source videos with this issue.
The encoder I use the most is transcode. Not for any particular reason other than I like it a lot, it’s a tool just for encoding video, and I’ve had a lot of success in the past.
Transcode’s docs come with a page that talks just about framerates. If you unpack the tarball, you’ll see framerate.txt in the docs/ directory. At the end it has a tiny section about VFR. Unfortunately, the doc is showing it’s age, and so I don’t know how reliable the example given is, because some of the options are now deprecated, and some are default.
Here’s a copy of it though:
transcode -i vobs/ -V -x vob,vob -f 0,4 -M2 -R3 -w2 –export_frc 1 \
-J ivtc -J decimate -B 3,9,16 –hard_fps –print_status 10 \
-J 32detect=verbose=1:force_mode=5:chromathres=2:chromadi=9 \
-y xvid -o next1.avi
The only problem I have with it is that it encodes the audio portion to MP3. I’d prefer getting an AC3 stream instead, but everytime I try to change it, it throws the sync off by about 20 to 40 seconds. The only stuff that’s really *new* in that example that I haven’t used before is using the constant quantizer (-R 3 -w 2) and the plugins (ivtc, decimate, 32detect). I know from watching the output of the file that it’s doing something with the interlacing, but sadly, that is something I’ve never understood very well. The video quality does look good after that, but still, it’s been a hit an miss as far as a/v sync goes with me.
The solution I’ve come up with so far is to test the video by running transcode 6 times on the same file, each time with different settings, and then seeing which one works out best for that DVD. Here’s the script I’m using currently:
if ! [ -a tc-test1.avi ]; then
transcode -a 0 -b 128,0,0 -i “$1″ -w 2200,250,100 -A -N 0x2000 -M 2 -Y 4,4,4,4 -B 1,11,8 -R 0 -x vob,vob -y xvid4 -c 1-15000 -o tc-test1.avi
if ! [ -a tc-test2.avi ]; then
transcode -a 0 -b 128,0,0 -i “$1″ -w 2200,250,100 -A -N 0x2000 -M 2 -Y 4,4,4,4 -B 1,11,8 -R 0 -x vob,vob -y xvid4 -c 1-15000 -f 23.976,1 -o tc-test2.avi
if ! [ -a tc-test3.avi ]; then
transcode -a 0 -b 128,0,0 -i “$1″ -w 2200,250,100 -A -N 0x2000 -M 2 -Y 4,4,4,4 -B 1,11,8 -R 0 -x vob,vob -y xvid4 -c 1-15000 -f 23.976,1 –export_fps 23.976,1 -o tc-test3.avi
if ! [ -a tc-test4.avi ]; then
transcode -a 0 -b 128,0,0 -i “$1″ -w 2200,250,100 -A -N 0x2000 -M 2 -Y 4,4,4,4 -B 1,11,8 -R 0 -x vob,vob -y xvid4 -c 1-15000 -f 23.976,1 –export_fps 23.976,1 –hard_fps -o tc-test4.avi
if ! [ -a tc-test5.avi ]; then
transcode -a 0 -b 128,0,0 -i “$1″ -w 2200,250,100 -A -N 0x2000 -M 2 -Y 4,4,4,4 -B 1,11,8 -R 0 -x vob,vob -y xvid4 -c 1-15000 –hard_fps -o tc-test5.avi
# vfr framerate redecimate, or something
if ! [ -a tc-test6.avi ]; then
transcode -i “$1″ -x vob,vob -f 0,4 -M 2 -R 3 -w 1 –export_frc 1 -J ivtc -J decimate -B 3,9,16 –hard_fps -J 32detect=force_mode=5:chromathres=2:chromadi=9 -y xvid -c 1-15000 -o tc-test6.avi
As you can see, just a simple little bash script. Checks to see if the outpfile file exists first (tc-test 1-6.avi) and then transcodes them. The “-c 1-15000″ section tells it to only encode the first 150 thousand frames, which comes out to around 5 or 10 minutes of video. I can’t remember, do the math yourself. :) It does take about 7 minutes to run through each pass though. A lot of time, I know, but it’s worth it if you can pinpoint what’s gong to work well.Anyway, I’m still currently in experimental, research and learning mode with this thing, so take everything on here with a little grain of salt. And if you find something that helps, let me know.
–hard_fps, not –force_fps