我使用mencoder调用x264编码一个psp用的视频:
x264+aac in mp4 (我修改过的,原作者的不能使用)
mencoder test_video.vob -oac lavc -lavcopts acodec=libfaac:abitrate=94 -ovc x264 -x264encopts
\
cabac=1:ref=1:deblock=1,0,0:analyse=0x1,0x111:me=hex:subme=6:psy_rd=1.0,0.0:mixed_refs=0:me_range=32:chroma_me=1:trellis=1:8x\
8dct=0:no-chroma-me=0:chroma_qp_offset=-\
2:nr=0:dct_decimate=1:bframes=3:b_pyramid=0:b_adapt=1:b_bias=0:direct=3:keyint=250:keyint_min=25:scenecut=40:qp=18:bitrate=80\
0 -lavdopts er=2 -of lavf -lavfopts format=mp4 -vf scale=720:480 -o men.mp4
对应的ffmpeg编码参数是:
ffmpeg
ffmpeg -i inputfile.avi -f psp -acodec libfaac -ab 94k -vcodec libx264 -cqp 28 -coder 1 -refs 3 -deblockalpha 1 -deblockbeta -1 -me_method umh -subq 9 -me_range 32 -trellis 2 -chromaoffset -2 -nr 0 -bf 2 -b_strategy 1 -bframebias 0 -directpred 3 -g 250 -i_qfactor 1.3 -b_qfactor 1.4 -flags2 +bpyramid+wpred+mixed_refs+8x8dct -er 2 -s 480x320
需要注意的是,flags2里面那块,似乎要按照一定顺序才能正常工作,其他地方都差不多,详细情况可以从下面两篇文章得出:
第一篇是这个在网上被传了很多,但有些问题的对照表格,我修改了有问题的部分:
FFmpeg option | x264 option |
---|---|
-g <frames> | –keyint |
-b <bits per second> | –bitrate |
-bufsize <bits> | –vbv-bufsize |
-maxrate <bits> | –vbv-maxrate |
-pass <1,2,3> | –pass |
-crf <float> | –crf |
-cqp <int> | –qp |
-bf <int> | –bframes |
-coder <0,1> | –no-cabac |
-bframebias <int> | –b-bias |
-keyint_min <int> | –min-keyint |
-sc_threshold <int> | –scenecut |
-deblockalpha <int>-deblockbeta <int> | –deblock |
-qmin <int> | –qpmin |
-qmax <int> | –qpmax |
-qdiff <int> | –qpstep |
-qcomp <float> | –qcomp |
-qblur <float> | –qblur |
-complexityblur <float> | –cplxblur |
-refs <int> | –ref |
-directpred <int> | –direct |
-me_method <epzs,hex,umh,full> | –me |
-me_range <int> | –merange |
-subq <int> | –subme |
-bidir_refine <0,1> | –bime |
-trellis <0,1,2> | –trellis |
-nr <int> | –nr |
-level <int> | –level |
-bt <bits> | –ratetol = -bt / -b |
-rc_init_occupancy <bits> | –vbv-init = -rc_init_occupancy / -bufsize |
-i_qfactor <float> | –ipratio = 1 / -i_qfactor |
-b_qfactor <float> | –pbratio |
-chromaoffset <int> | –chroma-qp-offset |
-rc_eq <string> | –rc_eq |
-threads <int> | –threads |
-cmp <-chroma/+chroma> | –no-chroma-me |
-partitions | –partitions |
+parti8×8 | i8×8 |
+parti4×4 | i4×4 |
+partp8×8 | p8×8 |
+partp4×4 | p4×4 |
+partb8×8 | b8×8 |
-flags | |
-loop/+loop | –no-deblock/–deblock |
-psnr/+psnr | –no-psnr/nothing |
-flags2 | |
+bpyramid | –b-pyramid |
+wpred | –weightb |
+brdo | –b-rdo 我这里的ffmpeg已经不能用这个了 |
+mixed_refs | –mixed-refs |
+dct8×8 | –8×8dct |
-fastpskip/+fastpskip | –no-fast-pskip |
+aud | –aud |