1

I'm using ffmpeg in x265 and I want to use multiple x265-params in one encoding.

When I use more than one parameter, ffmpeg does not recognize them.

My script is:

ffmpeg -s:v 1440x1080 -r 25 -i incident_10d_1440x1080_25.yuv -c:v rawvideo \
-pix_fmt yuv420p -c:v libx265 -x265-params "--qp=16:--preset=medium:--psnr" \
out_1440x1080_qp16.mp4

I set quantization parameter value equal to 16.

But my output in terminal contains the following:

x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-28.0 / 0.60

As can be seen I get Rate Control / qCompress : CRF-28.0 / 0.60.

The correct one must be x265 [info]: Rate Control : CQP-16.

When I have only this parameter in x265-params like -x265-params "--qp=16" it's working properly.

zinon
  • 4,427
  • 14
  • 70
  • 112

3 Answers3

3

Apply the preset and tune outside:

-preset medium -tune psnr -x265-params "qp=16:rc-lookahead=18"
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • 1
    Unfortunately, still the same. – zinon Nov 20 '17 at 10:49
  • I had also to add psnr outside like '-preset medium -psnr -x265-params "-qp=16" otherwise it's not working! – zinon Nov 20 '17 at 10:51
  • Yes. Both are applied before individual params are parsed. – Gyan Nov 20 '17 at 10:52
  • The problem is that each parameter in -x265-params must have a `key=value` otherwise all the parameters are rejected without any error or warning. – zinon Nov 20 '17 at 10:53
  • Only if that malformed option is at the end. If in the beginning or middle, it will gobble up the next option but the remaining and preceding options get applied. This is a parsing bug. – Gyan Nov 20 '17 at 11:28
3

Just set options which does not require a value to 1. For examples below works for me

ffmpeg.exe -i input.mp4 -c:v libx265 -crf 32 -x265-params constrained-intra=1:intra-refresh=1:ctu=32:ref=1:bframes=0:keyint=150:min-keyint=150:aq-mode=2:aq-strength=1.0:qp-adaptation-range=1.0:no-aq-motion=1:qg-size=16:no-cutree=1 output.mp4

Those 1's for below options will be ignored since they do not take a value

constrained-intra=1
intra-refresh=1
no-aq-motion=1
no-cutree=1
1

ffmpeg uses a "key=value:" structure for all -x265-params passed to libx265, but some x265 parameters have no value.

This means that some parameters are set differently in libx265 compared to the x265 documentation.

--psnr    -> psnr=1
--no-psnr -> psnr=0
--ssim    -> ssim=1
--no-ssim -> ssim=0

I have not tested this with the rest of the x265 parameters which have the structure --no-*, but I assume it applies to all of them, with some exceptions, e.g. --asm, --no-asm, since --asm takes a value and is not a flag.

As you have pointed out: incorrectly including a flag type option within args of -x265-params "{args}" will cause libx265 to reject the entire string defined for -265-params.

mph10
  • 11
  • 2