Log in

View Full Version : How to use b-frames: 1 or 2?


Pages : [1] 2

civitos
6th January 2005, 15:12
hi everybody


I ask some help and clear about b-frame:

My doubt: I encode twopass at at 2nd pass i choose a target size: for example 1000mb. What's the difference between use 2 consecutive b-frames or 1 b-frames or 0 (no) b-frames?

another doubt: same scenario but at 2nd pass i choose a target bitrate (ex. 2500 bitrate).What's the difference between use 2 consecutive b-frames or 1 b-frames or 0 (no) b-frames?

In my mind i don't have clear if b-frame help to reduce size at same quality (but how i've to set parameters) or b-frame help to increase quality with increasing size but less than use only p-frame?

May you help me?


I started to make testing clip to test kiss-dp450.
I've just successful played a clip with 2 consecutive b-frame, no packed bitstream and closed GOV.

I 'will you update if you help me.

bye everybody

Sharktooth
6th January 2005, 16:12
If you use 2 pass encoding don't worry about the filesize or bitrate you set. It will respected with and without b-frames.
The rate control will compensate the reduction in size (when you enable b-frames or higher the value of max consecutive b-frames) rising the bitrate in some areas.
2 pass encoding usually can take a better advantage from the use of b-frames coz the codec rate control can reallocate bitrate in areas where it's needed ensuring a better overall quality.
However the result is the same average bitrate and the same filesize.
If you're going for constant quant encoding you will exclude the rate control mechanisms and you will definately see a difference in filesize in favour of the "b-frame enabled" encoding (that doesnt not necessarily mean a big difference in overall perceived quality).

For standalones is usually better to keep 1 max cons. b-frame coz most of them can't handle more than that.
If your standalone is able to decode more than 1 b-frame, then use it without packed bitstream.

mikeX
6th January 2005, 19:08
As far as I know, the idea behind B-frames is this:

Increase overall quality by decreasing the quality of certain parts of the clip (the ones where B-frames are used). That means you save bitrate at some parts of the clip (where it won't show that much) in order to use it at other ones (where quality loss is more visible).

In each scenario you described, the more B-frames you use, the better the overall quality of the clip, but at the same time, the bigger the chance you will notice certain scenes of the clip with dissapointing quality. Whether the gain in overall quality is worth that loss is for you to decide and depends mostly on the particular clip. However, be aware that the default setting (max 2 consecutive B-frames) has been carefully chosen by the developers, and should produce good results for most clips.

Regarding your assumptions, the first one is closer to the idea behind B-frames: B-frames aim at increasing quality at the same size (in your words: decreasing size at the same quality).

civitos
6th January 2005, 19:56
thanks, but now you ligth me another duobt: 1-pass encode (quantizer or bitrate based) vs 2-pass encode.

up to now I've used 2-pass encoding with 2nd pass filesize or bitrate target, to reach a good quality, what I knew was reached about to 2000 Kbps.
When possible in 2-nd pass i set 2000/2500 bitrate, which filesize is larger than i desire i set the maximum filesize i desire.

Now i want to undesrtand and evaluate the 1-pass econde with quantizer target or bitrate.

Grateful for anyone who talk me about

mikeX
6th January 2005, 20:57
Well 1-pass is not really recommended if you are after maximum quality. However, fixed quantizer 1-pass can give good quality as well (as long as you use a small enough quantizer like 2 or 3), but the resulting filesize is totally unpredictable. On the other hand with fixed bitrate 1-pass you can't be sure of the quality you will achieve before you try, but you can easily predict the resulting size (with the built-in bitrate calculator for example). Of course in the latter case, using 2 passes will most probably give you far better results, so it's only useful for stuff that can't afford 2 passes, like capturing from a video card.

Mnl
6th January 2005, 22:46
Hi civitos

Try reading this thread:

http://forum.doom9.org/showthread.php?s=&threadid=69130

In the thread Manono gives a good explanation regarding 1-pass vs. 2-pass encoding.

Originally posted by mikeX
Well 1-pass is not really recommended if you are after maximum quality. However, fixed quantizer 1-pass can give good quality as well (as long as you use a small enough quantizer like 2 or 3), but the resulting filesize is totally unpredictable.

I don't agree with that. 1-pass encoding is the way to go if you want maximum quality - as long as you don't care about final filesize. Probably that is what you ment to say, but your reply could be misunderstood ;)

Neo Neko
6th January 2005, 23:14
Basically 2-pass is only usefull for best quality while trying to hit a target a specific datarate. A 1-pass quality/quantizer encode will deliver the best over all quality but at the cost of filesize/datarate predictability. Though lately I have found myself using constant qualtizer more than 2-pass. Even using constant quantizer I can still on average get 3 or more movies per DVD+R. More now that I am getting more AVC encodes.

mikeX
7th January 2005, 01:32
Mnl, Neo Neko,
yes you are right, I was hasty :)

IgorC
7th January 2005, 04:04
3 bframes?
Can it improve the quality?. If yes then what options to use

Neo Neko
7th January 2005, 06:03
Yes and no. It depends on the video really. Even if you set it to 8 B frames that does not mean you will get much more than 2 consecutive in general. What you are setting is a max value. Much above 2 or 3 and you will not normally reach your max value. Unless you do something like setting up zones with increased b frame sensitivity etc. I encode with the max set to 4. But watching the frame type output it is rare to se more than 2 together.

b0b0b0b
7th January 2005, 06:44
Yeah, with 1-pass encodes my experience is that scene change detection is kind of wacky, regarding where it chooses to put I-frames.

OT, I've gotten fair results with avg quant of like 1.99.

Tommy B.
10th January 2005, 01:24
When it comes to cartoons it occurs sometimes that more than
2 B-Frames are used. Buta as already said, this is pretty rare,
especially when encoding real life material (e.g. a movie).

Sagittaire
10th January 2005, 02:43
The primary advantage of using B-frames is that an error in a B-frame will not propagate to subsequent frames as an error in a P-frame will.

-> with constant quantizer for I,P,B IPBBPBBPBBP... is better than IPPPPPPPPP...

Bframe number are adaptative ... higher number bframe in "low motion" and lower or not in "high motion".

-> choose 10 or 15 for max bframe number is not a problem. The codec choose himself the best bframe max number for each sequences : generaly 0 or 1 for XviD ... with default sensivity setting.

quant ratio or/and offset for bframe is better for average quality.

-> for example this sequence

I q3 45 dB
P q3 45 dB
B q5 43 dB
B q5 43 dB
P q3 45 dB
average 44.2 dB

is better than that sequence with same size

I q4 44 dB
P q4 44 dB
B q4 44 dB
B q4 44 dB
P q4 44 dB
average 44.0 dB

ChronoCross
10th January 2005, 05:05
it's my opinion that 4+ max consecutive bframes is generally a bad idea in that it can have really bad effects on high motion scenes gernerally around line edges not so much in the main portions of the move however it still makes it look ugly.
Try to stick to 1-3 bframes and disable bframes for DVD archiving.

Sharktooth
10th January 2005, 13:46
B-Frames are adaptive... even if you put 10 in the "Max cons. b-frames" textbox the codec will usually put 1 or 2 (and very rarely 3) consecutive b-frames.
However if you modify the b-frames sensitivity that behaviour will change.
Also the human eye perception is not perfect and 1 or 2 b-frames (standard settings) should be a fair choice for DVD backups.

AsTimeGoesBy
10th January 2005, 16:11
Is the behaviour of DivX and Xvid similar how they set B-frames?

In my small 'uncertified DivX feature' test with allowing 2 consecutive B-frames i have noticed that the probability to find such a couple (with EKG tool) is very high on low motion scences. - Is that experience also valid for Xvid?

Old movies have a lot of steady camera positions so i had the idea to encrease from 0 to 10 Xvid's b-frame sensivity (range allowed -20 till +30) in combination with 2 b-frames on maximum.
Now, is that good idea? Is there anything more i should respect before changing default values for B-frames?

Tommy B.
10th January 2005, 17:01
Try it and give us the results.

AsTimeGoesBy
10th January 2005, 18:43
Sorry, i can't!
...because trying & tring that's just what i do since the evening of December 23th 2004.

I guess my PC runs now for more than 300h non-stop making 3 test encoding for all my B/W collection movies, LotR-trilogy, some WWII-movies and so more.
I even have calculated the changes on room temperature affected by 400W power dissipation by my temporary 4HD-tuned computer so i decided to underclock (downclock?) my CPU some percentages.
Actually i also set up in haste an apache at home telling me now that there are still about 10 passes left so i hope my PC stands that torture some longer or at least until i am back home again the next weekend.

Than i like to test the new DivX Plasma as mentioned in the DivX forum (http://forums.divx.com/eve/ubb.x?a=tpc&f=401101651&m=177101302) and maybe than i will have some time and CPU resources left to make B-frame tests.
But i really like to get a short enlightment if i would be on the right way with the b-frame-'tweaks' as posted in my last entry here.

mp3chan
11th January 2005, 15:34
Is that true that B-frames is more usefull and gives more advantage in low motion video (eg. cartoon/anime)?

Sharktooth
11th January 2005, 15:58
@ATGB: i would trust the xvid devs (i'm sure they spent a lot of time finding the optimal values) and keep the standard b-frames settings. If you need standalone players compatibility then i would set the max cons. bframes value to 1.
Altering b-frames settings is not reccomended, expecially if you dont know what are you doing.

@mp3chan: The codec has an "adaptive" algorithm and will choose when and how many b-frames are needed (limited by the user settings).
As i said in a previous reply rising the max consecutive b-frames value without altering the sensitivity is almost useless.
Forcing the codec to use (or not) b-frames modifying the b-frame sensitivity is not a good idea unless you really know what you're doing.
BTW, cartoons and animes are not necessarily "low motion".

AsTimeGoesBy
11th January 2005, 18:42
Originally posted by Sharktooth
...
Forcing the codec to use (or not) b-frames modifying the b-frame sensitivity is not a good idea unless you really know what you're doing.
...I guess this statment could also applied on me... ;)
So i will start re-encoding the critical sences by returning back to the default b-frames settings before changing filters and xvid's chroma option.

Sharktooth
11th January 2005, 18:55
It depends, i usually tend to keep the default b-frame settings or in rare cases i make very, very, very little changes to the default values (yes, sometimes i use 3 b-frames, but only when i need some more compressibility).

AsTimeGoesBy
11th January 2005, 20:31
I would like to allow Xvid to use 3 consecutive b-frames too because i generally think adaptive consecutive b-frames is an efficent and less problematic feature (specially compared to QPel).
But practically i want avoid the risk that my carefully made Xvid encodings don't play on a friend's player - nothing else kills more the holiday atmosphere than an announced movie that doesn't play.

That's why i keep 2 consecutive b-frames, nethertheless i try to get more 'adaptive consecutive b-frame profit' by encreasing the b-frame sensitivity form 0 to 5 or 10.
Technically i never have noticed problems with 2 consecutive b-frames till now although i'm not fully sure on the consequences for visual quality by changing the sensitivity.


I really must make any tests the next time with some scenes where i suppose consecutive b-frames are very probable, e.g. at dialoques with steady/unmoved background...

mp3chan
12th January 2005, 17:42
Originally posted by Sharktooth
... BTW, cartoons and animes are not necessarily "low motion".
Yes, cartoons and anime not always "low motion" but usually it contains more still pictures. With this assumption, XviD would produce more consecutive B-frames. Do I misunderstand something here?

b0b0b0b
13th January 2005, 06:20
Don't forget that the more Bframes you use, potentially the more bits the next Pframe needs.

Teegedeck
13th January 2005, 08:49
P-frames don't depend upon B-frames.

Leak
13th January 2005, 09:16
Originally posted by Teegedeck
P-frames don't depend upon B-frames.

Well, that's why B0b0b0b said that P-frames will get bigger - since it can only depend on the previous P-/I-frame, the difference that needs to be encoded will be greater.

Teegedeck
13th January 2005, 23:24
I'm growing old at a rapid pace.

Leak
13th January 2005, 23:43
Originally posted by Teegedeck
I'm growing old at a rapid pace.

Same here... :D

np: Keishi Urata - Code 07TX (Texhnolyze OST The Man Of Men)

b0b0b0b
15th January 2005, 10:18
I've been doing some encodes night after night after night, getting a feel for xvid and bframes. One thing I tried was having min quants of 1 across the board and 1 bframe with a ratio of 4, offset 1, and targeting 10gigs. Movie came out at 1.1g and even though it's h263 quant matrices, I perceived it retaining lots of detail and good film grain.

Lesson is, I think, that bframes will save you a ton of space. Common knowledge, but it was nice to finally be convinced and see it for myself.

Clock
15th January 2005, 15:24
I go with a max of 10 BFrames most of the times, simply because, like some here mentioned, the codec chooses for himself. I could even say I wonder, why there is such a thing as a max. Why not give the codec all possibilities, if it's algorithm is good enough.

But when it comes to sensitivity, I'm clueless. Only thing I know: higher sens, more bframes. But I would really like to know more. My opinion: "bframes save bits, so use many of them" doesn't seem to be shared by many in here. I like to play around with the sens-setting, but know absolutely nothing about what a sens of, for example, 10 means. Is is 10% more on average, bframe if save in bits is 10%, or what...???

Clock

b0b0b0b
15th January 2005, 18:54
I did that exercise for myself too, setting the sensitivity to something really high like 5000 for the whole movie, and setting the max consecutive bframes to 50 or something, and giving a 2nd pass target size of 10gigs. I seem to recall the result was huge and sloppy.

After running lots of my own tests, I've come to realize that the preset defaults have been arrived at through a lot of tuning and testing and thought by a lot of people. (h263 quant matrices, bframe q multiplier, bframe q offset)

I think you could look at your point of max infinity bframes (assuming the algorithm is 'good enough') as an issue of xvid giving you enough 'rope' to hang yourself.

Go ahead and make a regular encode and compare it against another encode where the only setting you change is the bframe sensitivity, and compare the results for yourself. Also, watch the xvid stats window and the virtualdub frame size graph during the encoding. In the latter case I think you end up with too many bframes and pframes that are sized like iframes.

Andrey
16th January 2005, 12:21
>>Don't forget that the more Bframes you use, potentially the more bits the next Pframe needs.
Sure ;)
1. But 3 b-frames between them with 2 times lower quantizer will overcompensate it :)
2. Potentially, this p-frame will looks better. You know why :)
(hint - that p-frame will not depends on quantizers of those b-frames).
EDIT: grammar and hint added. :)

stephanV
16th January 2005, 16:01
potentially, that p frame will take up *a lot* more space due to the bigger time difference between p-frames. more must be compensated. it is certainly not sure that the b-frames will compensate the extra bits used by the p-frame... it might even degrade quality...

perhaps for anime or cartoons its true though... i wouldnt know.

people who know what they are doing probably dont even want to muddle with b-frame settings too much, and people who dont know shouldnt :p

AsTimeGoesBy
17th January 2005, 18:01
Originally posted by AsTimeGoesBy
...I really must make any tests the next time with some scenes where i suppose consecutive b-frames are very probable, e.g. at dialoques with steady/unmoved background... Sorry to quote myself, but i was courious if that impression would be ok.

Thus i have compared 'no B-frames' with 'many B-frames' in the following scene of 'Amelie'. The two samples are at ~200kbps (~250kb/11s), one without B-frames, the other with over 65% of B-frames (sensitivity at 5 - i know, not really recomended for normal use).
Amelie-0BVOP.avi (http://n.ethz.ch/student/fhoesli/video/bvop/Amelie-0BVOP.avi)
Amelie-3BVOP.avi (http://n.ethz.ch/student/fhoesli/video/bvop/Amelie-3BVOP.avi)
Here is a AviSynth file you can easily watch them both at the same time, eg. with VirtulDub or MPC:
Amelie-xBVOP.avs (http://n.ethz.ch/student/fhoesli/video/bvop/Amelie-xBVOP.avs)
http://n.ethz.ch/student/fhoesli/video/bvop/Amelie-xBVOP.jpg

Please note, altought 3 consecutive B-frames were allowed, Xvid didn't used it on that scene:
Stats by MPEG4 Modifier for Amelie-3BVOP.avi

Packed bitstream: Yes
QPel: No
GMC: No
Interlaced: No
Aspect ratio: Square pixels
Quant type: H.263

I-VOPs: 2 (0.70%)
P-VOPs: 96 (33.45%)
B-VOPs: 189 (65.85%)
S-VOPs: 0 (0.00%)
N-VOPs: 0 (0.00%)

Max consecutive B-VOPs: 2 ! ! !
1 consec: 1.05%
2 consec: 98.95%


Personally 200kbps is much below my favortite bitrate but it seems the higher the bitrate the harder to see differences
(although also saving a little amount of bitrate gets very intresting, specilly when images get subjectively
free of compressions artefacts or visual blocks thanks to that B-frame bitrate benefit - but i'm sorry,
it would take too much time to approuch that quality treshhold by trial and error).

Here is another low-motion scence (keep an eye on Brad's blocky shadow or on that anti-gravity-ice-cube smoke).
FightClub-0BVOP.avi (http://n.ethz.ch/student/fhoesli/video/bvop/FightClub-0BVOP.avi)
FightClub-3BVOP.avi (http://n.ethz.ch/student/fhoesli/video/bvop/FightClub-3BVOP.avi)
(each avi ~360kb/17s)
FightClub-xBVOP.avs (http://n.ethz.ch/student/fhoesli/video/bvop/FightClub-xBVOP.avs)
Stats by MPEG4 Modifier for FightClub-3BVOP.avi

Packed bitstream: Yes
QPel: No
GMC: No
Interlaced: No
Aspect ratio: Square pixels
Quant type: H.263

I-VOPs: 5 (1.13%)
P-VOPs: 148 (33.33%)
B-VOPs: 291 (65.54%)
S-VOPs: 0 (0.00%)
N-VOPs: 0 (0.00%)

Max consecutive B-VOPs: 2
1 consec: 2.04%
2 consec: 97.96%
Here again, there are no 3x B-VOPs. - So where are they used?

After all, i had hoped to see a bigger difference indeed specially at these rather extreme samples. I also i'm not sure if low-motion scenes are the best place for multi-B-VOPs, the 3x-B-VOPs evidentially prefer other scenes.
However the improvment by b-frames exists, so far a welcome feature! :)

_____________
Edit: since the public beta of Xvid 1.1b is out it would be useful to say that i have used for my samples Xvid1.0.3 from www.koepi.org (http://www.koepi.org/xvid.shtml).

Tommy B.
17th January 2005, 18:36
You have to increase the BVOP sensitivity to a rather "extreme"
level. I tried using "30" and made the codec use 3 BVOPs. You could
also try "1000".

I encoded a video with a high BVOP sensitivity and with a lower one.
In my eyes there were no real differences between the two encodes.
I tried using 10 BVOPs and XviD usually used about 6 to 8 B-Frames
during coding. The P-Frames were quite large though. I will try
encoding to a fixed quant and see which file is smaller.

Sharktooth
17th January 2005, 18:38
over 2/3 b-frames usually the advantage of b-frames becomes nullified/the file becomes bigger.

Tommy B.
17th January 2005, 19:05
That seems not to be the case with my encodings.

Just encoded a 3.14 min clip (cutout from the movie Triple X) with a
fixed quant of 1 and the file with the many B-Frames (10 allowed,
sensitivity set to 100) came about 8 megs smaller than the other.
The picture quality is the same, though it seems as if Adaptive
Quantinization produces some very slight errors which can only be
seen in the stills.

Used the new BETA of XviD.

Sharktooth
17th January 2005, 19:10
Quant 1? well, at that quant the P frames are so large that using B will almost always be an advantage...

Tommy B.
17th January 2005, 19:59
Just tried this. Seems to be true. Final size of files:

Nrml BVOPs: 25.608.192 Bytes
Many BVOPs: 25.636.864 Bytes

Well, the difference in size is not that much but is present. The
fixed quant was 3.

I will try encoding one more time, forcing the use of 3 BVOPs.

Tommy B.
18th January 2005, 01:25
I just did some more testing and it seems that the size (with Q3) of
a file is the smallest when 3 B-Frames are forced. The size was

24.940.544 Bytes

which is quite a bit for a 3 minute clip. But it seems as if the
quality did degrade a bit (can't say exactly whether this is imagined
due to a lack of sleep).

Caroliano
18th February 2005, 23:14
I made my own tests for B-vops in anime encodes.
The raw is the first part of the Ghibli's film "Neko no ongaeshi" which approximately 3 min lenght.

Geral Setings:
------------------------------------------------------------
Xvid 1.1 Beta-1

VHQ - 4 and VHQ for B-frames
Turbo - on (my computer is slow....which out this 4~5 fps)
trellis - on
quantizers: 2/3 2/4 4/8
Croma motion & optimizer
Overflow control: 10 in all.

Target Bitrate: 519 (in q-2 the final bitrate is 1100~1300)

-----------------------------------------------------------
The rest is the defaut

I make 4 tests: which out b-frames; 2 b-frames (defaut); 15 b-frames; 15 b-frames and sensibility at 100.

Results:

- The 15 b-frames which sensibility 100 was horrible. Althoug the sensibility 100 the number of b-frames was "only" 6.3 times than the p-frames at the end of clip (I expected almost 15 times which this seting).
- Which out b-frames (at least in this bitrate) was visible worst than which b-frames but much better than the 15 b-vops s/ 100.
- Use 15 b-frames as max was almost the same as 2 b-frames. 2749 and 2698 b-frames respectively(total of 4298 frames and all tests used 45 I-frames). In most parts only 2 consecutive b-frames was used. In the logo of Ghibli (a static and simple scene which a blue backgrond and a thin line in black making the figure(which generate a lot of ringing whit Xvid and is incredibly good for comparate the encodes =P)) used 8~10 b-frames. The two are very similar but which 15 b-vops was slight better than 2. Even in the logo's part the quality is improved which more b-frames...


The conclusion I reached is that the decision of Xvid in put or no a B-frame is very accurated. In some scenes in animes more b-frames is a good idea but in more complex totaly static scenes the Xvid use only 2 b-frames... so the diference is not so big, but exist.
I dont know if more than 2 b-frames could be problematic whith FFDSHOW or DVDs players that supose to run Xvid and Divx. If anyone answer that I wold be glad. If it become a problem the defaut 2 frames would be better because the lack of compatibility...

(sorry for my english, its not my main language)

vigi_lante
27th February 2005, 15:27
Well, I didn't understand very well what is difference between using b-frames with single pass at fixed quant and using b-frames with two pass...

I encoded the same source two times with quant 2, the first without b-frames, and the second with 2 b-frames. The results are...

First: 798 mb
Second: 518 mb

So, using b-frames at a fixed quant of 2 is a good idea ? I really liked the reduced file size, but I'm wondering at what level the picture quality are being compromised for the first to the second encode.

Tommy B.
27th February 2005, 16:50
I think since B-Frames use a higher quant than P-Frames, you will
recognize a loss in quality when there is a large sequence of
B-Frames.

I encoded a clip with those settings and it seems as if the picture
quality is pretty bad when there are many B-Frames (more than 4),
siply because you have 4 frames you see quant 4 (when the P-Frame
has 2) and thus you see more artifacts.

vigi_lante
27th February 2005, 17:18
Sorry, but how I can see, using Virtualdub, if the frame is b-frame or not ?

stephanV
27th February 2005, 18:20
you cant see if a frame in an AVI is b-frame or not in VDub. B-frames do not exist for AVI. There are only delta and key frames.

The question is not: "Is there a degradation in quality (due to b-frames in a fixed quant encode?)", the question is: "Can you see a degradtion?"

If the answer is yes, don't use b-frames. if its no, then use them.

Caroliano
27th February 2005, 22:57
Originally posted by vigi_lante
Sorry, but how I can see, using Virtualdub, if the frame is b-frame or not ?

As stephanV said you cant see it in virtual dub but exist many forms to see it.
The first is when you encode a video check "print debug info" in the Advanced options of Xvid. But it is only for test or as the name say "debug" purposes because the Xvid realy print in the frame it.
The second way I know is using FFDSHOW. In configurations go to the "debug" area and check to show what type of frame is. This is not permanent as the first case.

dooWohcysP
10th March 2005, 17:45
Hello everybody, and sorry for the intromission :)

What about using BVOPS with a quantizer offset of 0?

This way bframes should behave like (~have same quant as) Pframes, but with a lower size (due to the bframe structure, i.e. the bidirectional reference), or not?

Sharktooth
10th March 2005, 18:09
bad idea... they won't look much better coz the p-frames and i-frames quantizer will grow up reducing the overall encode quality.

dooWohcysP
10th March 2005, 18:32
they won't look much better coz the p-frames and i-frames quantizer will grow up reducing the overall encode quality

Why? If I do a low bitrate 2pass encoding, this is true, but if I do a fixed quant encoding, this should maximize the quality..

I'm lost...