View Full Version : x264 zones parameter
sirt
28th April 2012, 12:06
Hi everybody,
I have a question about x264 zones parameters ; let's say I encode like this :
--preset placebo --tune film --zones 100,200,b=6000 --zones 400,500,crf=10
Does that mean placebo's settings will be applied on the whole video EXCEPTED on frames 100 to 200 and 400 to 500 where respectively a bitrate of 6000 and crf 10 will be applied ? If not can you tell me exactly what will happen with above comand line and how could I apply a bitrate of 600 on [100,200] and crf 10 on [400,500] ?
DeeGee
28th April 2012, 12:26
Presets don't set the bitrate used. In your example rest of the video would have the default (crf 23 I think) bitrate setting and the zones would have the settings you set. All of the video would have the same preset and tune settings.
And I'm not sure if several separate --zones inputs work. according to the documentation your example should have been --zones 100,200,b=6000/400,500,crf=10
sirt
28th April 2012, 13:02
Thanks for your answer, but if I set it like that : --preset placebo --tune film --zones 100,200,b=6000/400,500,crf=10
I get an error :
x264 [error]: invalid zone param: 0 = (null)
x264 [error]: failed to parse zones
x264 [error]: x264_encoder_open failed
My comand line works but as you said we are not sure if several zones will work ; what do you think ?
the_weirdo
28th April 2012, 13:08
Options in --zones will override user and default settings for those zones.
According to x264 --fullhelp (or here (http://mewiki.project357.com/wiki/X264_Settings#zones)):
--zones <zone0>/<zone1>/... Tweak the options of regions of the video
Each zone is of the form
<start frame>,<end frame>,<options>
where <options> is a comma separated list
either q=<integer> (force QP)
or b=<float> (bitrate multiplier)
can only be used as the first option
So b=6000 doesn't set bitrate of 6000 but normal bitrate * 6000 :eek:. You can't set a specific bitrate per zone. You can set crf per zone though. However, b or q must be the first option, for example:
--preset placebo --tune film --zones 400,500,b=1,crf=10
sirt
28th April 2012, 13:15
Okay then would be that line correct : --preset placebo --tune film --zones 100,200,crf=8 --zones 400,500,b=1,crf=10 i.e will [100,200] and [400,500] be encoded with cr8 and b=1,crf=10 respectivly ? If I set it like I said the encoding process takes place but I ignore if it really does what I expect.
the_weirdo
28th April 2012, 13:17
Okay then would be that line correct : --preset placebo --tune film --zones 100,200,crf=8 --zones 400,500,b=1,crf=10 i.e will [100,200] and [400,500] be encoded with cr8 and b=1,crf=10 respectivly ? If I set it like I said the encoding process takes place but I ignore if it really does what I expect.
No, it should be like this:
--preset placebo --tune film --zones 100,200,b=1,crf=8/400,500,b=1,crf=10
sirt
28th April 2012, 13:44
Your code works.
I was playing around and tried this :
--preset placebo --tune film --zones 908,1006,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/1635,1753,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/2616,3296,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/3509,3977,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/6109,7020,b=1,crf=6 --bitrate 1000 --pass 1
--preset placebo --tune film --zones 908,1006,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/1635,1753,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/2616,3296,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/3509,3977,b=1,crf=8,deblock=0,0,psy-rd=0.8,0.15/6109,7020,b=1,crf=6 --bitrate 1000 --pass 2
But I still get same crash error ; changing "," to ":" while using deblock and psy-rd options doesn't work either ; it seems I should use "," anyway but I don't understand why the crash occurs.
the_weirdo
28th April 2012, 14:07
For both deblock and psy-rd options, ":" must be used instead of ",". However, I don't know why it doesn't work in your case.
sirt
28th April 2012, 14:40
I am using last x264 32 8bit version from x264.nl ; does my comand line works for you then ?
kemuri-_9
28th April 2012, 15:31
You can't set a specific bitrate per zone. You can set crf per zone though. However, b or q must be the first option, for example:
This is incorrect, It's not that "b or q MUST be specified", it's "If b or q are specified, they MUST be first"
e.g.
--zones 400,500,crf=10 works just fine.
refer to http://mewiki.project357.com/wiki/X264_Settings#zones for proper syntax of zone options.
sirt
28th April 2012, 17:44
Well it doesn't work with ":" ; moreover, any process has ever worked with "," ; I always use --deblock -2,-2 as an example and not --deblock -2:-2, same with psy-rd. Is it normal ?
Furthermore, I still haven't found what is wrong on my comand line above, any suggestion ? I tried reemplace "/" by ";" and the encode starts but I don't know if the zone parameter works. If would be easier if I could simply set several zones such as in my first comand line as the one at the top but none of you seem to know if that is possible or not.
kemuri-_9
28th April 2012, 18:07
zone handling is as such
tokenized by / to identify unique zones
check for start and frames and if b= or q= are specified
tokenize the remaining string by ,
arguments are split on the = to identify parameter names and values
name-value pairs are parsed using the standard parsing system.
your command line doesn't work (e.g. errors with):
x264 [error]: invalid zone param: 0 = (null)
x264 [error]: failed to parse zones
x264 [error]: x264_encoder_open failed
because you are using , to separate deblock and psy-rd option values. you must use : as indicated in the mediawiki.
the correct format of what you're doing is
--zones 908,1006,crf=8,deblock=0:0,psy-rd=0.8:0.15/1635,1753,crf=8,deblock=0:0,psy-rd=0.8:0.15/2616,3296,crf=8,deblock=0:0,psy-rd=0.8:0.15/3509,3977,crf=8,deblock=0:0,psy-rd=0.8:0.15/6109,7020,crf=6
which works fine here.
If it continues to crash, provide more information about your build, such as version information and where you got it from.
If would be easier if I could simply set several zones such as in my first comand line as the one at the top but none of you seem to know if that is possible or not.
It doesn't, x264 only uses the last one specified on the commandline
sirt
28th April 2012, 18:55
Thanks, I've tried your line like this :
--preset placebo --tune film --zones 908,1006,crf=8,deblock=0:0,psy-rd=0.8:0.15/1635,1753,crf=8,deblock=0:0,psy-rd=0.8:0.15/2616,3296,crf=8,deblock=0:0,psy-rd=0.8:0.15/3509,3977,crf=8,deblock=0:0,psy-rd=0.8:0.15/6109,7020,crf=6 --bitrate 1000 --pass 1
--preset placebo --tune film --zones 908,1006,crf=8,deblock=0:0,psy-rd=0.8:0.15/1635,1753,crf=8,deblock=0:0,psy-rd=0.8:0.15/2616,3296,crf=8,deblock=0:0,psy-rd=0.8:0.15/3509,3977,crf=8,deblock=0:0,psy-rd=0.8:0.15/6109,7020,crf=6 --bitrate 1000 --pass 2
and I get :
ffms [error]: could not create index
lavf [error]: could not open input file
raw [error]: raw input requires a resolution.
x264 [error]: could not open input file `0,psy-rd=0.8:0.15/1635,1753,crf=8,deblock=0:0,psy-rd=0.8:0.15/2616,3296,crf=8,deblock=0:0,psy-rd=0.8:0.15/3509,3977,crf=8,deblock=0:0,psy-rd=0.8:0.15/6109,7020,crf=6' via any method!
EDIT : if I set it like that it crashes too :
--preset placebo --tune film --zones 908,1006,crf=8,deblock=0,0,psy-rd=0.8,0.15/1635,1753,crf=8,deblock=0,0,psy-rd=0.8,0.15/2616,3296,crf=8,deblock=0,0,psy-rd=0.8,0.15/3509,3977,crf=8,deblock=0,0,psy-rd=0.8,0.15/6109,7020,crf=6 --bitrate 1000 --pass 1
--preset placebo --tune film --zones 908,1006,crf=8,deblock=0,0,psy-rd=0.8,0.15/1635,1753,crf=8,deblock=0,0,psy-rd=0.8,0.15/2616,3296,crf=8,deblock=0,0,psy-rd=0.8,0.15/3509,3977,crf=8,deblock=0,0,psy-rd=0.8,0.15/6109,7020,crf=6 --bitrate 1000 --pass 2
I get :
x264 [info]: using cpu capabilities: MMX2 SSE2Slow SlowCTZ
x264 [error]: invalid zone param: 0 = (null)
x264 [error]: failed to parse zones
x264 [error]: x264_encoder_open failed
I have always used "," instead of ":" and it worked (I am using last x264 from www.x264.nl) so I have no idea what happens.
Here is my bat file :
SET filen=%vid
SET pass1=% --preset placebo --tune film --zones 908,1006,crf=8,deblock=0,0,psy-rd=0.8,0.15/1635,1753,crf=8,deblock=0,0,psy-rd=0.8,0.15/2616,3296,crf=8,deblock=0,0,psy-rd=0.8,0.15/3509,3977,crf=8,deblock=0,0,psy-rd=0.8,0.15/6109,7020,crf=6 --bitrate 1000 --pass 1
SET pass2=% --preset placebo --tune film --zones 908,1006,crf=8,deblock=0,0,psy-rd=0.8,0.15/1635,1753,crf=8,deblock=0,0,psy-rd=0.8,0.15/2616,3296,crf=8,deblock=0,0,psy-rd=0.8,0.15/3509,3977,crf=8,deblock=0,0,psy-rd=0.8,0.15/6109,7020,crf=6 --bitrate 1000 --pass 2
start /b /Low /wait x264.exe --sar 8:9 --stats "%filen%.stats" %pass1% --output "%filen%-1st.mkv" "%filen%.avs" "%filen%.tmp"
start /b /Low /wait x264.exe --sar 8:9 --stats "%filen%.stats" %pass2% --output "%filen%-2nd.mkv" "%filen%.avs"
Pause
sirt
28th April 2012, 20:26
If I delete all deblock and psy-rd lines on the --zones line then everything seem to work fine ; it seems I can't use deblock and psy-rd parameters on that zones line
EDIT : if i set psy-rd=0.8;0.15 and same for deblock everywhere the encode starts, but is that correct ? I'm really confused now because it should work with ":" and it doesn't....
kemuri-_9
28th April 2012, 21:24
your problem looks to be with the batch processor
: have a special connotation when used in conjunction with % in batch.
it looks like your batch also might be a little malformed...
SET filen=%vid
should be
SET filen=%vid%
and i'm not sure what the rogue % are in the
SET pass1=%
SET pass2=%
lines
if you were to echo your %pass1% and %pass2% variables i'm pretty sure you'll seem some issues when using the : for the psy-rd/deblock parameters
Also, x264 exiting with the parse error is not a crash so please stop referring to it as a "crash"
sirt
28th April 2012, 22:41
I've deleted the % afer SET pass1 but I kept %vid and it seems to work...
nibus
29th April 2012, 01:13
This zones tool is handy:
http://minitheatre.org/forum/11-x264h264/85551-zones-tool-for-x264.html
Lets you preview the video and set each zone, then it pieces them all together and copies the command line to the clipboard. You have to register to see the download links
the_weirdo
29th April 2012, 03:19
This is incorrect, It's not that "b or q MUST be specified", it's "If b or q are specified, they MUST be first"
e.g.
--zones 400,500,crf=10 works just fine.
refer to http://mewiki.project357.com/wiki/X264_Settings#zones for proper syntax of zone options.
Oh, I misinterpreted that then. Until now, I've always used zones with b either greater or less than 1 so I didn't even try that.
sirt
29th April 2012, 10:17
Thanks nibus, it looks quite interesting !
There is something that it is still unclear to me : let's say I do this :
--preset placebo --deblock -1:-1 --bitrate 1000 --zones 400,500,deblock=0;0
Does that mean the whole video will be encoded with placebo, -1:-1 and bitrate 1000 EXCEPTED the [400,500] segment where deblock -1 -1 will be remplaced by deblock 0 0 ? Or will both deblocking lines be applied on [400,500] ? I am not sure about that but ły purpus is of course to use specifical settings through the zones parameter ; then if I write --zones 400,500,crf=8 I expect crf to be applied and NOT bitrate 1000 + crf 8 ; if that is not the case, how could I do what I plan ?
nibus
29th April 2012, 13:41
Thanks nibus, it looks quite interesting !
There is something that it is still unclear to me : let's say I do this :
--preset placebo --deblock -1:-1 --bitrate 1000 --zones 400,500,deblock=0;0
Does that mean the whole video will be encoded with placebo, -1:-1 and bitrate 1000 EXCEPTED the [400,500] segment where deblock -1 -1 will be remplaced by deblock 0 0 ? Or will both deblocking lines be applied on [400,500] ? I am not sure about that but ły purpus is of course to use specifical settings through the zones parameter ; then if I write --zones 400,500,crf=8 I expect crf to be applied and NOT bitrate 1000 + crf 8 ; if that is not the case, how could I do what I plan ?
Yes, the whole video would be encoded with those settings at -1:-1 deblock, while frames 400-500 would be encoded with 0:0 instead of -1:-1. With any zone, it's specified settings override those from the rest of the video, but only those settings that are specified. And yes, on your 2nd example that specific zone would be encoded with a CRF of 8, rather than 1000kbps.
sirt
29th April 2012, 17:37
Ok, thank you, it is working now. I guess the configuration of zones parameters is not easy and I don't really know if it worth the try in so far as using CRF for example should help to target the "greatest" bitrate for a specific area of the video. As as said in other threads, I'm chiefly testing the codec and it's possibilities, do you know some page that would give examples of situations where using extra zones configuration would be usefull ?
kypec
30th April 2012, 15:13
I've never needed to play with zones, setting the desired bitrate or constant rate factor is all one needs to get decent output. It's just not worth the effort to
1) look for problematic areas in source manually beforehand
2) experiment with what settings should be changed for that particular zone
3) repeat steps 1+2 because the output has not improved as expected
sirt
30th April 2012, 17:07
I'm not either ; in fact I'm experimenting that's all.
Howhever, I have some videos that include a large amount of melted scenes and fades ; that is the reason for which I wanted to use zones so as to specifically adjust these scenes. What would you recommand for this type of scenes then ?
Asmodian
30th April 2012, 23:23
do you know some page that would give examples of situations where using extra zones configuration would be usefull ?
Zones are good for encoding credits at lower quality to save space for the rest of the video.
Credits are often pretty large given all the movement and edges involved in scrolling text so setting a higher crf for them can help save some space.
And regarding dark areas likely to result in macro blocks, do you think is it a good idea to specify some extra settings trough zones and which one then ? Check the backgrounds from there http://www.ehomeupgrade.com/wp-content/uploads/media/mediablab_hd-dvd_wmv_hd_comparison.jpg, especially the HD-DVD screen. This is what I would like to fight against by setting something with that zones parameter.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.