Variable Frame Rate MP4
From SDA Knowledge Base
Contents
Introduction
This guide assumes you're comfortable with AviSynth, MeGUI and batch files or working through the command line.
What is variable frame rate? You can probably guess that a constant frame rate is where the frame rate of a video stays the same throughout its whole length. In VFR you'll have sections that have a different framerate. VFR is useful when the game you've recorded has multiple in-game framerates. For example, God of War for the PS2 outputs gameplay at full framerate while its cinematics are half framerate. MvBob is best suited for F1 while Telecide is best suited for F2.
Creating the actual VFR MP4 isn't so hard, the tedious part is setting up the AviSynth script and frame ranges. You have to look through your segment for changes in framerate and get the exact frame that this happens.
File you'll need
Download tc2mp4 and extract the contents to your working directory.
Encoding the AviSynth script
Besides finding the frame ranges, the idea is that we make the parts with Telecide match the framerate of the parts with MvBob. The telecide parts will play at double the speed in the CFR version, but we will use tc2mp4 to slow them down which will get us our VFR version. Your script should be similar to this:
Loadplugin("C:\Program Files\DGMPGDec\DGDecode.dll") Ac3Source(MPEG2source("SEG7_5155.d2v"),"SEG7_5155_DELAY-73ms.ac3").DelayAudio(-0.073) assumetff() a=last.Trim(0,1720).mvbob() b=last.Trim(1721,4080).telecide().assumefps(a) c=last.Trim(4081,11480).mvbob() d=last.Trim(11481,12455).telecide().assumefps(a) e=last.Trim(12456,13485).mvbob() f=last.Trim(13486,16680).telecide().assumefps(a) g=last.Trim(16681,17200).mvbob() AlignedSplice(a,b,c,d,e,f,g) Lanczos4Resize(640,480) ConvertToYV12()
Encode it!
Finding the frame ranges
To calculate the frame ranges from the AviSynth script above, first find out how many there are in each set. Since MvBob is a bobbing deinterlacer, it doubles the amount of frames. Don't forget that the first number in the trim command is inclusive. So the above sets are 3442,2360,14800,975,2060,3195,1040, that's 27872 frames in total.
So, timecode.txt would be:
# timecode format v1 Assume 29.970030 0,3441,59.940060 3442,5801,29.970030 5802,20601,59.940060 20602,21576,29.970030 21577,23636,59.940060 23637,26831,29.970030 26832,27871,59.940060
Tip: Write down the left hand side first by incrementing from the set above, then the end frame is just the one before.
Setting the VFR
Your CFR encoding should be done now. Open a command line and use the following:
tc2mp4 -i myCFRvid.mp4 -t timecode.txt -o myVFRvid.mp4
Now you can mux the audio in.
Et voilà, you're done.