I got those Baldur’s Gate videos converted to something more modern. The problem turned out to be in the Interplay MVE demuxer code I wrote long ago for FFmpeg. Once upon a time, timestamps in FFmpeg were supposed to be in reference to a 90 kHz clock. Thanks to Pengvado for pointing out that my demuxer still made that assumption. Fixing the demuxer seems like a lot of work right now. So at this point in the exercise, I opted to simply hard code 15 fps for the framerate.
So I got that transcoding process underway, finally. And I made an interesting discovery along the way. I have a colleague who has this quote on his office whiteboard:
I can only conclude that said colleague is a huge Baldur’s Gate fan.
Prerequisites for the transcoding operation (basic Kubuntu 8.04 virtual machine):
- install the libfaac-dev package
- download and manually compile YASM (required by x264 and the latest YASM packaged by Ubuntu is not bleeding edge enough)
- download and compile the latest x264 snapshot; configure with –enable-shared
- get the latest SVN of FFmpeg
- configure and build FFmpeg with: configure –enable-gpl –enable-postproc –enable-avfilter –enable-avfilter-lavf –enable-swscale –enable-libx264 –enable-libfaac; I don’t really know if all the filter options are strictly necessary for this exercise but I’m used to them by now
So my process for transcoding in bulk after installing this software is:
- use my Python script (parse-bif-graf.py, listed at the end of this post) to split the BIF resource into its constituent MVE files:
$ parse-bif-graf.py MovieCD1.bif extracting file #0 at offset 132, 29654204 bytes, to 'MovieCD1.bif-0.mve' extracting file #1 at offset 29654336, 6530954 bytes, to 'MovieCD1.bif-1.mve' [...]
- bulk transcode:
for mve in `ls *.mve` do ffmpeg -y -i $mve \ -acodec libfaac -ab 128k \ -vcodec libx264 -vpre hq -b 500k -bt 500k \ `basename $mve .mve`.mp4 done [...]
The resulting files are highly competitive, size-wise, against the original MVE files. At first, I was monkeying with the bitrate because there were some annoying artifacts in the high motion areas. But then I watched the original videos using ffplay and realized that those artifacts are artifacts in the source material.