Log in

View Full Version : x264 zones parameter


mp3dom
4th August 2014, 01:06
Is the "zones" parameter ever working?
I've tried to do an encode with both vbv-enabled (for bluray, so maxrate 39 Mbps and bufsize 30 Mbps) and without vbv. In both cases the encoder seems to ignore the values.

Just as a test, I've tried
--zones 307,376,crf=40
To exaggerate, I'm expecting a really bad quality but, watching the verbose coming from the encoder (and watching the frame too):


x264 [debug]: frame= 295 QP=18.55 NAL=1 Slice:B Poc:590 I:2304 P:4609 SKIP:155 size=175658 bytes
x264 [debug]: frame= 296 QP=18.76 NAL=0 Slice:B Poc:588 I:1714 P:4975 SKIP:191 size=158793 bytes
x264 [debug]: frame= 297 QP=18.17 NAL=2 Slice:P Poc:596 I:3169 P:4840 SKIP:151 size=194054 bytes
x264 [debug]: frame= 298 QP=18.82 NAL=0 Slice:B Poc:594 I:2252 P:4611 SKIP:176 size=171272 bytes
x264 [debug]: frame= 299 QP=17.86 NAL=2 Slice:P Poc:598 I:2792 P:5240 SKIP:128 size=191431 bytes
x264 [debug]: frame= 300 QP=18.17 NAL=2 Slice:P Poc:602 I:2684 P:5362 SKIP:114 size=185220 bytes
x264 [debug]: frame= 301 QP=18.79 NAL=0 Slice:B Poc:600 I:2262 P:4580 SKIP:155 size=172493 bytes
x264 [debug]: frame= 302 QP=18.16 NAL=2 Slice:P Poc:606 I:2601 P:5436 SKIP:123 size=181236 bytes
x264 [debug]: frame= 303 QP=18.73 NAL=0 Slice:B Poc:604 I:2184 P:4634 SKIP:161 size=172674 bytes
x264 [debug]: frame= 304 QP=17.69 NAL=2 Slice:P Poc:610 I:2740 P:5292 SKIP:128 size=193432 bytes
x264 [debug]: frame= 305 QP=18.74 NAL=0 Slice:B Poc:608 I:2214 P:4633 SKIP:175 size=172904 bytes
x264 [debug]: frame= 306 QP=17.84 NAL=2 Slice:P Poc:612 I:2776 P:5284 SKIP:100 size=193061 bytes
x264 [debug]: frame= 307 QP=15.91 NAL=2 Slice:I Poc:614 I:8160 P:0 SKIP:0 size=350921 bytes
x264 [debug]: frame= 308 QP=17.51 NAL=2 Slice:P Poc:618 I:4293 P:3732 SKIP:135 size=231945 bytes
x264 [debug]: frame= 309 QP=18.68 NAL=0 Slice:B Poc:616 I:2189 P:4694 SKIP:167 size=174094 bytes
x264 [debug]: frame= 310 QP=17.53 NAL=2 Slice:P Poc:622 I:3191 P:4833 SKIP:136 size=208331 bytes
x264 [debug]: frame= 311 QP=18.63 NAL=0 Slice:B Poc:620 I:2248 P:4686 SKIP:139 size=176666 bytes
x264 [debug]: frame= 312 QP=17.72 NAL=2 Slice:P Poc:628 I:2878 P:5170 SKIP:112 size=202562 bytes
x264 [debug]: frame= 313 QP=17.22 NAL=1 Slice:B Poc:626 I:2457 P:4251 SKIP:159 size=210791 bytes
x264 [debug]: frame= 314 QP=18.75 NAL=0 Slice:B Poc:624 I:1944 P:4768 SKIP:182 size=167648 bytes
x264 [debug]: frame= 315 QP=17.53 NAL=2 Slice:P Poc:634 I:3278 P:4779 SKIP:103 size=208048 bytes
x264 [debug]: frame= 316 QP=17.21 NAL=1 Slice:B Poc:632 I:2543 P:4206 SKIP:128 size=211340 bytes
x264 [debug]: frame= 317 QP=18.71 NAL=0 Slice:B Poc:630 I:1941 P:4716 SKIP:163 size=171271 bytes
x264 [debug]: frame= 318 QP=17.48 NAL=2 Slice:P Poc:640 I:3269 P:4784 SKIP:107 size=207912 bytes
x264 [debug]: frame= 319 QP=17.00 NAL=1 Slice:B Poc:638 I:2336 P:4299 SKIP:138 size=204238 bytes
x264 [debug]: frame= 320 QP=18.63 NAL=0 Slice:B Poc:636 I:1771 P:4889 SKIP:204 size=159933 bytes
x264 [debug]: frame= 321 QP=17.98 NAL=2 Slice:P Poc:644 I:3254 P:4785 SKIP:121 size=204616 bytes
x264 [debug]: frame= 322 QP=18.60 NAL=0 Slice:B Poc:642 I:2248 P:4649 SKIP:160 size=177371 bytes
x264 [debug]: frame= 323 QP=17.98 NAL=2 Slice:P Poc:648 I:2756 P:5307 SKIP:97 size=190877 bytes
x264 [debug]: frame= 324 QP=18.61 NAL=0 Slice:B Poc:646 I:2310 P:4553 SKIP:121 size=178773 bytes
x264 [debug]: frame= 325 QP=17.59 NAL=2 Slice:P Poc:652 I:2797 P:5277 SKIP:86 size=200419 bytes
x264 [debug]: frame= 326 QP=18.57 NAL=0 Slice:B Poc:650 I:2215 P:4659 SKIP:156 size=176673 bytes
x264 [debug]: frame= 327 QP=17.58 NAL=2 Slice:P Poc:656 I:2775 P:5291 SKIP:94 size=198761 bytes
x264 [debug]: frame= 328 QP=18.56 NAL=0 Slice:B Poc:654 I:2218 P:4600 SKIP:148 size=177035 bytes
x264 [debug]: frame= 329 QP=17.67 NAL=2 Slice:P Poc:658 I:2713 P:5336 SKIP:111 size=196638 bytes
x264 [debug]: frame= 330 QP=15.81 NAL=2 Slice:I Poc:660 I:8160 P:0 SKIP:0 size=356307 bytes
x264 [debug]: frame= 331 QP=17.41 NAL=2 Slice:P Poc:664 I:4412 P:3646 SKIP:102 size=241174 bytes
x264 [debug]: frame= 332 QP=18.51 NAL=0 Slice:B Poc:662 I:2299 P:4590 SKIP:137 size=179756 bytes
x264 [debug]: frame= 333 QP=17.49 NAL=2 Slice:P Poc:670 I:3373 P:4663 SKIP:124 size=215653 bytes
x264 [debug]: frame= 334 QP=18.22 NAL=1 Slice:B Poc:668 I:2381 P:4444 SKIP:165 size=185864 bytes
x264 [debug]: frame= 335 QP=18.57 NAL=0 Slice:B Poc:666 I:1910 P:4808 SKIP:138 size=172906 bytes
x264 [debug]: frame= 336 QP=17.46 NAL=2 Slice:P Poc:676 I:3360 P:4683 SKIP:117 size=215726 bytes
x264 [debug]: frame= 337 QP=18.17 NAL=1 Slice:B Poc:674 I:2331 P:4538 SKIP:149 size=183614 bytes
x264 [debug]: frame= 338 QP=18.54 NAL=0 Slice:B Poc:672 I:1883 P:4852 SKIP:178 size=170076 bytes
x264 [debug]: frame= 339 QP=17.34 NAL=2 Slice:P Poc:682 I:3301 P:4746 SKIP:113 size=213986 bytes
x264 [debug]: frame= 340 QP=18.20 NAL=1 Slice:B Poc:680 I:2438 P:4359 SKIP:162 size=186914 bytes
x264 [debug]: frame= 341 QP=18.39 NAL=0 Slice:B Poc:678 I:1838 P:4820 SKIP:190 size=171438 bytes
x264 [debug]: frame= 342 QP=17.79 NAL=2 Slice:P Poc:686 I:3224 P:4788 SKIP:148 size=203529 bytes
x264 [debug]: frame= 343 QP=18.38 NAL=0 Slice:B Poc:684 I:2253 P:4596 SKIP:174 size=179630 bytes
x264 [debug]: frame= 344 QP=17.79 NAL=2 Slice:P Poc:690 I:2709 P:5329 SKIP:122 size=194097 bytes
x264 [debug]: frame= 345 QP=18.50 NAL=0 Slice:B Poc:688 I:2314 P:4518 SKIP:183 size=182590 bytes
x264 [debug]: frame= 346 QP=17.71 NAL=2 Slice:P Poc:694 I:2760 P:5259 SKIP:141 size=193398 bytes
x264 [debug]: frame= 347 QP=18.44 NAL=0 Slice:B Poc:692 I:2197 P:4654 SKIP:196 size=180646 bytes
x264 [debug]: frame= 348 QP=17.38 NAL=2 Slice:P Poc:698 I:2766 P:5291 SKIP:103 size=203164 bytes
x264 [debug]: frame= 349 QP=18.40 NAL=0 Slice:B Poc:696 I:2236 P:4528 SKIP:199 size=179101 bytes
x264 [debug]: frame= 350 QP=17.76 NAL=2 Slice:P Poc:702 I:2731 P:5284 SKIP:145 size=193138 bytes
x264 [debug]: frame= 351 QP=18.42 NAL=0 Slice:B Poc:700 I:2233 P:4596 SKIP:174 size=181129 bytes
x264 [debug]: frame= 352 QP=17.56 NAL=2 Slice:P Poc:704 I:2768 P:5247 SKIP:145 size=197491 bytes
x264 [debug]: frame= 353 QP=15.58 NAL=2 Slice:I Poc:706 I:8160 P:0 SKIP:0 size=361451 bytes
x264 [debug]: frame= 354 QP=17.18 NAL=2 Slice:P Poc:712 I:4417 P:3566 SKIP:177 size=241865 bytes
x264 [debug]: frame= 355 QP=18.07 NAL=1 Slice:B Poc:710 I:2411 P:4392 SKIP:180 size=187843 bytes
x264 [debug]: frame= 356 QP=18.36 NAL=0 Slice:B Poc:708 I:1920 P:4806 SKIP:172 size=176272 bytes
x264 [debug]: frame= 357 QP=17.42 NAL=2 Slice:P Poc:718 I:3334 P:4734 SKIP:92 size=215789 bytes
x264 [debug]: frame= 358 QP=18.06 NAL=1 Slice:B Poc:716 I:2381 P:4477 SKIP:153 size=190189 bytes
x264 [debug]: frame= 359 QP=18.38 NAL=0 Slice:B Poc:714 I:1924 P:4786 SKIP:170 size=172371 bytes
x264 [debug]: frame= 360 QP=17.30 NAL=2 Slice:P Poc:722 I:3404 P:4657 SKIP:99 size=217686 bytes
x264 [debug]: frame= 361 QP=18.31 NAL=0 Slice:B Poc:720 I:2353 P:4549 SKIP:144 size=185436 bytes
x264 [debug]: frame= 362 QP=17.37 NAL=2 Slice:P Poc:728 I:2948 P:5124 SKIP:88 size=208865 bytes
x264 [debug]: frame= 363 QP=16.86 NAL=1 Slice:B Poc:726 I:2588 P:4176 SKIP:128 size=219463 bytes
x264 [debug]: frame= 364 QP=18.39 NAL=0 Slice:B Poc:724 I:1982 P:4792 SKIP:153 size=175281 bytes
x264 [debug]: frame= 365 QP=17.75 NAL=2 Slice:P Poc:732 I:3379 P:4667 SKIP:114 size=207434 bytes
x264 [debug]: frame= 366 QP=18.28 NAL=0 Slice:B Poc:730 I:2379 P:4576 SKIP:137 size=187657 bytes
x264 [debug]: frame= 367 QP=17.72 NAL=2 Slice:P Poc:736 I:2781 P:5277 SKIP:102 size=194456 bytes
x264 [debug]: frame= 368 QP=18.38 NAL=0 Slice:B Poc:734 I:2266 P:4560 SKIP:151 size=183166 bytes
x264 [debug]: frame= 369 QP=17.46 NAL=2 Slice:P Poc:740 I:2888 P:5165 SKIP:107 size=202805 bytes
x264 [debug]: frame= 370 QP=18.30 NAL=0 Slice:B Poc:738 I:2311 P:4524 SKIP:173 size=182540 bytes
x264 [debug]: frame= 371 QP=17.80 NAL=2 Slice:P Poc:744 I:2685 P:5331 SKIP:144 size=190231 bytes
x264 [debug]: frame= 372 QP=18.35 NAL=0 Slice:B Poc:742 I:2331 P:4548 SKIP:188 size=183520 bytes
x264 [debug]: frame= 373 QP=17.81 NAL=2 Slice:P Poc:748 I:2851 P:5180 SKIP:129 size=192609 bytes
x264 [debug]: frame= 374 QP=18.29 NAL=0 Slice:B Poc:746 I:2208 P:4587 SKIP:197 size=181115 bytes
x264 [debug]: frame= 375 QP=18.14 NAL=2 Slice:P Poc:750 I:2661 P:5351 SKIP:148 size=183544 bytes
x264 [debug]: frame= 376 QP=18.03 NAL=2 Slice:I Poc:752 I:8160 P:0 SKIP:0 size=278549 bytes
x264 [debug]: frame= 377 QP=25.40 NAL=2 Slice:P Poc:754 I:8154 P:6 SKIP:0 size=18868 bytes
x264 [debug]: frame= 378 QP=26.28 NAL=2 Slice:P Poc:756 I:850 P:3504 SKIP:3806 size=9291 bytes
x264 [debug]: frame= 379 QP=9.05 NAL=2 Slice:P Poc:758 I:4724 P:3390 SKIP:46 size=192769 bytes
x264 [debug]: frame= 380 QP=8.74 NAL=2 Slice:P Poc:762 I:4959 P:3131 SKIP:70 size=207430 bytes
x264 [debug]: frame= 381 QP=9.64 NAL=0 Slice:B Poc:760 I:1139 P:4007 SKIP:1944 size=78413 bytes
x264 [debug]: frame= 382 QP=8.58 NAL=2 Slice:P Poc:764 I:4731 P:3321 SKIP:108 size=205899 bytes


As you can see, the zoned frames are in par with all the previous frames (quality-wise). Also frame 377 is actually a new static scene (even if the encoder choose to use a P frame) that continues till the end. Frames 377 and 378 have a general high quantizer compared to 379-380-381-382 and this is clearly visible because those 2 frames are heavily compressed. Again, I've tried to use qpfile, forcing a quantizer of 9 on those two frames (to have similar quality to the next frames) but, again, the encoder seems to ignore it. I'm using the latest komisar build (if this might help).

Full cmd:

--profile high --preset veryslow --tune film --bframes 2 --ref 4 --pass 2 --level 4.1 --slices 4 --bitrate 35000 --vbv-maxrate 39000 --vbv-bufsize 30000 --keyint 24 --deblock 0:0 --bluray-compat --open-gop --merange 36 --colorprim bt709 --transfer bt709 --colormatrix bt709 --threads 8 --zones 307,376,crf=40 --sar 1:1 --verbose

fionag
4th August 2014, 01:44
Zones can't change ratecontrol modes in the middle of an encode; you're using bitrate mode, so you can't switch to CRF for a section of the encode. You can apply a bitrate weight though, I think (I don't remember the syntax for this though).

mp3dom
4th August 2014, 03:16
I've tried "Q" and "B" too (which sets respectively a constant quantizer or a bitrate multiplier).
for example

--zones 307,376,b=0.1

In all cases, the result is almost the same. It seems that my attempt to force the bitrate/quantizer is ignored during the encode process.

poisondeathray
4th August 2014, 04:15
Did you have the zones specified in the 1st pass? I did some quick (non BD) 1pass CRF tests and it works ok

mp3dom
4th August 2014, 08:34
Yes, I've setup the zone (the same, copy/pasted) on both passes.

Edit: I'm investigating, because sometimes it appears to abide the forced quantizer.

Edit2: Ok, it seems to work. VBV take precedence over quantizer/bitrate override so it doesn't lower q/b at adjacent GOPs (to conform to both VBV and override) but it simply ignore it. Also (and this was my mistake) when using seek+frames parameters (to start the encoder at a different place) the frames specified in the zone doesn't correspond anymore (at least it seems to me). Is this confirmed?

poisondeathray
4th August 2014, 15:33
I did some more tests with VBV and BD parameters 2pass and it seems to work ok

But I didn't test the results of --seek or --frames . But wouldn't it make sense that the frame reference numbers change? Effectively it becomes a different video as if you had cut it with something else (e.g. Trim() in avisynth) , so shouldn't the zone numbers change ?

mp3dom
4th August 2014, 16:06
I've tried to change QP of frames 377/378 due to high distorted output (QP>25, it starts a new scene so it's very visible). Changing only those 2 frames produces no visible alteration (probably due to the fact that the previous scene is indeed very hard so probably the bitrate was maximized to vbv). Lowering 353 to 376 (previous GOP) with b=0.7 and forcing 377/378 with QP=9 worked as expected.

Regarding the seek/frames and zones... I think it should work (imho) in a small different way. Let me explain: if I want to trim (and nothing more) I can do that via AviSynth or other ways around (for example a different export). Seek+frames should also be very useful for debug purposes. For example to test zones very far from the beginning of a movie. If I want to "zone" frame 100.000 and see the results, I simply can't encode the whole film (hours+hours of encode and for more tests the hours increase even more) so it can be very useful to start at frame 98.000 and then encode 3.000 frames to see the results. This allows to keep the zones/qpfile intact (as a reference, it's the whole film). Basically the encoder should consider that the starting frame is not 0 but 98.000 and then should apply the zones/qpfile accordingly... at least I think this would be more useful. In this way it can be simply used in both ways (simple trim and debug).

poisondeathray
4th August 2014, 16:14
Regarding the seek/frames and zones... I think it should work (imho) in a small different way. Let me explain: if I want to trim (and nothing more) I can do that via AviSynth or other ways around (for example a different export). Seek+frames should also be very useful for debug purposes. For example to test zones very far from the beginning of a movie. If I want to "zone" frame 100.000 and see the results, I simply can't encode the whole film (hours+hours of encode and for more tests the hours increase even more) so it can be very useful to start at frame 98.000 and then encode 3.000 frames to see the results. This allows to keep the zones/qpfile intact (as a reference, it's the whole film). Basically the encoder should consider that the starting frame is not 0 but 98.000 and then should apply the zones/qpfile accordingly... at least I think this would be more useful. In this way it can be simply used in both ways (simple trim and debug).


I can see how that would be useful in those situations, maybe you should make a feature request

But I can see other complexities, like VBV issues, current buffer level, where if you don't at least start the test encode from way back, you'll get slightly different results than if you did the whole film - that may limit it's usefulness somewhat

cretindesalpes
4th August 2014, 18:12
I wrote a tool to help with seek and zones/qpfile:
http://forum.doom9.org/showthread.php?t=168825

mp3dom
4th August 2014, 18:40
Uh, thanks cretindesalpes! I'll put a look at it!
Thanks also to all the contributors of this thread