Variable Frame Rate MP4

From SDA Knowledge Base

Revision as of 22:49, 18 February 2007 by Ballofsnow (Talk | contribs)

Jump to: navigation, search

Introduction

This is an advanced guide meant for those who want that extra quality in their videos. Creating VFR video takes a lot more work than CFR. You should be 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. 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.

This guide uses the concatenation method meaning that you will have to split your video on each change in framerate. So if the framerate changes six times, you're going to create seven different videos. Now you might understand why I said this is a lot of work, you're going to have to do some serious AviSynth scripting! The drawback of the concatenation method is that the bitrate distribution when doing multi-pass will be affected negatively.


Setup

There are two things you must do to make this work properly:

  • Encode to raw avc (*.264) in MeGUI/CLI.
  • Each part absolutely must have the same framerate. If you used MvBob with NTSC material, use AssumeFPS(59.94) in all the avisynth scripts, including those that used Telecide.

Make it easier for yourself and name each .264 file with some kind of sequence. Place those files in a folder that contains MP4box.exe. You can locate it in "..\MeGUI\tools\mp4box\".


The batch files

If you don't want to use batch files, the mp4box commands look like this:

mp4box -add testvfr_tele.264 -fps 29.97 -new tele.mp4 
mp4box -add testvfr_mvbob.264 -fps 59.94 -new mvbob.mp4 
mp4box -cat tele.mp4 -cat mvbob.mp4 -new telebob.mp4 

Otherwise, here are three batch files that should make this less tedious. Those PAL people out there, you know what to do.

mp4_2997.bat

@echo off
REM ### Change path below to your working directory ###
set mypath=C:\heymanyoubetterchangethis

:start
if {%1}=={} goto :eof
set name=%1
"%mypath%MP4Box.exe" -add %name% -fps 29.97 -new %name:~0,-5%.mp4
shift
goto start

mp4_5994.bat

@echo off
REM ### Change path below to your working directory ###
set mypath=C:\heymanyoubetterchangethis

:start
if {%1}=={} goto :eof
set name=%1
"%mypath%MP4Box.exe" -add %name% -fps 59.94 -new %name:~0,-5%.mp4
shift
goto start

mp4_cat.bat

@echo off
REM ### Change path below to your working directory ###
set mypath=C:\heymanyoubetterchangethis

if {%2}=={} goto :eof
"%mypath%MP4Box.exe" -cat %1 -cat %2 -new "%mypath%joined.mp4"
shift
shift
:start
if {%1}=={} goto :eof
"%mypath%MP4Box.exe" -cat "%mypath%joined.mp4" -cat %1 -new "%mypath%joined.mp4"
shift
goto start


Creating the VFR video

Whichever .264 files were encoded with Telecide, select and drag them onto the mp4_2997.bat batch file. This will create a new set of mp4 files. Do the same with the MvBob'ed files but on mp4_5994.bat.

Once they've all been muxed into an mp4, drag that set onto the mp4_cat.bat batch file. This will join everything into one big file. Hopefully you won't get any errors. If you do, complain on the Tech Support forum.

I didn't mention anything about audio.. did I? I suggest creating the audio track from the regular avisynth script for your segment, before all the splitting, and muxing that into the joined mp4.

Personal tools