[MPlayer-users] Encode HD to lower resolution to play without "your system is too SLOW"

infernix infernix at infernix.net
Wed Apr 11 12:24:34 CEST 2007


Dmitry Antipov wrote:
> ...
> VIDEO:  [avc1]  1920x1080  24bpp  24.000 fps    0.0 kbps ( 0.0 kbyte/s)
> ...
> Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
> Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

Here's the culprit.

Real H264 streams (captured, usually in .ts format) are almost always 
more CPU intensive than x264 (reencoded) streams. Some H264 streams 
cannot be decoded yet (PAFF). Either way, to succesfully decode x264 and 
H264 1080p streams, you will need a fast core. My overclocked 3ghz C2D 
E6600 handles everything i throw at it, but at stock speed (2.4ghz) it 
cannot cope with some H264 streams.

This is simply the nature of the beast. There are a few possible 
workarounds.

1) Enable the skiploopfilter parameter (discussed in the thread). This 
will only help to a certain extent and might not be enough.

2) Apply the CoreAVC patches and install CoreAVC (see the 
mplayer-dev-eng mailinglist threads, be sure to use the latest patches 
from februari if they haven't made it to SVN). This will help *a great 
deal* and possibly solve all your performance issues, but at the cost of 
some quality loss here and there. ffh264 is a much more accurate 
decoder. Plus Coreavc is a commercial product.

3) reencode to 720p or an even lower resolution.

> 1) What are the best (in the sense of loosing video/audio quality as 
> small as
> possible) mencoder options to encode this movie down to given resolution 

Here's what I use for two-pass encoding; these settings are slow but 
high quality:

mencoder -oac pcm -nosound -passlogfile /tmp/x264statsfile.tmp 
-x264encopts 
bitrate=$BITRATE:threads=auto:cqm=~/eqm_avc_hr.cfg:deblock=-3,-3:bframes=5:me=umh:frameref=1:subq=1:nodct_decimate:partitions=none:nopsnr:nossim:direct_pred=auto:pass=1 
-ovc x264 -of rawvideo -o /dev/null [source file]

mencoder -oac pcm -nosound -passlogfile /tmp/x264statsfile.tmp 
-x264encopts 
bitrate=$BITRATE:threads=auto:cqm=~/eqm_avc_hr.cfg:deblock=-3,-3:bframes=5:b_pyramid:bime:weight_b:brdo:me=umh:frameref=5:mixed_refs:subq=7:trellis=1:8x8dct:nofast_pskip:nopsnr:nossim:direct_pred=auto:pass=2 
-ovc x264 -of rawvideo -o [target file.264] [source file]

I always do the audio separately so if you want to do that in one go, 
you'll have to figure that out yourself.

If you are rescaling, I recommend using '-vf scale=1280:720 -sws 9' 
which will use the lanczos rescaler.

> 2) Is there a way to encode to fit into specified size ? For example, I 
> want
> to fit the movie described above in 1G (loosing as small as possible) - how
> to choose encoding options in this case ?

Two-pass x264 encoding means you specify a target bitrate. This target 
bitrate is your target size. So, whenever you aim for a specific 
filesize, you should use twopass. If you just care about quality, you 
can use 1pass CRF encodes, like this:

mencoder -oac pcm -nosound -x264encopts 
crf=20:threads=auto:cqm=~/m4g_hrm_v2.cfg:deblock=-3,-3:bframes=5:b_pyramid:bime:weight_b:brdo:me=umh:frameref=5:mixed_refs:subq=7:trellis=1:8x8dct:nofast_pskip:nopsnr:nossim:direct_pred=auto 
-ovc x264 -of rawvideo -o [target file.264] [source file]

I know of a bitrate calculator in the windows MeGui package which you 
could use to determine the target bitrate for a given filesize. 
Generally, 1080p shouldn't be less than ~9000kbit for normal film, and 
720p shouldn't be less than ~4000kbit. I don't know about appropriate 
bitrates for lower resolutions.

note that the cqm files (eqm_avc_hr.cfg and m4g_hrm_v2.cfg) can be found 
  with google.



More information about the MPlayer-users mailing list