View Full Version : Give me advise what to improve with mencoder cmdline please ;)
shevegen
21st January 2007, 05:19
Currently I use this:
mencoder -ovc xvid -oac mp3lame -xvidencopts autoaspect:pass=2:bitrate=1100:chroma_me:me_quality=6 -o output.avi
input.vob
(Before that, I do a first pass with pass=1)
Anyone has an idea on how to get better quality, or lower file size?
The movies I encode are DVDs, most are quite cheap, the picture on them
is often not that good.
But I am just interested in creating solid .avi files myself. I know that somehow I seem to miss a great deal to "professionally" made .avi files... cuz my files end up being a lot bigger yet hardly have any real
quality improve compared to that :(
nm
21st January 2007, 11:58
Anyone has an idea on how to get better quality, or lower file size?
The default XviD settings in MEncoder are good, so there is not much to improve there. You could add chroma_opt:vhq=4 (and maybe quant_type=mpeg) to the options. The file size depends only on the bitrate you specify. If you think that the size is too large, just use a lower bitrate and see if the quality drops too much.
There is more to gain in preprocessing. First of all, the bitrate you use is already quite low for encoding DVDs at full resolution. I'd recommend downscaling to either 720xXXX with square pixels (if your DVDs are anamorphic) or even 640xXXX. Then you can try encoding at lower bitrates, or keep the 1100 kbps if the quality gets significantly better. With MEncoder, you can use -vf scale=640:-10 to get a good square-pixel resolution with the width and height being multiples of 16.
If the source is very noisy or grainy and you don't mind denoising it, you could try the hqdn3d filter.
Do you encode interlaced or telecined sources? In those cases, choosing the correct deinterlacer or ivtc method is very important for quality.
And finally, if you don't need to play the files on standalone players, try x264 instead of XviD. Then you could use a lot lower bitrates and still get the same quality.
Edit: this is pretty much the same answer you got last time (http://forum.doom9.org/showthread.php?t=118871). Did you try any of the things we suggested?
Amnon82
21st January 2007, 12:38
I found some time and looked for an old test I did with mencoder for a while. The sample was a 2000 frames comercial.
The settings and results for 1pass:
Very High Quality
__________________________
lacv: vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:vme=5:naq:qns=2
>> 3fps, 1886.141 kbit/s, PSNR: Y:50.05, Cb:51.94, Cr:52.51,All:50.66
XviD:
chroma_opt:vhq=4:bvhq=1:quant_type=mpeg
>> 12fps, 1748.798 kbit/s, Average PSNR y : 48.16 dB, u : 50.61 dB, v : 51.11 dB
x264:
subq=6:4x4mv:8x8dct:me=3:frameref=5:bframes=3:b_pyramid:weight_b
>> 5fps, 1300.185 kbit/s, PSNR Mean Y:51.71 U:54.79 V:55.62 Avg:52.52 Global:50.80
High quality
__________________________
lavc:
vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:turbo:psnr
>> 13fps, 1968.337 kbit/s, PSNR: Y:50.18, Cb:52.06, Cr:52.62, All:50.79
XviD:
vhq=2:bvhq=1:psnr:chroma_opt:quant_type=mpeg:psnr
>> 18fps, 1790.227 kbit/s, Average PSNR y : 48.14 dB, u : 50.64 dB, v : 51.14 dB
x264:
subq=5:4x4mv:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:psnr
>> 11fps, 1473.458 kbit/s, PSNR Mean Y:51.36 U:54.51 V:55.37 Avg:52.18 Global:50.59
Fast
__________________________
lavc:
vcodec=mpeg4:mbd=2:trell:v4mv:turbo:psnr
>> 34fps, 2043.167 kbit/s, PSNR: Y:49.89, Cb:52.04, Cr:52.57, All:50.56
XviD:
turbo:vhq=0:psnr
>> 28fps, 1898.784 kbit/s, Average PSNR y : 47.65 dB, u : 50.10 dB, v : 50.64 dB
x264:
subq=4:bframes=2:b_pyramid:weight_b:psnr
>> 15fps, 1554.404 kbit/s, PSNR Mean Y:51.37 U:54.37 V:55.21 Avg:52.14 Global:50.47
Realtime
__________________________
lavc:
vcodec=mpeg4:mbd=2:turbo:psnr
>> 49fps, 2018.563 kbit/s, PSNR: Y:49.09, Cb:51.50, Cr:52.12, All:49.82
XviD:
turbo:nochroma_me:notrellis:max_bframes=0:vhq=0:psnr
>> 38fps, 2436.407 kbit/s, Average PSNR y : 48.88 dB, u : 50.71 dB, v : 51.20 dB[/code]
I ran a constant quantiser encode to test the relative compressibility gain by each of the encode settings.
Also I did some runs with the snow-codec:
Snow, constant quality:
vqscale=2:vcodec=snow:cmp=1:subcmp=1:vqcomp=0.6:pred=1:psnr:vstrict=-2
>> 8fps941.722kbit/s, PSNR: Y:45.70, Cb:47.96, Cr:48.61, All:46.40
vqscale=2:vcodec=snow:cmp=1:subcmp=1:vqcomp=0.6:pred=1:psnr:vstrict=-2:qpel
>> 8fps931.956kbit/s, PSNR: Y:45.77, Cb:47.91, Cr:48.55, All:46.45
Then I did 2pass-mode runs with the same settings. The target was 900 kb/s:
Lavc
VHQ >> 6fps909.944 kbit/s PSNR: Y:45.28, Cb:47.61, Cr:48.48, All:46.02
HQ >> 15fps 908.248 kbit/s PSNR: Y:45.24, Cb:47.58, Cr:48.40, All:45.97
F >> 42fps 906.681 kbit/s PSNR: Y:44.43, Cb:47.32, Cr:48.20, All:45.28
RT >> 54fps 905.553 kbit/s PSNR: Y:43.92, Cb:47.03, Cr:47.91, All:44.81
XviD
VHQ >> 14fps 894.029 kbit/s, Average PSNR y : 44.80 dB, u : 47.72 dB, v : 48.41 dB
HQ >> 20fps 895.003 kbit/s, Average PSNR y : 44.66 dB, u : 47.68 dB, v : 48.41 dB
F >> 29fps 996.446 kbit/s, Average PSNR y : 44.19 dB, u : 46.95 dB, v : 47.63 dB
RT >> 41fps 993.631 kbit/s, Average PSNR y : 43.67 dB, u : 45.88 dB, v : 46.58 dB
x264
VHQ >> 6fps901.249 kbit/s, PSNR Mean Y:50.39 U:53.58 V:54.41 Avg:51.22 Global:48.84
HQ >> 13fps 901.408 kbit/s, PSNR Mean Y:49.53 U:52.89 V:53.75 Avg:50.39 Global:47.98
F >> 17fps 901.584 kbit/s, PSNR Mean Y:49.02 U:52.38 V:53.19 Avg:49.87 Global:47.36
RT >> (No realtime setting)
Snow 2pass:
vqscale=2:vcodec=snow:cmp=1:subcmp=1:vqcomp=0.6:pred=1:psnr:vstrict=-2
>> 9fps 898.809 kbit/s, PSNR: Y:45.48, Cb:47.79, Cr:48.45, All:46.19
vqscale=2:vcodec=snow:cmp=1:subcmp=1:vqcomp=0.6:pred=1:psnr:vstrict=-2:qpel
>> 9fps 898.991 kbit/s, PSNR: Y:45.41, Cb:47.72, Cr:48.36, All:46.12
From my point of view x264 will do the best quality with lowest spaceuse.
nm
21st January 2007, 13:27
Nice comparison, Amnon82! The 5 dB PSNR difference between x264 and MPEG-4 ASP codecs at the same bitrate (and ~ the same encoding speed) is really something to consider when choosing an encoder for low bitrates.
There is more to gain in preprocessing. First of all, the bitrate you use is already quite low for encoding DVDs at full resolution. I'd recommend downscaling to either 720xXXX with square pixels (if your DVDs are anamorphic) or even 640xXXX. Then you can try encoding at lower bitrates, or keep the 1100 kbps if the quality gets significantly better. With MEncoder, you can use -vf scale=640:-10 to get a good square-pixel resolution with the width and height being multiples of 16.
Forgot to mention that you should also crop all black borders completely. Try -vf cropdetect (and move around in the movie) to find good crop values.
shevegen
21st January 2007, 23:08
"Do you encode interlaced or telecined sources? In those cases, choosing the correct deinterlacer or ivtc method is very important for quality.
And finally, if you don't need to play the files on standalone players, try x264 instead of XviD. Then you could use a lot lower bitrates and still get the same quality.
Edit: this is pretty much the same answer you got last time. Did you try any of the things we suggested?"
http://forum.doom9.org/showthread.php?t=118871
Well the answers I got this time were better than last time.
On that other thread, one suggested
downscaling, and you (nm) suggested another codec, + experimenting
with higher vhq values, qpel and b-frames ... but without
giving really enough hints from an experienced user, this is
kinda ... well do-it-on-your-own ;)
Just trying on my own is a bit cumbersome. I could have
done this without asking for help. And I have to do it
anyway too since "your mileage may vary "
could be true too ... ;)
I already deinterlace when my source is interlaced. I found
that whenever I do so, the result gets more crap than the
original ... i hate interlaced material, but it seems way better to
get rid of that line-blur :(
Mostly using
-vf pp=lb
Telling to use another codec isnt that much of a help in that regard, when what really interests
me is to gain the best quality / file size, without bloating the movie.
And seeing that other can do so more easily. ;)
Most of the files seem to be in divx or xvid. Its nice if x264 is a lot better, but
that doesnt help me much when others have better results than I have :)
Cropping some bits wont lead to the big difference I see when I compare my results with other videos.
This time I got better answers, really, I didnt even know this thing ;)
The file size depends only on the bitrate you specify.
Anyway, thanks for the help! Appreciate it.
alec_robertson
22nd January 2007, 05:29
This is what I use to encode a film dvd to a portable device. Run "mplayer dvd://1 -vf cropdetect" to get the crop parameter.
mencoder dvd://1 -aid 128 -vfm libmpeg2 -ofps 24000/1001 \
-vf crop=720:368:0:56,scale,dsize=720:400,harddup -oac mp3lame \
-lameopts abr:br=128 -ovc x264 -x264encopts crf=24:bframes=2:nopsnr:nossim \
-o output.avi
Amnon82's post gives you a bunch of different x264encopts you can use. Just try some and see what works for you in terms of encoding speed vs visual quality.
For more info:
http://aflux.deltaanime.net/Zero1/MP4/x264.html
http://www.mplayerhq.hu/DOCS/HTML-single/en/MPlayer.html#menc-feat-x264-example-settings
nm
22nd January 2007, 08:34
I already deinterlace when my source is interlaced. I found
that whenever I do so, the result gets more crap than the
original ... i hate interlaced material, but it seems way better to
get rid of that line-blur :(
Mostly using
-vf pp=lb
Ok, that is usually fine. Sports and other fast-moving sources are better with -vf pp=fd (same as -vf lavcdeint) or by encoding them interlaced.
Most of the files seem to be in divx or xvid. Its nice if x264 is a lot better, but
that doesnt help me much when others have better results than I have :)
Cropping some bits wont lead to the big difference I see when I compare my results with other videos.
Cropping doesn't help much by itself, but is one of the important factors. Depending on the source, proper cropping will save you about 5-10% of the bitrate when keeping the same quality. Denoising will help about as much (or a lot more if you like really smooth video).
Scaling is the most important factor. With XviD and a generic DVD source, you really need to scale the resolution down if you want to use low bitrates (< 1500 kbps).
For example, with a 16:9 anamorphic PAL DVD, the original video at resolution 720x576 has 414720 pixels, while scaling that down to 640x360 leaves you with 230400 pixels. If you encode the latter (properly cropped) video with 1000 kbps, you'll probably get better visual quality than by encoding the original uncropped source directly at 1500 kbps. Just take a look at those good encodes others have made and compare the bitrate to the resolution.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.