[MPlayer-dev-eng] Variable frame rate for mencoder

Con Kolivas kernel at kolivas.org
Mon Feb 18 01:06:38 CET 2008


Hi all

I had a need to generate variable frame rate avi files and timecode stamps for 
muxing into other containers (specifically .mkv) and hacked in a -makevfr 
option into mencoder. There are only a handful of really awful unmaintained 
windows apps that manage these currently.

What this does is it generates an avi output file without any null frames, 
which is pretty much unusable by itself, but it also generates a timecodes 
version2 file (timecodes.txt). The resulting avi file and timecodes file can 
then be muxed into a true variable frame rate container such as mkv using 
mkvtoolnix.

So what this is useful for, is the various pseudo variable frame rate videos 
out there such as wmv (which imitates 1000fps) and the so called 120fps ntsc 
video captures. These are usually a blend of various combinations of 
24000/1001, 30000/1001 and 60000/1001 videos. No fixed frame rate ever 
creates smooth video from them.

To use this, you must use nosound as the resultant file is meaningless without 
it.

Any frame rate input should be able to be used, and the resultant output 
*should* always have audio video sync.

Eg:

mencoder -nosound -ovc lavc -mc 0 -makevfr -o temporary_vfr.avi source.wmv

the resultant temporary_vfr.avi file then needs to be muxed with mkvtoolnix 
specifying the timecodes for that video stream and the audio needs to be 
added separately.

mplayer -vo null -ao pcm:fast:file=audio.wav source.wmv
faac audio.wav

mkvmerge -o vfr.mkv --timecodes 0:timecodes.txt  temporary_vfr.avi audio.aac

This should generate a real variable frame rate in a container that supports 
it without losing audio sync from any input.

The use of -ofps can be used to set the maximum frame rate, but is usually not 
required. I'd actually suggest using it for wmv because at a precision of 
1000fps it actually isn't any meaningful multiple of the real frame rates. 
The best is actually that 120 number used by avi, so -ofps 120000/1001

Generally speaking, those who already know about making variable frame rate 
anime will already know what to do.


I realise mencoder has lots of issues and is considered broken at the moment, 
but there are many of us who depend on it as it fills a niche nothing else 
does.

I also realise that I have not studied the code style of mplayer/mencoder 
extensively and have probably committed numerous sins in the way I've hacked 
this up. Thus I don't expect the code to be committed. However, I offer it as 
a demonstration piece and of interest since it has been incredibly useful to 
me, dealing with variable frame rate mkv, mp4, 120fps avi, wmv.

Cheers, and thanks for mplayer.

Patch attached.

-- 
-ck
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vfr.patch
Type: text/x-diff
Size: 4432 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080218/ddb9d4a7/attachment.patch>


More information about the MPlayer-dev-eng mailing list