[FFmpeg-user] copy encoder settings for cycling platform

Moritz Barsnick barsnick at gmx.net
Thu Jun 11 17:16:17 EEST 2020


On Thu, Jun 11, 2020 at 09:33:55 +0200, Bernd Eller wrote:
> I wont upload big files which they reduce from eg. 17GB to 4GB, but i
> dont wont upload it in a lesser quality than they re-code
>
> This mean i want upload it in the same quality or a little bit higher.

As Edward said: If your upload platform recodes the video, and so do
you, you will have two processes involving loss of quality. This is not
recommended.

> I have checked the Encoder Settings of the Platform and want ask if i
> can or how i can simply copy this setting to produce the same quality.

If you just want to reduce your video size while retaining a certain
amount of quality, play with the CRF setting and the presets for
libx264. Make sure you understand the implications of them.

If you want to replicate that encoding, a first good bet might be to
see if those match one of x264's presets, and using that. (Note, CRF
vs. fixed bitrate, 1-pass vs. 2-pass, and so forth, will change the
parameters despite same preset.) Yours looks a bit like preset
"veryslow" with fixed-rate 2-pass encoding and changed GOP sizes.


But in case you or anybody else *really* wants to exactly reproduce
x264's reported encoding settings (for whatever reason), there is a
method. Quoting your video characteristics:

> Encoding settings           : cabac=1 / ref=6 / deblock=1:0:0 /
> analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.00 /
> mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 /
> deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 /
> lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 /
> interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 /
> b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 /
> weightp=2 / keyint=30 / keyint_min=3 / scenecut=40 / intra_refresh=0 /
> rc_lookahead=30 / rc=2pass / mbtree=1 / bitrate=20000 / ratetol=1.0 /
> qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 /
> ip_ratio=1.40 / aq=1:1.00

This output is from Mediainfo. You must understand that this is info
that the original encoder x264 has embedded into the video stream.

As ffmpeg uses x264, and has a lot of liberties, you *can* try to
exactly reproduce these setting. There's an option to the libx264
encoder names "-x264-params", which will pass these parameters directly
to the encoding library.

Unfortunately, the parameters don't match *exactly* (which is libx264's
fault), so you need to do some investigation as well as trial and error
in order to get them right. Also see here:

https://superuser.com/a/1559852/361295

I tried to replicate the "veryslow" prefix, which gives a video with
this info:

  cabac=1 / ref=16 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

This is the command line option I need to use to replicate that. Note
the many discrepancies in the formatting of variables and values!

  -x264-params 'cabac=1:ref=16:deblock=0,0:analyse=all:me=umh:subme=10:psy=1:psy_rd=1.00,0.00:mixed-refs=1:me_range=24:chroma_me=1:trellis=2:8x8dct=1:cqm=flat:deadzone-inter=21:deadzone-intra=11:fast_pskip=1:chroma_qp_offset=0:threads=3:lookahead_threads=1:sliced_threads=0:nr=0:dct-decimate=1:interlaced=0:bluray_compat=0:constrained_intra=0:bframes=8:b_pyramid=2:b_adapt=2:b_bias=0:direct=auto:weightb=1:open_gop=0:weightp=2:keyint=250:keyint_min=25:scenecut=40:intra_refresh=0:rc_lookahead=60:mbtree=1:crf=23.0:qcomp=0.60:qpmin=0:qpmax=69:qpstep=4:ipratio=1.40:aq-mode=1:aq-strength=1.00'

I actually got bit-wise identical videos. Your mileage may vary.

> It would be realy great if somebody spend some time to help me, the
> documentation is so big and i dont really understand all that things,
> but willing to learn.

To learn, just play around with encoder settings a bit, and read about
the H.264 basics here:
https://trac.ffmpeg.org/wiki/Encode/H.264

Cheers,
Moritz


More information about the ffmpeg-user mailing list