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

Con Kolivas kernel at kolivas.org
Mon Feb 18 02:59:37 CET 2008


On Mon, 18 Feb 2008 12:47:04 Calvin Walton wrote:
> 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.

Sounds great, but I still need the null-frame-less avi stream to work with in 
the intermediate stage to do hard subs and so on. Also it allows me to 
deconstruct mkv, mp4 and wmv into this format for that intermediate use while 
generating the timecodes I need for the final phase. Yes I do use softsubs 
for the final phase as well, but hardsubs are required for certain things, 
and wmv and other sources are impossible to manipulate in this way. It just 
happens to combine and streamline the steps for me that you describe above 
(with raw output etc). I kind of got sick of piping things all over the place 
for different encoders etc :P

Anyway as I said, I found it useful (as have a few friends) so I was just 
making the code available. I doubt the maintainers want this merged, so I've 
made the patch available for download here for those who want it:
http://ck.kolivas.org/apps/mplayer/vfr.patch

-- 
-ck



More information about the MPlayer-dev-eng mailing list