Log in

View Full Version : Question for pro or the coder of x264


lutinor
19th April 2011, 00:12
Hi all,

I'm testing a lot x264cli cause it's a very powerful tool.

I'm encountering a very strange issue. If i use the preset slow/veryslow i get 'lag' movie when in multiplex in Netblender dostudio which use Corel hd multiplexer. If i use any other preset (fast, faster, medium, etc..) all is fine. 1pass encoding or 2 pass is not a part of the problem, i tested it.

Question : How slower/veryslow impact the media contruction, it changes what and where ? Or is it a bug ? Adobe encore seem to 'accept' all preset media but maybe it's a more tolerant tool i dunno :confused:

Here's my cli line btw :

x264 --bitrate 1100 --vf resize:width=1280,height=720,sar=1:1,method=lanczos --pass 1 --fps 24000/1001 --preset slow --force-cfr --tune animation --bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 24 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 -o slow.264 ep1.mkv

Blue_MiSfit
19th April 2011, 03:00
Hi lutinor,

Straight from x264.exe --fullhelp: Here are the features enabled when moving from "medium" to "slow"


- slow:
--b-adapt 2 --direct auto --me umh
--rc-lookahead 50 --ref 5 --subme 8


I'm not sure which of these would cause an issue

lutinor
19th April 2011, 04:33
Hi lutinor,

Straight from x264.exe --fullhelp: Here are the features enabled when moving from "medium" to "slow"


- slow:
--b-adapt 2 --direct auto --me umh
--rc-lookahead 50 --ref 5 --subme 8


I'm not sure which of these would cause an issue
Here's the definition of each part, what do you suggest ? i'm a bit confused this time :confused:

b-adapt

Default: 1

Set the adaptive B-frame placement decision algorithm. This setting controls how x264 decides between placing a P- or B-frame.

0. Disabled. Pick B-frames always. This is the same as what the older no-b-adapt setting did.

1. 'Fast' algorithm, faster, speed slightly increases with higher --b-frames setting. When using this mode, you basically always want to use --bframes 16.

2. 'Optimal' algorithm, slower, speed significantly decreases with higher --b-frames setting.

Note: For a multi-pass encode, this option is only needed for the first pass where frame types are decided.

direct

Default: 'spatial'

Set prediction mode for 'direct' motion vectors. There are two modes available: spatial and temporal. You can also select none to disable direct MVs, and auto to allow x264 to swap between them as it sees fit. If you set auto, x264 outputs information on the usage at the end of the encode. 'auto' works best in a 2pass encode, but will work in single-pass encodes too. In first-pass auto mode, x264 keeps a running average of how well each method has so far performed, and picks the next prediction mode from that. Note that you should only enable auto on the second pass if it was enabled on the first pass; if it wasn't, the second pass will default to temporal. Direct none wastes bits and is strongly discouraged.

Recommendation: 'auto'


me

Default: 'hex'

Set the full-pixel motion estimation method. There are five choices:

dia (diamond) is the simplest search, consisting of starting at the best predictor, checking the motion vectors at one pixel upwards, left, down, and to the right, picking the best, and repeating the process until it no longer finds any better motion vector.
hex (hexagon) consists of a similar strategy, except it uses a range-2 search of 6 surrounding points, thus the name. It is considerably more efficient than dia and hardly any slower, and therefore makes a good choice for general-use encoding.
umh (uneven multi-hex) is considerably slower than hex, but searches a complex multi-hexagon pattern in order to avoid missing harder-to-find motion vectors. Unlike hex and dia, the merange parameter directly controls umh's search radius, allowing one to increase or decrease the size of the wide search.
esa (exhaustive) is a highly optimized intelligent search of the entire motion search space within merange of the best predictor. It is mathematically equivalent to the bruteforce method of searching every single motion vector in that area, though faster. However, it is still considerably slower than UMH, with not too much benefit, so is not particularly useful for everyday encoding.
tesa (transformed exhaustive) is an algorithm which attempts to approximate the effect of running a Hadamard transform comparison at each motion vector; like exhaustive, but a little bit better and a little bit slower.

rc-lookahead

Default: 40

Sets the number of frames to use for mb-tree ratecontrol and vbv-lookahead. The maximum allowed value is 250.

For the mb-tree portion of this, increasing the frame count generates better results but is also slower. The maximum buffer value used by mb-tree is the MIN( rc-lookahead, --keyint )

For the vbv-lookahead portion of this, increasing the frame count generates better stability and accuracy when using vbv. The maximum value used by vbv-lookahead is:
MIN(rc-lookahead, MAX(--keyint, MAX(--vbv-maxrate, --bitrate) / --vbv-bufsize * --fps))

ref

Default: 3

Controls the size of the DPB (Decoded Picture Buffer). The range is from 0-16. In short, this value is the number of previous frames each P-frame can use as references. (B-frames can use one or two fewer, depending on if they are used as references or not.) The minimum number of refs that can be referenced is 1.

Also note that the H.264 spec limits DPB size for each level. If adhering to Level 4.1 specs, the maximum refs for 720p and 1080p video are 9 and 4 respectively. You can read more about levels and 4.1 in particular under --level.

subme

Default: 7

Set the subpixel estimation complexity. Higher numbers are better. Levels 1-5 simply control the subpixel refinement strength. Level 6 enables RDO for mode decision, and level 8 enables RDO for motion vectors and intra prediction modes. RDO levels are significantly slower than the previous levels.

Using a value less than 2 will enable a faster, and lower quality lookahead mode, as well as cause poorer --scenecut decisions to be made, and thus it is not recommended.

Possible Values:

0. fullpel only
1. QPel SAD 1 iteration
2. QPel SATD 2 iterations
3. HPel on MB then QPel
4. Always QPel
5. Multi QPel + bi-directional motion estimation
6. RD on I/P frames
7. RD on all frames
8. RD refinement on I/P frames
9. RD refinement on all frames
10. QP-RD (requires --trellis=2, --aq-mode > 0)

Recommendation: Default, or higher, unless speed is very important.

Blue_MiSfit
19th April 2011, 08:04
This doesn't seem logical. What do you mean by a "lag" movie?

Try using --preset medium (defaults), but doing a bunch of test encodes, one with each of the additions in --preset slow.

Example (abbreviated)

Encode 1:
--preset medium --b-adapt 2

Encode 2:
--preset medium --direct auto

Encode 3:
--preset medium --ref 5

etc...

Derek

lutinor
19th April 2011, 09:27
This doesn't seem logical. What do you mean by a "lag" movie?

Try using --preset medium (defaults), but doing a bunch of test encodes, one with each of the additions in --preset slow.

Example (abbreviated)

Encode 1:
--preset medium --b-adapt 2

Encode 2:
--preset medium --direct auto

Encode 3:
--preset medium --ref 5

etc...

Derek
That's what i thought but i already seen something wrong in the preset.

Veryslow/slower/placebo are suposed to be blueray compliant but how can they compliant cause they have more than REF=6 ? If you use these settings you direct lose the compliant bd

I will post my test asap

mp3dom
19th April 2011, 10:02
bluray compat is executed at the end, this mean that while preset veryslow/placebo etc, allows for more than 6 refs, the bluray compat at the end will limit the value to a max of 6 ref.
What also I don't understand is what's your final goal. You're using professional tools (DSA) to made (presumably) professional replicated disc (CMF output) but you're using absurdly low bitrates at 'internet streaming' level. 1.1 Mbps average with a max allowed of 40 Mbps is very unbalanced.

lutinor
19th April 2011, 10:33
bluray compat is executed at the end, this mean that while preset veryslow/placebo etc, allows for more than 6 refs, the bluray compat at the end will limit the value to a max of 6 ref.
What also I don't understand is what's your final goal. You're using professional tools (DSA) to made (presumably) professional replicated disc (CMF output) but you're using absurdly low bitrates at 'internet streaming' level. 1.1 Mbps average with a max allowed of 40 Mbps is very unbalanced.
No, i have 2 goals , one is professional where i can use cinevision with high bitrate and personnal video collection at my home which is different.

I have the guilty option, it's --b-adapt 2 in medium preset it set to 1 and when i put 1 all become ok

About balancing, what do you suggest ? This :

--vbv-bufsize 15000 --vbv-maxrate 30000

If you think this is better , what that will change in the final media ?

mp3dom
19th April 2011, 11:04
I would change to L4.0, 1 slice only and an average bitrate of at least 5 Mbps.
I doubt that b-adapt could create problems, it let x264 to have better decision on bframes. I cannot understand well your problem, but sounds similar to a refreshing or trailing problem.

Sagittaire
19th April 2011, 12:16
it's certainely ref the problem ... change for ref=3 ...

Blue_MiSfit
22nd April 2011, 01:37
--bluray-compat should force ref=3 though... right?

Derek

Sagittaire
22nd April 2011, 09:48
--bluray-compat should force ref=3 though... right?

Derek

Not for 720p ... IMO more than 3 ref is not really usefull in most case.

shon3i
22nd April 2011, 10:38
Can use max of 6 which allowed by BD specs for 720p, so no problem along is not more than 6. Here is problem using completely no-sense settings like --vbv-maxrate 40000 --vbv-bufsize 30000 when target bitrate is 1000kbps.

hopstiii
22nd April 2011, 11:05
Nope

Blu-Ray Standard High@L4.1
1280x720: 9 ref frames
1920x1080 4 ref frames

16 B frames OK

Tested and working
---------------------------------------
--b-pyramid normal IS NOT OK
--b-pyramid none / strict IS OK

shon3i
22nd April 2011, 11:10
Nope

Blu-Ray Standard High@L4.1
1280x720: 9 ref frames
1920x1080 4 ref frames

16 B frames OK

Tested and working
---------------------------------------
--b-pyramid normal IS NOT OK
--b-pyramid none / strict IS OK
lol, did you have Blu-Ray specification and read it? obviously not, so please leave us, what is work for you on your unrestricted player, has no mean nothing

hopstiii
22nd April 2011, 11:21
lol, did you have Blu-Ray specification and read it? obviously not, so please leave us, what is work for you on your unrestricted player, has no mean nothing

I read from WikiPedia High L4.1 is Blu-Ray Standard.
Was that wrong? :rolleyes:

shon3i
22nd April 2011, 11:33
It's wrong that L4.1 on Blu-Ray is not same as H264/AVC L4.1, it have more restrictions.

read here.
http://forum.doom9.org/showthread.php?t=154533

lutinor
22nd April 2011, 12:04
Can use max of 6 which allowed by BD specs for 720p, so no problem along is not more than 6. Here is problem using completely no-sense settings like --vbv-maxrate 40000 --vbv-bufsize 30000 when target bitrate is 1000kbps.

Can i ask you the best target option ? :) Something like max 15000,vbv 10000 ? Aren't we forced to focus on some compliant setting ?

shon3i
22nd April 2011, 12:48
Can i ask you the best target option ? :) Something like max 15000,vbv 10000 ? Aren't we forced to focus on some compliant setting ?
Anything less or equal to --vbv-maxrate 40000 --vbv-bufsize 30000 is compliant. And never is good idea to use maximum possible settings, and leave room for possible errors. In this case i would use something like --vbv-maxrate 5000 --vbv-bufsize 5000, level 4.0, no slices, ref4.

lutinor
22nd April 2011, 13:38
Anything less or equal to --vbv-maxrate 40000 --vbv-bufsize 30000 is compliant. And never is good idea to use maximum possible settings, and leave room for possible errors. In this case i would use something like --vbv-maxrate 5000 --vbv-bufsize 5000, level 4.0, no slices, ref4.

I take good notice from your tips but : slices = 0 ? On the compliant list it said at least 1 (on the pinned topic)

hopstiii
22nd April 2011, 13:41
Isn't there Blu-Ray progressive 1920x1080 ~30 and 60 fps.
I personally wouldn't buy anything that's interlaced if i have the choice.

I also wouldn't buy any camera that makes interlaced video.

If i would be making product to sell i wouldn't make it interlaced because it looks ugly.

Sagittaire
22nd April 2011, 14:03
Can use max of 6 which allowed by BD specs for 720p, so no problem along is not more than 6. Here is problem using completely no-sense settings like --vbv-maxrate 40000 --vbv-bufsize 30000 when target bitrate is 1000kbps.

Here I think that restrictions come from multiplexer (Netblender dostudio which use Corel hd multiplexer). Cerainely 4 ref for 1080p and 720p for test compliance multiplexer ...

Lutinor say that with exactly same command line stream is ok with normal preset but not with slow ... and change between preset for structural video stream is only for ref number ...

--vbv-maxrate 40000 --vbv-bufsize 30000 are completely legal setting for 720p (even it's that sound like unrestricted RC). Anyway with 720p at 1000 kbps, gop at 2 sec with --vbv-maxrate 10000 --vbv-bufsize 10000 (sound like unrestricted RC too with average at 1000 kbps) will be really better for quality and multiplexing possibility.


Try that for max compatibilty ...

x264 --bitrate 1100 --vf resize:width=1280,height=720,sar=1:1,method=lanczos --pass 1 --fps 24000/1001 --preset slow --ref 3 --force-cfr --tune animation --bluray-compat --vbv-maxrate 10000 --vbv-bufsize 10000 --level 4.1 --keyint 24 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 -o slow.264 ep1.mkv


Try that for max quality ...

x264 --bitrate 1100 --vf resize:width=1280,height=720,sar=1:1,method=lanczos --pass 1 --fps 24000/1001 --preset slow --ref 3 --force-cfr --tune animation --bluray-compat --vbv-maxrate 10000 --vbv-bufsize 10000 --level 4.0 --keyint 48 --open-gop --slices 1 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 -o slow.264 ep1.mkv

mp3dom
22nd April 2011, 14:47
I take good notice from your tips but : slices = 0 ? On the compliant list it said at least 1 (on the pinned topic)

No slices means 1 slice

lutinor
22nd April 2011, 14:53
No slices means 1 slice
My bad too much difference about your knowledge and mine (but i'm learning ^^)

ps: merci sagittaire , francophone en force lol