[MEncoder-users] Sending raw video into x264

James Hastings-Trew jimht at shaw.ca
Tue Mar 3 14:29:32 CET 2009

Andrew Berg wrote:
> I've been using MediaCoder for a while, but I decided I want a bit more
> control, so I thought I'd try doing what MC does manually. I'm really
> doing this mostly because I want to deinterlace video before sending it
> to x264, which I can't do with MC. I'm having a big problem, though. I
> can't seem to send raw video from by mencoder into x264 for encoding and
> get a good output like MC does (the video I get is distorted and plays
> at half the speed it should). What are the basic options I should set to
> achieve this (sending the decoded video to stdout)? My input files are
> interlaced MPEG-2, if that matters.
> _______________________________________________
Why try to send output from mencoder to x264 when mencoder has x264 
built into it? And I don't mean the mencoder that comes with Media 
Coder. I mean get a decent built of it from 

I am assuming your input is interlaced NTSC video in mpeg-2, likely from 
a DVD source, and you want a progressive h.264/aac .mp4 output. You 
could try this:

mencoder input.vob -fps 30000/1001 -ofps 24000/1001 -of lavf -lavopts 
\ -oac faac -faacopts mpeg=4:object=2:br=128:raw -channels 2 -srate 48000
\ -ovc -ovc x264 -x264encopts 
\ nodct_decimate:global_header:threads=auto
\ -sws 9 -vf pullup,softskip,scale=848:480:dsize=848:480,harddup
\ -o yourmovie.mp4

Note that this recipe leaves out b-frames which mencoder cannot 
currently encode into an mp4 container without creating an broken file. 
If you want to use bframes (which help with compression) then you will 
need to do what Media Coder does - encode the audio and video 
seperately, and mux them together into an mp4 container with mp4box. 
However, I do not recommend that with DVD sources - you will more than 
likely lose a/v sync doing it that way. Note also that I've not included 
any niceties like cropping since it is impossible to guess at what 
you'll need. I've also left de-interlacing out entirely because most 
DVDs have progressive content pulled down into an interlaced video 
stream. If the input is truely interlaced video then use this filter 
chain instead, and omit the -fps and -ofps parameters:

-vf pp=lb,scale=848:480,dsize=848:480,harddup

It is weird that media coder only includes deinterlace as a "post 
processing" video filter. Deinterlacing should always be at the top of 
the filter chain, before you do anything else with the video, in my opinion.

More information about the MEncoder-users mailing list