Will the mythtv saga ever end? Will Steve ever be happy? Isn’t that way too many Twinkies in your cupboard? In answer to all three … probably not.
I have this strange little psychological tick that turns on anytime I encode video from a professionally formatted source (basically anything I didn’t make myself). I always think I can see that the A/V is out of sync. In reality, I can’t tell if it is or not. But after staring at people’s lips for a few hours straight, you’ll probably start to believe anything.
There actually is one legitimate problem though, and I know I’ve encountered these issues a long time ago and decided on using what I am now (transcode over ffmpeg / mencoder, an “fps” flag in the database, etc.) but for the life of me I can’t remember why.
The problem is that DVDs come in three different framerates: 29.97, 23.97 and a mix between the two. To handle the matter, I’ve got a trinary flag in the database. The default value will let transcode decide how to process the framerate. In most cases, that works just fine for me. Most DVDs are either 29.97 fps, or start off for a second or two in 23.97 and then switch to 29.97 for good.
Then there are my good friends that just switch back and forth between scenes from one framerate to the other — variable framerate. I know it sounds crazy, so here’s an example:
Starting playback... VDec: vo config request - 720 x 480 (preferred colorspace: Planar YV12) VDec: using Planar YV12 as output csp (no 0) Movie-Aspect is 1.33:1 - prescaling to correct movie aspect. VO: [xv] 720x480 => 720x540 Planar YV12 A: 44.8 V: 44.8 A-V: -0.007 ct: 0.076 16/ 13 ??% ??% ??,?% 0 0 demux_mpg: 24000/1001fps progressive NTSC content detected, switching framerate. A: 62.3 V: 62.3 A-V: -0.002 ct: 0.296 203/200 11% 0% 2.0% 0 0 demux_mpg: 30000/1001fps NTSC content detected, switching framerate. Warning! FPS changed 23.976 -> 29.970 (-5.994005) [4] 2.0% 0 0 A: 62.7 V: 62.7 A-V: 0.024 ct: 0.325 215/210 11% 0% 2.0% 0 0 demux_mpg: 24000/1001fps progressive NTSC content detected, switching framerate. A: 63.9 V: 63.9 A-V: 0.009 ct: 0.386 246/240 11% 0% 2.0% 0 0 demux_mpg: 30000/1001fps NTSC content detected, switching framerate. Warning! FPS changed 23.976 -> 29.970 (-5.994005) [4] 2.0% 0 0 A: 64.4 V: 64.4 A-V: 0.038 ct: 0.421 261/253 10% 0% 1.9% 0 0 demux_mpg: 24000/1001fps progressive NTSC content detected, switching framerate. A: 74.3 V: 74.3 A-V: 0.013 ct: 0.182 672/664 11% 1% 4.5% 0 0 Exiting... (Quit)
Now, I can’t remember what I used to do about this problem. I think I used to force transcode to save the new file to 23.97 frames per second. I’d rather drop some frames on the 29.97 than try to stretch out the other ones, after all. Testing this stuff isn’t easy though. You have to stare at a lot of lips and try and convince yourself that you really can see a difference of a few milliseconds.
To solve my little problem (or to put my mind to rest, whichever’s easiest), I have three ideas:
1. Tell mplayer to fix the a/v sync on playback
MPlayer has an “autosync” feature (see the man page) that you can use to tweak how often it looks to see if the audio is delayed. I tried flipping it on on one pass, and I thought I could see an improvement (although, it was a cartoon so who knows if the lip sync was ever correct in the first place), and then I tried it while watching a live-action show with it turned on, and it seemed like the sync was off. So, who knows. One thing I’ve learned from all of this is that it’s not likely there’s going to be a setting that will work for every scenario.
2. Use some funky transcode flags
In transcode’s docs directory, theres a framerate.txt file that talks just about adjusting framerates. It even mentions the exact problem I’m running into … “Some video sources are not of constant framerate. This is mostly true for Anime and some DVD Releases of TV series.” Doh!
They then have this huge example using flags I’ve never even read up on before, so that seems kinda scary. There is one, though, that I noticed in the man page, –hard-fps, which will “disable smooth dropping (for variable fps clips)” and is off by default. That might be my ticket, too.
3. Don’t do anything
There’s always the exciting option of assuming that the developers of these multimedia applications are just a twinge more genius than I am, and that by using the defaults on everything, that things might just turn out fine. I’m not sure where the fun is in that, though.
When I’m encoding more than a thousand episodes of TV shows ranging from 6 to 60 minutes in length, I have a tendency to be a little picky. Eventually though, I’m sure I’ll just settle in and start watching the shows and not even realize that it’s transcoded from the original and that the A/V is off by 3/1000th of a second. And hopefully I’ll forget all about their lips, too.