Log in

View Full Version : x264 development: Lookahead VBV


Dark Shikari
17th August 2009, 20:49
In the spirit of the Macroblock Tree thread, I figure I'll continue these announcements with regard to extremely major improvements to x264 so that people know how things have changed.

http://i31.tinypic.com/10gljk5.png

VBV lookahead (http://git.videolan.org/?p=x264.git;a=commit;h=1b6086ceb0c346c959a68478b9c36284fbdd5872)

What does it do?

Read the commit message!

Lookahead VBV

Use the large-scale lookahead capability introduced in MB-tree for ratecontrol purposes.

(Does not require MB-tree, however.)

Greatly improved quality and compliance in 1-pass VBV mode, especially in CBR; +2db OPSNR or more in some cases.

Fix some other bugs in VBV, which should improve non-lookahead mode as well.

Change the tolerance algorithm in row VBV to allow for more significant mispredictions when buffer is nearly full.

Note that due to the fixing of an extremely long-standing bug (>1 year), bitrates may change by nontrivial amounts in CRF without MB-tree.

How does this change things?

CRF + VBV will now probably work Just Great™ in almost all situations. In fact, it'll even work when the VBV restrictions are absurd; for example, CRF 18 + maxrate/bufsize 250 works despite the fact that CRF 18 will almost always demand a higher bitrate than that. To quote dynaflash, previously, x264 would "underflow and fall on its face".

1-pass VBV in general is now a much better option, which should greatly improve quality when doing live streaming video. Two pass should still give better results in the case of heavy restrictions, particularly CBR, because it can work off the actual bit costs instead of estimated bit costs, but the difference should be significantly smaller.

Even the non-lookahead case should improve a good bit as well, due to bugs found and fixed during the development of VBV lookahead.

Since no other open source encoder that I know of has a VBV lookahead, this probably makes x264 the most reliable free software application for live video streaming.

Will it always work perfectly?

Of course not. Due to the fact that lookahead uses approximate costs (SATD) instead of exact bit cost data, it isn't perfect (nothing is); it's just a billion times better than it used to be.

What's the speed cost?

Near-zero without MB-tree, small (a % or two) with MB-tree.

Anyone to thank for this?

Other than me (and akupenguin for the usual patch reviewing), Avail Media (http://availmedia.com/), the world's largest provider of x264-encoded broadcast video, sponsored the creation of this feature. :cool:

Anything else coming in the next few weeks?

Explicit weighted prediction (weightp) and threaded lookahead are both coming Soon™.

Chengbin
17th August 2009, 21:06
Thank you SOOOO much for these updates! They're just what we needed.

I wish there is a thanks button next to the quote button (like in Math Help Forum). But then truthfully we can't thank you enough for your commitment to x264.

BTW, I love the picture. Very smart.

Sagekilla
17th August 2009, 21:10
Kudos Dark for all the awesome commits this summer :) Also, these public development threads are good, keep them up.

Now only thing left is to make x264 some sort of AI to optimally code any video (But then we'd have to be worrying about it taking over the world).

poisondeathray
17th August 2009, 21:22
Nice work!

Any scenarios where CRF+VBV might fail?

Any specific testing or feedback required? or is this pretty much a "bulletproof" commit?

Selur
17th August 2009, 22:27
Sounds nice :) Thanks especially to Avail for the sponsoring. (+ thanks to the workers ;))

CruNcher
17th August 2009, 22:55
Slowly Ateme should be frightened if this Broadcast optimization continues so rapidly ;) guess we gonna see Avails x264 Commercial Broadcast solution going live soon ;)

Chengbin
18th August 2009, 00:13
Just saw the edit.

Really looking forward for those!

One thing, unless improving x264 is your day job, which clearly is not, I find it magical how you can write all this code for us, and be online on Doom9 for hours a day?

ChronoCross
18th August 2009, 01:56
Just saw the edit.

Really looking forward for those!

One thing, unless improving x264 is your day job, which clearly is not, I find it magical how you can write all this code for us, and be online on Doom9 for hours a day?

If your current job happens to be working with the video department of a very popular social networking website then more than likely you will be involved with video codecs all day =)

I actually was wondering when he sleeps because he's up when I get up in the morning and he stays up later than when I go to sleep. Zombie Perhaps?

Guest
18th August 2009, 02:44
Stay OT please, guys. Chat can be taken to PM.

Sagittaire
18th August 2009, 09:38
Good news ...

CpT
18th August 2009, 10:04
Very very cool. Nice work!

juGGaKNot
18th August 2009, 11:17
Nice work™

i will compile and test now

small OT : can i get the latest git from other sources ? ( i have 56k net and git clone crashes a lot, i want to use flashget )

Wishbringer
18th August 2009, 11:27
how about gzipped snapshots of git, only 393 KB size
http://git.videolan.org/?p=x264.git;a=summary

pthreads and gpac don't change very often, so you don't need to check them out each time.

juGGaKNot
18th August 2009, 12:29
THNX.

So its on by default and cannot be turned off or tweaked ( larger lookahead ) ?

Riki
19th August 2009, 05:23
Thanks, x264 keep leaping ahead!

Terka
19th August 2009, 18:43
:thanks:

Terka
24th August 2009, 11:23
when this will be ready?

J_Darnley
24th August 2009, 11:28
when this will be ready?
Perhaps on August 17th. (http://git.videolan.org/?p=x264.git;a=commit;h=1b6086ceb0c346c959a68478b9c36284fbdd5872)

laserfan
24th August 2009, 13:33
when this will be ready?It appears to have been included "way back" in r1213:

http://x264.nl/x264/changelog.txt

Terka
24th August 2009, 15:45
AHA.
and is this possible to use by ffdshow?

LoRd_MuldeR
24th August 2009, 15:50
Lookahead VBV is an encoder-side only feature, so ffdshow will decode streams encoded with Lookagead VBV just fine. I won't even notice that anything has changed ;)

JEEB
24th August 2009, 15:54
The vfw x264 builds are usually bad and limited (plus usually *old*). Use Avisynth or any other way to input video to x264 or libx264 (depending on your app/ways) and encode via it.

As for decoding, ffdshow will do it nicely :V

Riki
2nd November 2009, 21:58
CRF + VBV will now probably work Just Great™ in almost all situations. In fact, it'll even work when the VBV restrictions are absurd; for example, CRF 18 + maxrate/bufsize 250 works despite the fact that CRF 18 will almost always demand a higher bitrate than that. To quote dynaflash, previously, x264 would "underflow and fall on its face".

This is the part I'm trying to understand in my tests. I have a max bitrate of 200 and a buffsize of 1000 and I will encode at different CRF values and the output is dramatically different. Visually the lower CRF encodes look great and the filesizes are bigger, and when I use mediainfo or bitrate viewer the numbers are higher for bitrate, and likewise the higher CRF encodes have a much lower bitrate/filesize/quality.

Im under the assumption that VBV maxbitrate/bufsize should limit CRF and it shouldnt matter if I set it to 10 or 30, but its just not the case. Could someone please help me understand the interaction with CRF and VBV?

Dark Shikari
2nd November 2009, 22:00
This is the part I'm trying to understand in my tests. I have a max bitrate of 200 and a buffsize of 1000 and I will encode at different CRF values and the output is dramatically different. Visually the lower CRF encodes look great and the filesizes are bigger, and when I use mediainfo or bitrate viewer the numbers are higher for bitrate, and likewise the higher CRF encodes have a much lower bitrate/filesize/quality.

Im under the assumption that VBV maxbitrate/bufsize should limit CRF and it shouldnt matter if I set it to 10 or 30, but its just not the case. Could someone please help me understand the interaction with CRF and VBV?The VBV limits the CRF value. If at CRF 30, the video stream only needs 100kbps, it will only use 100kbps, even if the max is 200kbps. If you lower the CRF to, say, 10, it'll use the full 200kbps.

Riki
2nd November 2009, 22:08
Ok great, that clears up my doubts, I guess I just wanted to hear you say it so I could just trust my outputs haha. Appreciate your time.