[MEncoder-users] Handy MPEG-2 (DVD) test script
Francois Visagie
fvisagie at za.spescom.com
Sun Oct 7 12:22:12 CEST 2007
Hi All,
Especially when doing something for the first time with no prior
configuration for guidance, it becomes tedious to compare the effect of
various settings. Here's a handy Windows batch file that tests most settings
relevant to MPEG-2 (DVD compliant) encoding. For comparison a separate
MPEG-2 output file is created for each setting. Separate log files for both
passes of each setting contain the following useful information: PSNR for
the whole encode as well as for individual frames, and encoding speed
measurements in fps.
This could be more elegantly coded, but that would be at the expense of what
little portability there is.
Remember to set bitrate to your preference. Audio probably isn't of much
relevance here, but you might want to fiddle with that too.
===
@echo off
setlocal
REM Check that input file is valid
if exist %1 goto ENCOD1
echo.
echo Invalid input file %1!
echo HINT: If it contains spaces, enclose input filename in quotes
pause
goto END
:ENCOD1
set PASS=1
:LOOP1
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpeg2video:vpass=%PASS%
:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3:abitrate=128:psnr
-of mpeg -mpegopts format=dvd:tsaf -o %1.1.mpg >%1.1.%PASS%.txt
if %PASS% == 2 goto ENCOD2
set PASS=2
goto LOOP1
:ENCOD2
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP2
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
cmp=3:precmp=3:subcmp=3:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec
=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec
=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.2.mpg
>%1.2.%PASS%.txt
if %PASS% == 2 goto ENCOD3
set PASS=2
goto LOOP2
:ENCOD3
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP3
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
cmp=6:precmp=6:subcmp=6:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec
=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec
=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.3.mpg
>%1.3.%PASS%.txt
if %PASS% == 2 goto ENCOD4
set PASS=2
goto LOOP3
:ENCOD4
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP4
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
dia=2:predia=2:preme=2:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=
mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=
ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.4.mpg
>%1.4.%PASS%.txt
if %PASS% == 2 goto ENCOD5
set PASS=2
goto LOOP4
:ENCOD5
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP5
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
dc=10:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpeg2video:vpass=
%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3:abitrate=128:
psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.5.mpg >%1.5.%PASS%.txt
if %PASS% == 2 goto ENCOD6
set PASS=2
goto LOOP5
:ENCOD6
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP6
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
last_pred=3:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpeg2video:
vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3:abitrat
e=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.6.mpg >%1.6.%PASS%.txt
if %PASS% == 2 goto ENCOD7
set PASS=2
goto LOOP6
:ENCOD7
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP7
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
mbd=2:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpeg2video:vpass=
%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3:abitrate=128:
psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.7.mpg >%1.7.%PASS%.txt
if %PASS% == 2 goto ENCOD8
set PASS=2
goto LOOP7
:ENCOD8
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP8
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
mv0:mv0_threshold=0:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpe
g2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3
:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.8.mpg
>%1.8.%PASS%.txt
if %PASS% == 2 goto ENCOD9
set PASS=2
goto LOOP8
:ENCOD9
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP9
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
cbp:trell:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpeg2video:vp
ass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3:abitrate=
128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.9.mpg >%1.9.%PASS%.txt
if %PASS% == 2 goto ENCOD10
set PASS=2
goto LOOP9
:ENCOD10
if exist psnr_*.log del psnr_*log
set PASS=1
set VB_STRAT=vb_strategy=0:
:LOOP10
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
vmax_b_frames=1:%VB_STRAT%aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcod
ec=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acod
ec=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.10.mpg
>%1.10.%PASS%.txt
if %PASS% == 2 goto ENCOD11
set PASS=2
set VB_STRAT=
goto LOOP10
:ENCOD11
if exist psnr_*.log del psnr_*log
set PASS=1
set VB_STRAT=vb_strategy=1:
:LOOP11
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
vmax_b_frames=1:%VB_STRAT%aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcod
ec=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acod
ec=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.11.mpg
>%1.11.%PASS%.txt
if %PASS% == 2 goto ENCOD12
set PASS=2
set VB_STRAT=
goto LOOP11
:ENCOD12
if exist psnr_*.log del psnr_*log
set PASS=1
set VB_STRAT=vb_strategy=2:
:LOOP12
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
vmax_b_frames=1:%VB_STRAT%aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcod
ec=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acod
ec=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.12.mpg
>%1.12.%PASS%.txt
if %PASS% == 2 goto ENCOD13
set PASS=2
set VB_STRAT=
goto LOOP12
:ENCOD13
if exist psnr_*.log del psnr_*log
set PASS=1
set VB_STRAT=vb_strategy=0:
:LOOP13
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
vmax_b_frames=2:%VB_STRAT%aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcod
ec=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acod
ec=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.13.mpg
>%1.13.%PASS%.txt
if %PASS% == 2 goto ENCOD14
set PASS=2
set VB_STRAT=
goto LOOP13
:ENCOD14
if exist psnr_*.log del psnr_*log
set PASS=1
set VB_STRAT=vb_strategy=1:
:LOOP14
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
vmax_b_frames=2:%VB_STRAT%aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcod
ec=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acod
ec=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.14.mpg
>%1.14.%PASS%.txt
if %PASS% == 2 goto ENCOD15
set PASS=2
set VB_STRAT=
goto LOOP14
:ENCOD15
if exist psnr_*.log del psnr_*log
set PASS=1
set VB_STRAT=vb_strategy=2:
:LOOP15
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
vmax_b_frames=2:%VB_STRAT%aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcod
ec=mpeg2video:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acod
ec=ac3:abitrate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.15.mpg
>%1.15.%PASS%.txt
if %PASS% == 2 goto ENCOD16
set PASS=2
set VB_STRAT=
goto LOOP15
:ENCOD16
if exist psnr_*.log del psnr_*log
set PASS=1
:LOOP16
mencoder %1 -aspect 4/3 -mc 0 -noskip -vf hqdn3d=2:1:2,harddup -ovc lavc
-oac lavc -lavcopts
lmin=1:vqmin=1:aspect=4/3:ildct:ilme:keyint=15:vbitrate=7345:vcodec=mpeg2vid
eo:vpass=%PASS%:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:acodec=ac3:abit
rate=128:psnr -of mpeg -mpegopts format=dvd:tsaf -o %1.16.mpg
>%1.16.%PASS%.txt
if %PASS% == 2 goto ENCOD17
set PASS=2
goto LOOP16
:ENCOD17
if exist psnr_*.log del psnr_*log
:END
if exist divx2pass.log del divx2pass.log
:EXIT
set PASS=
set VB_STRAT=
Endlocal
===
Kind regards,
Francois
This e-mail is sent on the Spescom Terms and Conditions
that can be accessed by clicking on this link http://www.spescom.com/email.html
More information about the MEncoder-users
mailing list