x264 CRF custom profile fails


I would like to create a custom profile for the H264 export. When I use x264 I often use Constant Rate Factor because this brings better quality than a variabel Bitrate. But I have no idea where I can include my custom x264 settings to the profile. e.g.

Here I changed only the bitrate to crf=16.

f=mp4 crf=16 hq=1 acodec=aac ab=128k ar=48000 pix_fmt=yuv420p vcodec=libx264 minrate=0 g=250 bf=3 b_strategy=1 subcmp=2 cmp=2 coder=1 flags=+loop flags2=dct8x8 qmax=51 subq=8 qmin=10 qcomp=0.6 qdiff=4 trellis=1 aspect=%dar

And this is what I get (Checked with mediainfo)

cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=umh / subme=8 / psy=1 / psy_rd=1,00:0,20 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / sliced_threads=0 / nr=2 / decimate=1 / mbaff=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / wpredb=1 / wpredp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=16,0 / qcomp=0,60 / qpmin=0 / qpmax=51 / qpstep=4 / ip_ratio=1,40 / aq=1:1,00

But when I enter something like this

f=mp4 crf=16 hq=1 acodec=aac ab=224k ar=48000 pix_fmt=yuv420p vcodec=libx264 minrate=0 g=250 bf=3 b_strategy=1 subcmp=2 cmp=2 coder=1 flags=+loop flags2=dct8x8 deblock=-1:-1 direct_pred=auto frameref=5 b_adapt=2 me=umh chroma_me=1 rc_lookahead=50 mbtree=1 qpmax=51 subq=8 qpmin=10 qcomp=0.6 qdiff=4 trellis=1 aspect=%dar keyint=250 cqm=flat weight_b noglobal_header mixed_refs level_idc=51 partitions=all psy-rd=1:0,15

Here I wanted to change psy-rd, I get something like this (checked with mediainfo)

cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0 / me=dia / subme=8 / psy=0 / mixed_ref=0 / me_range=4 / chroma_me=0 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=0 / threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=tff / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=2 / weightb=0 / open_gop=0 / weightp=0 / keyint=250 / keyint_min=25 / scenecut=0 / intra_refresh=0 / rc=crf / mbtree=0 / crf=16.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.25 / pb_ratio=1.25 / aq=1:1.00

So e.g. deblock=1:0:0 does not accept the setting. According to the x264 manual you are allowed to seperate option with : or |.

Can somebody explain me how to change these settings here, please?


Are you using a v53+ of libavcodec?
If so, are you using v0.7.4+ of mlt that properly supports the new codec-specific options in libavcodec?
If so, perhaps you need to use the new x264opts:

The example on that page converted to mlt_properties syntax is: x264opts=keyint=123:min-keyint=20

Also, in your command you have "weight_b noglobal_header mixed_refs" but those will not be interpreted as mlt properties and hence avoptions. Only name=value is interpreted as a propertyavoption, and if value has a space it must be quoted.

Well thank you very much. After trying a little bit around, I finally got some results. I was able to change some parameters.


My impression is, that crf is actually (and very unfortunately!) not supported by kdenlive yet. Why? Well I used a rendering profile with crf=20 and rendered. Then I changed the profile to crf=18 (leaving everything else unchanged). The filesize of the first rendering should usually be smaller than the rendering of the second file. BUT: It is not! The two files had the exact same filesize! Therefore it seems to me, that kdenlive actually just ignores the crf-option (and at the same time does not put out an error message).

Could perhaps someone confirm this?

It would be also very helpful, if a savvy person could exactly explain, what options are supported and which ones not.

Happy to discuss.

http://www.mltframework.org/bin/view/MLT/ConsumerAvformat, F3 search the page in your browser for crf, you'll find it's an option in MLT's AVFormat consumer.

Your test, was that one file or have you tried various clips with differing rate control and compared, including long clips and those with a lot of motion?

Thank you for your quick help. I realize that it is an option in MLT. But at the end it is obviously still not working. I indeed tested it not with the same file but with the same project.
So: Same project rendered twice with same rendering profile except for changing the crf value. Result: Same output file size.

Could someone try this same scenerario to acknowledge this?

Meanwhile I updated my system from ubuntu 11.10 to 12.04 - and now the crf-option is working!