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

Calvin Walton calvin.walton at gmail.com
Mon Feb 18 02:47:04 CET 2008


On Mon, 2008-02-18 at 11:06 +1100, Con Kolivas wrote:
> 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.

From my testing, mkvmerge can handle a 120fps avi file as input just
fine, outputting an mkv with the correct timecodes, so you shouldn't
really need this hack.

For my encoding currently, I use mencoder to encode directly to h264
120fps avi (with b-frames even, with the really hacky support), then use
mkvmerge to turn that into an mkv.


Admittedly, I wrote a video filter that implements the same thing you
are doing before I realized this. I had the video filter write the time
code of each frame to a text file as it passed through, which is a bit
cleaner than adding another separate command line option.

If you're curious, I've attached my patch here as well. It's against an
older version of mplayer, but it should only have trivial merge
problems, from changes to the list of video filters.

Usage is "-vf timecode=filename.txt"

I generally used it in combination with the raw video output (which
drops all null frames), piped into the 'h264' command line encoder.

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

I know what you mean, some of the DVDs I have switch switch between
24fps progressive, 30fps telecined, 30fps progressive, 30fps interlaced
several times within just the first few minutes of the opening...

> 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.

-- 
Calvin Walton <calvin.walton at gmail.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: timecode-filter.patch
Type: text/x-patch
Size: 4001 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080217/0ae22c9a/attachment.bin>


More information about the MPlayer-dev-eng mailing list