Log in

View Full Version : mencoder settings


ost
2nd March 2009, 17:38
Is it possible to get similar quality and hardware player compliant mpeg2 files from Mencoder like from HCencoder ?
I have Linux box which is on all the day(proxy sever), it would be great that I can use it for encoding purposes also.
To find out closest Mencoder settings I encode part of video with HCencoder and then with Mencoder with similar
settings(I think). After compare them to each other:vbitrate=4000,vrc_maxrate=8500 .
First of all I try this batch:
E:\progra~1\mplayer\mencoder.exe -of mpeg -ovc lavc -nosound -lavcopts vcodec=mpeg2video:vmax_b_frames=2:vb_strategy=1:b_sensitivity=2:sc_threshold=-10000:top=0:alt:keyint=15:aspect=4/3:ildct:vrc_buf_size=1835:intra_matrix=8,8,8,9,11,13,14,17,8,8,9,11,13,13,14,17,8,8,11,12,13,14,17,94,9,11,13,13,14,17,17,94,11,11,13,13,14,17,94,94,13,13,14,16,17,20,94,94,13,13,14,17,94,94,94,94,13,14,17,94,94,94,94,94:inter_matrix=12,12,13,14,15,16,22,26,12,13,14,15,16,22,26,32,13,14,15,16,22,26,32,41,14,15,16,22,26,32,41,53,15,16,22,26,32,41,53,94,16,22,26,32,41,53,70,94,22,26,32,41,53,70,94,94,26,32,41,53,94,94,94,94:vpass=1:vbitrate=%3:vrc_maxrate=%4 %1 -o %2 of rawvideo -ffourcc MPG2
E:\progra~1\mplayer\mencoder.exe -of mpeg -ovc lavc -nosound -lavcopts vcodec=mpeg2video:vmax_b_frames=2:mbd=2:dc=9:cmp=258:precmp=258:preme=2:ildctcmp=258:b_sensitivity=2:sc_threshold=-10000:top=0:alt:keyint=15:aspect=4/3:ildct:vrc_buf_size=1835:intra_matrix=8,8,8,9,11,13,14,17,8,8,9,11,13,13,14,17,8,8,11,12,13,14,17,94,9,11,13,13,14,17,17,94,11,11,13,13,14,17,94,94,13,13,14,16,17,20,94,94,13,13,14,17,94,94,94,94,13,14,17,94,94,94,94,94:inter_matrix=12,12,13,14,15,16,22,26,12,13,14,15,16,22,26,32,13,14,15,16,22,26,32,41,14,15,16,22,26,32,41,53,15,16,22,26,32,41,53,94,16,22,26,32,41,53,70,94,22,26,32,41,53,70,94,94,26,32,41,53,94,94,94,94:vratetol=4000:vstrict=0:vpass=2:vbitrate=%3:vrc_maxrate=%4 %1 -o %2 of rawvideo -ffourcc MPG2

Result was similar with HCencoder except in static areas(walls) and scenes with high motion is noticeable macroblocking.

Then I tune batch with adaptive quantization settings:
E:\progra~1\mplayer\mencoder.exe -of mpeg -ovc lavc -nosound -lavcopts vcodec=mpeg2video:vpass=1:turbo:vqmin=3:vqscale=2:vrc_maxrate=%4:vrc_buf_size=1835:keyint=15:vqcomp=0.9:vmax_b_frames=2:vb_strategy=1:b_sensitivity=2:vb_qfactor=1.0:vb_qoffset=0.0:vi_qfactor=1.0:me_range=128:preme=2:dia=2:predia=2:mbd=2:mv0:dc=9:aspect=4/3:inter_matrix=12,12,13,14,15,16,22,26,12,13,14,15,16,22,26,32,13,14,15,16,22,26,32,41,14,15,16,22,26,32,41,53,15,16,22,26,32,41,53,94,16,22,26,32,41,53,70,94,22,26,32,41,53,70,94,94,26,32,41,53,94,94,94,94:intra_matrix=8,8,8,9,11,13,14,17,8,8,9,11,13,13,14,17,8,8,11,12,13,14,17,94,9,11,13,13,14,17,17,94,11,11,13,13,14,17,94,94,13,13,14,16,17,20,94,94,13,13,14,17,94,94,94,94,13,14,17,94,94,94,94,94:vlelim=-2:vcelim=3:ildct:sc_threshold=-10000:top=0:alt %1 -o %2 -of rawvideo -ffourcc MPG2
E:\progra~1\mplayer\mencoder.exe -of mpeg -ovc lavc -nosound -lavcopts vcodec=mpeg2video:vpass=2:vqmin=3:vrc_maxrate=%4:vrc_buf_size=1835:keyint=15:vqcomp=0.9:vmax_b_frames=2:b_sensitivity=2:bidir_refine=1:vb_qfactor=1.0:vb_qoffset=0.0:vi_qfactor=1.0:me_range=128:last_pred=1:preme=2:dia=2:predia=2:mbd=2:mv0:nssew=1000:mv0_threshold=128:dc=9:aspect=4/3:inter_matrix=12,12,13,14,15,16,22,26,12,13,14,15,16,22,26,32,13,14,15,16,22,26,32,41,14,15,16,22,26,32,41,53,15,16,22,26,32,41,53,94,16,22,26,32,41,53,70,94,22,26,32,41,53,70,94,94,26,32,41,53,94,94,94,94:intra_matrix=8,8,8,9,11,13,14,17,8,8,9,11,13,13,14,17,8,8,11,12,13,14,17,94,9,11,13,13,14,17,17,94,11,11,13,13,14,17,94,94,13,13,14,16,17,20,94,94,13,13,14,17,94,94,94,94,13,14,17,94,94,94,94,94:lumi_mask=0.05:dark_mask=0.3:tcplx_mask=0.1:scplx_mask=0.1:vlelim=-2:vcelim=3:naq:vbitrate=%3:vratetol=4000:vstrict=0:ildct:sc_threshold=-10000:top=0:alt:threads=1 %1 -o %2 -of rawvideo -ffourcc MPG2

Mencoder in some places report that there were rc buffer underflows. First ~200 frames looks ugly, but later result
outperform HCencoder, until I notice - in ~middle of the file artifact: at the top part of screen very heavy macroblocking
which tend to increase in size in following frames.

Mencoder:
9539

HCencoder:
9540

What was wrong with my batch files?

I’m sorry for my English!

ar
24th August 2009, 21:37
How about this?
$ mencoder -of mpeg -ovc lavc -nosound -lavcopts vcodec=mpeg2video:dc=10:cgop:aspect=4/3:threads=1:vpass=1:vqmin=1:lmin=0.5:mblmin=0.5:vbitrate=$3:vrc_maxrate=$4:vrc_buf_size=1835:vrc_strategy=1:vmax_b_frames=2:vme=4:me_range=0:preme=2:mbd=0:keyint=15:sc_threshold=1000000000:vb_strategy=2:bidir_refine=4:ildct:ilme:alt:top=0:mbcmp=6:ildctcmp=6:precmp=6:cmp=6:subcmp=6:skipcmp=6:nssew=1000:predia=-1:dia=-1:intra_matrix=8,8,8,9,11,13,14,17,8,8,9,11,13,13,14,17,8,8,11,12,13,14,17,94,9,11,13,13,14,17,17,94,11,11,13,13,14,17,94,94,13,13,14,16,17,20,94,94,13,13,14,17,94,94,94,94,13,14,17,94,94,94,94,94:inter_matrix=12,12,13,14,15,16,22,26,12,13,14,15,16,22,26,32,13,14,15,16,22,26,32,41,14,15,16,22,26,32,41,53,15,16,22,26,32,41,53,94,16,22,26,32,41,53,70,94,22,26,32,41,53,70,94,94,26,32,41,53,94,94,94,94 -o /dev/null $1 && mencoder -of mpeg -ovc lavc -nosound -lavcopts vcodec=mpeg2video:dc=10:cgop:aspect=4/3:threads=1:vpass=2:vqmin=1:lmin=0.5:mblmin=0.5:vqblur=0.75:vbitrate=$3:vrc_maxrate=$4:vrc_buf_size=1835:vrc_strategy=1:vmax_b_frames=2:vme=4:me_range=0:preme=2:mbd=0:keyint=15:sc_threshold=1000000000:bidir_refine=4:ildct:ilme:alt:top=0:mbcmp=6:ildctcmp=6:precmp=6:cmp=6:subcmp=6:skipcmp=6:nssew=1000:predia=-1:dia=-1:intra_matrix=8,8,8,9,11,13,14,17,8,8,9,11,13,13,14,17,8,8,11,12,13,14,17,94,9,11,13,13,14,17,17,94,11,11,13,13,14,17,94,94,13,13,14,16,17,20,94,94,13,13,14,17,94,94,94,94,13,14,17,94,94,94,94,94:inter_matrix=12,12,13,14,15,16,22,26,12,13,14,15,16,22,26,32,13,14,15,16,22,26,32,41,14,15,16,22,26,32,41,53,15,16,22,26,32,41,53,94,16,22,26,32,41,53,70,94,22,26,32,41,53,70,94,94,26,32,41,53,94,94,94,94 -o $2 $1

fvisagie
25th August 2009, 09:00
Hi ost,

As I recall from when I compared them, MEncoder implements many more MPEG-2 features and control over them than does HCenc, and also does a much higher quality job of it. The MEncoder command line I used was quite slow and very high quality:

set BITRATE=6150
set MAXRATE=9000
set MUXRATE=10080

rem set PSNR=:psnr
set PSNR=
set VB_STRAT=
set CMD=37

set PASS=1
set VB_STRAT=:vb_strategy=1
if exist psnr_*.log del psnr_*log
if exist divx2pass.log del divx2pass.log
set OUTPUT=%1.%CMD%.mpg
:L37
mencoder -field-dominance 1 -mc 0 -vf hqdn3d=2:1:2,harddup -oac lavc -ovc lavc -lavcopts abitrate=128:acodec=ac3:autoaspect:ilme:ildct:keyint=15:mbd=2:top=0:trell:vbitrate=%BITRATE%:vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=%MAXRATE%:vstrict=0%PSNR%:vmax_b_frames=2%VB_STRAT%:dia=2:preme=2:predia=2:mbcmp=6:precmp=2:cmp=2:subcmp=6:last_pred=2:mv0:mv0_threshold=0 -of mpeg -mpegopts format=dvd:muxrate=%MUXRATE%:tsaf %1 -o %OUTPUT% >%OUTPUT%.%PASS%.txt
if %PASS% == 2 goto END
set PASS=2
set VB_STRAT=
goto L37


Removed the goto above which was confusing in this, an extract from a batch file. Also note that "-field-dominance 1" was put in for bottom field first DV material, and "ilme:ildct" for handling interlaced input.


For me the downside of MEncoder is the persistent buffer underflow (reported as "undeflow") at high bit rates and especially when there's a lot of inter-frame change. No developer confident with that part of the code seems around any more. After nearly losing my mind trying all kinds of ways out on big projects I eventually switched to FFmpeg which although similar in functionality, doesn't have that problem but has very limited documentation in turn ;-).