The wonderful tale of VFR FLV1 to CFR AVI to 3GP
WARNING: Needlessly long tech ramble follows.
So, browsing Youtube, like you do, I come across Interpretation of Trivium
Now, I quite like Trivium, and even though the video disses them a bit, I still like it. “Boat, Rudder, Strange Mountain!”
Anyway. Saving it for posterity, it goes into an flv (Flash Video). VLC player can play these quite easily. “Magic”, I thought, “FFMpeg can convert this no problem”.
Unfortunately, I was wrong. For some strange reason, the video was randomly sped up in places. So, I found FFDShow, which can understand FLV1 files, and uses DirectShow. The files played fine in MPC, Media Player, VLC – but as soon as they were converted they messed up. Moyea Flash to Video converter worked fine, but there was a massive watermark over the picture, as it was a demo.
I installed AviSynth. This is where the fun began. AviSynth’s DirectShowSource filter was giving me the same output as my AVIs. “Strange”, I thought. Googling led me to my problem: VFR.Variable Frame Rate. The AVI container format is quite happy working with CFR (Constant Frame Rate) but as soon as you start going variable, it messes up. “No matter!” thought I, reading the documentation for DirectShowSource. “ConvertFPS will solve it!”
Err.. No.
So, after more googling, this lead me to Graphedit, which is possibly the coolest bit of kit Microsoft has done. You can chain together DirectShow filters and output them anywhere.
Another google found a forum post recommending Matroska as a halfway house to AVI. So, I set up Graphedit – FLV->FFDShow Decoder->Xvid Encoder->AviMux->File Writer.
Success! The video played fine! This was because MKV is a clever little format that understands VFR.
Fuelled by this development, I frantically Googled for VFR MKV to CFR AVI solutions. The AviSynth page didn’t really help with this, but I found a tool called mkv2vfr. This would give me an AVI, and Timecodes of the frames. Using TVITC, I could create a proper AVI!
Except, mkv2vfr didn’t work. Disheartened, I instead looked at MKVtoolnix. MKVExtract has a function that gives out V2 Timecodes. mkv2vfr gives out V1 Timecodes, which are easier to work with. convert-timecodes.exe sorted this little hiccup up.
Another google found Timecode2AVS – A brilliant idea. Since V1 timecodes are in the format
frameX,frameY,framerateFromXtoY
you can convert every one of the lines in the file to the form
source.trim(X,Y).AssumeFPS(framerate).ChangeFPS(119.88)
The ChangeFPS is because it’s the LCM of 24 and 30. At the end of the file, you have to glue all the bits of files together, and then FDecimate(targetFramerate). In my case, I originally used 24. Having problems, I disregarded this method. Noticing later that my frames were around 30fps, I changed the setting from 23.976 to 29.97. It worked!
Now, all I had to do was set source to DirectShowSource(“Interpretation of Trivium.mkv”) and hope… Thankfully, it worked!
The last steps were academic really… VirtualDubMod can handle avs files, so I imported it and turned it into an XVid. The project that had me banging my head on the wall was complete! I’d turned a VFR FLV/MKV into a CFR AVI. The final step was to throw it at 3gp_Converter (which runs FFMpeg under the bonnet). Being CFR, it had no such problems this time.
Finally, I had my 3GP FLV :p Now I can take the best of YouTube to the pub with me.
In short:
1. Open FLV with Graphedit (with FFDShow installed and FLV1 activated)
2. XVidise the video and mux it with Matroska
3. Extract the V2 Timecodes
4. Convert the timecodes to avs, and edit the filenames, etc
5. Import the avs into VDubMod
6. Export as AVI
7. Import into 3GPConverter
8. Play your brand spanking new 3GP file!
Max Dymond

Loading…
Add a comment
You are not allowed to comment on this entry as it has restricted commenting permissions.