Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Feb 2009
Posts: 16
|
libavcodec 54 vs. 57: rate controller regression?
Preamble
A few years ago i encoded sequence from Elephant's Dream (see source) with different MPEG-2 encoding libraries. I downloaded all pngs, and then made AVI with lossless FFV1 (bgr0 pixel format). It helped to reduce size from 21 to 12,4 GiB. Avisynth script: Code:
InputRGB = ImageReader("%05d.png", \ start=00001, \ end=15691, \ fps=24, pixel_type="rgb24").\ AssumeFPS(24000, 1001) return InputRGB ++ \ InputRGB.Trim(15690, 15690) Code:
InputVideo_RGB = AVISource("ed-film-1080p-ffv1.avi", \ audio=false, \ pixel_type="RGB32", \ fourCC="FFV1") InputVideo_YUV = InputVideo_RGB.\ BilinearResize(720, 576).\ ConvertToYV12(matrix="Rec601", interlaced=false).\ AssumeFPS(25, 1) return InputVideo_YUV Code:
original = AVISource("ed-pal-i420-ffvh.avi", \ audio=false, \ pixel_type="YV12", \ fourCC="FFVH") return original Code:
intra="8,16,19,22,26,27,29,34,\ 16,16,22,24,27,29,34,37,\ 19,22,26,27,29,34,34,38,\ 22,22,26,27,29,34,37,40,\ 22,26,27,29,32,35,40,48,\ 26,27,29,32,35,40,48,58,\ 26,27,29,34,38,46,56,69,\ 27,29,35,38,46,56,69,83" inter="16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16,\ 16,16,16,16,16,16,16,16" intra=$(echo $intra | sed -e "s/[^0-9,]//g;") inter=$(echo $inter | sed -e "s/[^0-9,]//g;") wine avs2yuv -raw ed-pal.avs - | \ mencoder -demuxer rawvideo -rawvideo fps=25:pal=yes:i420=yes \ -of mpeg=yes -mpegopts format=dvd:tsaf=yes -ofps 25 -noskip -ovc lavc=yes \ -lavcopts vcodec=mpeg2video:vstrict=1 \ -lavcopts vbitrate=4800:vrc_maxrate=8700:vpass=1:vqblur=0.5:vb_strategy=2 \ -lavcopts vqmin=1:vqmax=31:vqdiff=3:dc=10 \ -lavcopts vb_qfactor=1.25:vi_qfactor=0.8:vb_qoffset=1.25:vi_qoffset=0 \ -lavcopts vlelim=0:vcelim=0 \ -lavcopts lmin=0.5:lmax=20:mblmin=0.5:mblmax=20:vqsquish=1 \ -lavcopts vrc_minrate=0:vrc_strategy=0:vrc_buf_size=1835 \ -lavcopts vqcomp=0.5 \ -lavcopts keyint=15:cgop=yes \ -lavcopts vmax_b_frames=2 \ -lavcopts sc_threshold=1000000000 \ -lavcopts vme=4:me_range=0:preme=2:bidir_refine=4 \ -lavcopts predia=-1:dia=-1 \ -lavcopts mbd=0:mbcmp=6:precmp=6:cmp=6:subcmp=6:skipcmp=6 \ -lavcopts mv0_threshold=256 \ -lavcopts subq=8 \ -lavcopts intra_matrix=${intra} \ -lavcopts inter_matrix=${inter} \ -lavcopts nr=0 \ -lavcopts aspect=16/9:threads=4 \ -passlogfile pass_ed-pal_menc50mpeg-nlqs.log \ -o /dev/null - Code:
wine avs2yuv -raw ed-pal.avs - | \ mencoder -demuxer rawvideo -rawvideo fps=25:pal=yes:i420=yes \ -of mpeg=yes -mpegopts format=dvd:tsaf=yes -ofps 25 -noskip -ovc lavc=yes \ -lavcopts vcodec=mpeg2video:vstrict=1 \ -lavcopts vbitrate=4800:vrc_maxrate=8700:vpass=2:vqblur=1.0 \ -lavcopts vqmin=1:vqmax=31:vqdiff=3:dc=10 \ -lavcopts vb_qfactor=1.25:vi_qfactor=0.8:vb_qoffset=1.25:vi_qoffset=0 \ -lavcopts vlelim=0:vcelim=0 \ -lavcopts lmin=0.5:lmax=20:mblmin=0.5:mblmax=20:vqsquish=1 \ -lavcopts vrc_minrate=0:vrc_strategy=0:vrc_buf_size=1835 \ -lavcopts vqcomp=0.5 \ -lavcopts keyint=15:cgop=yes \ -lavcopts vmax_b_frames=2 \ -lavcopts sc_threshold=1000000000 \ -lavcopts vme=4:me_range=0:preme=2:bidir_refine=4 \ -lavcopts predia=-1:dia=-1 \ -lavcopts mbd=0:mbcmp=6:precmp=6:cmp=6:subcmp=6:skipcmp=6 \ -lavcopts mv0_threshold=256 \ -lavcopts subq=8 \ -lavcopts intra_matrix=${intra} \ -lavcopts inter_matrix=${inter} \ -lavcopts nr=0 \ -lavcopts aspect=16/9:threads=4 \ -passlogfile pass_ed-pal_menc50mpeg-nlqs.log \ -o ed-pal_menc50mpeg-nlqs.vob - The matter Today i have tried to reproduce results with actual versions of libavcodec (encoders: ffmpeg 2.8.7, mencoder 1.1.1 and mencoder 1.3.0). For mencoder 1.1.1 command was the same, for others see commands bellow. For mencoder 1.3.0: Code:
wine avs2yuv -raw ed-pal.avs - | \ mencoder -demuxer rawvideo -rawvideo fps=25:pal=yes:i420=yes \ -of mpeg=yes -mpegopts format=dvd:tsaf=yes -ofps 25 -noskip -ovc lavc=yes \ -lavcopts vcodec=mpeg2video:vstrict=1 \ -lavcopts vbitrate=4800:vrc_maxrate=8700:vpass=1:vqblur=0.5:vb_strategy=2 \ -lavcopts vqmin=1:vqmax=31:vqdiff=3:dc=10 \ -lavcopts vb_qfactor=1.25:vi_qfactor=0.8:vb_qoffset=1.25:vi_qoffset=0 \ -lavcopts o=luma_elim_threshold=0:o=chroma_elim_threshold=0 \ -lavcopts lmin=0.5:lmax=31:mblmin=0.5:mblmax=31 \ -lavcopts vrc_minrate=0:vrc_strategy=0:vrc_buf_size=1835 \ -lavcopts vqcomp=0.5 \ -lavcopts keyint=15:cgop=yes \ -lavcopts vmax_b_frames=2 \ -lavcopts sc_threshold=1000000000 \ -lavcopts vme=4:me_range=0:preme=2:bidir_refine=4 \ -lavcopts predia=-1:dia=-1 \ -lavcopts mbd=0:mbcmp=6:precmp=6:cmp=6:subcmp=6:skipcmp=6 \ -lavcopts mv0_threshold=256 \ -lavcopts subq=8 \ -lavcopts intra_matrix=${intra} \ -lavcopts inter_matrix=${inter} \ -lavcopts aspect=16/9:threads=4 \ -passlogfile pass_ed-pal_menc50mpeg-nlqs.log \ -msglevel global=0 \ -o /dev/null - wine avs2yuv -raw ed-pal.avs - | \ mencoder -demuxer rawvideo -rawvideo fps=25:pal=yes:i420=yes \ -of mpeg=yes -mpegopts format=dvd:tsaf=yes -ofps 25 -noskip -ovc lavc=yes \ -lavcopts vcodec=mpeg2video:vstrict=1 \ -lavcopts vbitrate=4800:vrc_maxrate=8700:vpass=2:vqblur=1.0 \ -lavcopts vqmin=1:vqmax=31:vqdiff=3:dc=10 \ -lavcopts vb_qfactor=1.25:vi_qfactor=0.8:vb_qoffset=1.25:vi_qoffset=0 \ -lavcopts o=luma_elim_threshold=0:o=chroma_elim_threshold=0 \ -lavcopts lmin=0.5:lmax=31:mblmin=0.5:mblmax=31 \ -lavcopts vrc_minrate=0:vrc_strategy=0:vrc_buf_size=1835 \ -lavcopts vqcomp=0.5 \ -lavcopts keyint=15:cgop=yes \ -lavcopts vmax_b_frames=2 \ -lavcopts sc_threshold=1000000000 \ -lavcopts vme=4:me_range=0:preme=2:bidir_refine=4 \ -lavcopts predia=-1:dia=-1 \ -lavcopts mbd=0:mbcmp=6:precmp=6:cmp=6:subcmp=6:skipcmp=6 \ -lavcopts mv0_threshold=256 \ -lavcopts subq=8 \ -lavcopts intra_matrix=${intra} \ -lavcopts inter_matrix=${inter} \ -lavcopts nr=0 \ -lavcopts aspect=16/9:threads=4 \ -passlogfile pass_ed-pal_menc50mpeg-nlqs.log \ -msglevel global=0 \ -o ed-pal_men50mpeg-nlqs-lavc57.vob - Code:
ffmpeg -i ed-pal-i420-ffvh.avi \ -vcodec mpeg2video -strict strict \ -pass 1 \ -b:v 4800k -maxrate 8700k -minrate 0 -bufsize 1835k -rc_strategy 0 \ -g 15 -bf 2 -b_strategy 2 -flags cgop \ -qcomp 0.1 -qblur 0.5 \ -qmin 1 -qmax 28 -qdiff 3 -dc 10 -non_linear_quant 1 \ -lmin 0 -lmax 767 -mblmin 1 -mblmax 31 \ -i_qfactor 0.8 -i_qoffset 0 -b_qfactor 1.25 -b_qoffset 1.25 -ibias 96 -pbias 0 \ -luma_elim_threshold 0 -chroma_elim_threshold 0 \ -sc_threshold 1000000000 \ -me_method epzs -me_range 0 -dia_size -1 -pre_dia_size -1 -preme 2 -bidir_refine 4 -mv0_threshold 256 \ -mbd simple -cmp rd -subcmp rd -mbcmp rd -precmp rd -skipcmp rd -subq 8 -brd_scale 0 \ -intra_matrix ${intra} \ -inter_matrix ${inter} \ -nr 0 \ -aspect 16/9 -threads 4 \ -f dvd \ /dev/null -y ffmpeg -i ed-pal-i420-ffvh.avi \ -vcodec mpeg2video -strict strict \ -pass 2 \ -b:v 4800k -maxrate 8700k -minrate 0 -bufsize 1835k -rc_strategy 0 \ -g 15 -bf 2 -flags cgop \ -qcomp 0.1 -qblur 1.0 \ -qmin 1 -qmax 28 -qdiff 3 -dc 10 -non_linear_quant 1 \ -lmin 0 -lmax 767 -mblmin 1 -mblmax 31 \ -i_qfactor 0.8 -i_qoffset 0 -b_qfactor 1.25 -b_qoffset 1.25 -ibias 96 -pbias 0 \ -luma_elim_threshold 0 -chroma_elim_threshold 0 \ -sc_threshold 1000000000 \ -me_method epzs -me_range 0 -dia_size -1 -pre_dia_size -1 -preme 2 -bidir_refine 4 -mv0_threshold 256 \ -mbd simple -cmp rd -subcmp rd -mbcmp rd -precmp rd -skipcmp rd -subq 8 -brd_scale 0 \ -intra_matrix ${intra} \ -inter_matrix ${inter} \ -nr 0 \ -aspect 16/9 -threads 4 \ -f dvd \ ed-pal_men50mpeg-nlqs-lavc56.vob -y Code:
encoder library version max min avg. ssim 0.24 bitrate, bitrate, bitrate, kbps kbps kbps ================================================================================ cce sp3 cceserver2 1.0.1.4 9434 159 4779 92,65 hcenc hcenc 0.25 9181 118 4788 92,55 mencoder libavcodec 52.72.2 9048 118 4797 92,97 mencoder libavcodec 54.23.100 9390 118 4796 92,98 ffmpeg libavcodec 56.60.100 9018 167 4792 92,67 mencoder libavcodec 57.25.100 9472 167 3516 91,83 The question How to make it good again? How to make libavcodec 56/57 to reduce quantizers for low motion scenes? Which keys for ffmpeg/mencoder? Any ideas? Last edited by ar; 5th June 2016 at 10:19. Reason: fixed command for ffmpeg (-lmax 767) and results. |
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,113
|
Just a shot from the hip (as I am no ffmpeg specialist at all...):
Could it be that you still use Q units for lmin, lmax, mblmin and mblmax while newer ffmpeg versions use lambda units? See this post: http://forum.doom9.org/showthread.ph...26#post1662726 Whatever, for my AVStoDVD plugin I use the parameters supplied by Fishman from this post: http://forum.doom9.org/showthread.ph...63#post1663063 And with these parameters dark and static scenes do look very good... Cheers manolito |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Feb 2009
Posts: 16
|
Thank you!
I have just tested parameters supplied by Fishman. ffmpeg commands: Code:
intra="8,16,19,22,26,27,29,34,\ 16,16,22,24,27,29,34,37,\ 19,22,26,27,29,34,34,38,\ 22,22,26,27,29,34,37,40,\ 22,26,27,29,32,35,40,48,\ 26,27,29,32,35,40,48,58,\ 26,27,29,34,38,46,56,69,\ 27,29,35,38,46,56,69,83" inter="16,17,18,19,20,21,22,23,\ 17,18,19,20,21,22,23,24,\ 18,19,20,21,22,23,24,25,\ 19,20,21,22,23,24,26,27,\ 20,21,22,23,25,26,27,28,\ 21,22,23,24,26,27,28,30,\ 22,23,24,26,27,28,30,31,\ 23,24,25,27,28,30,31,33" intra=$(echo $intra | sed -e "s/[^0-9,]//g;") inter=$(echo $inter | sed -e "s/[^0-9,]//g;") ffmpeg -i ed-pal-i420-ffvh.avi \ -profile:v 4 \ -pass 1 \ -q:v 2 -maxrate 8700k \ -g 12 -bf 2 -b_strategy 2 \ -dc 10 \ -brd_scale 2 \ -intra_matrix ${intra} \ -inter_matrix ${inter} \ -an \ -aspect 16/9 -threads 4 \ -f mpeg2video \ /dev/null -y ffmpeg -i ed-pal-i420-ffvh.avi \ -profile:v 4 \ -pass 2 \ -b:v 4800k -maxrate 8700k \ -g 12 -bf 2 \ -qcomp 0.7 -qblur 0 \ -qmin 1 -qmax 31 -dc 10 \ -lmin 0.75 -mblmin 50 \ -sc_threshold 0 -sc_factor 4 \ -me_method dia -dia_size 5 -pre_dia_size 5 -preme 2 -bidir_refine 4 \ -mbd rd -cmp satd -subcmp satd -mbcmp satd -precmp satd -skipcmp satd \ -intra_matrix ${intra} \ -inter_matrix ${inter} \ -an \ -aspect 16/9 -threads 4 \ -f mpeg2video \ ed-pal_ffm50mpeg-lqs-fishman.m2v -y Code:
encoder library version max min avg. ssim 0.24 bitrate, bitrate, bitrate, kbps kbps kbps ================================================================================ cce sp3 cceserver2 1.0.1.4 9434 159 4779 92,65 hcenc hcenc 0.25 9181 118 4788 92,55 mencoder libavcodec 52.72.2 9048 118 4797 92,97 mencoder libavcodec 54.23.100 9390 118 4796 92,98 ffmpeg libavcodec 56.60.100 9018 167 4792 92,67 ffmpeg libavcodec 56.60.100 9252 167 4786 93,59 (fishman config) mencoder libavcodec 57.25.100 9472 167 3516 91,83 |
![]() |
![]() |
![]() |
Tags |
cce, ffmpeg, hcenc, libavcodec, rate control |
Thread Tools | Search this Thread |
Display Modes | |
|
|