Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th November 2019, 18:28   #1  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
B-frames quality questions (x264)

I was wondering if we could improve quality of b-frames without causing any issues, nor increasing filesize so much if possible/realistic. I'm aware that we don't watch a video frame by frame, but it still can be important with some videos in which pausing frequently on several moments is useful (e.g. family tapes...), or, if we want to take screenshots...

The thing is that I don't want to use custom settings without any advices, so I have some questions (note that I'm usually using 5-6 b-frames along with b-adapt 2 and b-pyramid) :

1) If I change ipratio value, would it change the quality of EVERY b-frame or just those which are using pframes as reference ?
Or do I HAVE to change both ipratio and pbratio values so that all b-frames would have a quality improvement.

2) I read here and there that pbratio doesn't work if mbtree is enabled, so if we use Grain Tune for instance, which enable both ipratio and pbratio, will mbtree be ignored if it's enabled ?
If yes, do you have any advise on how to "compensate" compression loss (e.g. in high motions) due to no-mbtree ?

3) I just want to have a close quality between b-frames and default "medium preset" pframes (or at least, not too much lower). So, can I achieve this by changing a bit ipratio and pbratio, or do I have to choose more "extreme" values just like Grain Tune do ? (Grain Tune is just an example, my goal isn't grain retention).
Note that I'm not bothered by low quality bframes in high motion moments, but rather in low motion moments.

4) If we change ipratio and pbratio, is it a good idea to decrease psy-rdo (the first value) to compensate ipratio/pbratio bitrate consumption.
Or maybe you have other advises to improve compression ?

Thank you

Last edited by andiandi; 25th November 2019 at 22:06.
andiandi is offline   Reply With Quote
Old 17th November 2019, 22:12   #2  |  Link
Rumbah
Registered User
 
Join Date: Mar 2003
Posts: 466
If you want at least p-frame quality and don't care that much about space, why don't you just deactivate b-frames altogether?
__________________
x264 full help - x264 --fullhelp r2345
Cuttermaran HCEnc provider - Support for HCEnc in Cuttermaran
DualDVDRB - Dual core support for DVD-RB free
Rumbah is offline   Reply With Quote
Old 17th November 2019, 22:33   #3  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
Quote:
Originally Posted by Rumbah View Post
If you want at least p-frame quality and don't care that much about space, why don't you just deactivate b-frames altogether?
Thanks for your reply.
Because by using b-frames we can make them a bit lower quality than p-frames (but not as low quality as the default preset).

Also, b-frames are more efficient for compression than p-frames (efficiency of bi-prediction).

Last edited by andiandi; 17th November 2019 at 22:37.
andiandi is offline   Reply With Quote
Old 18th November 2019, 09:37   #4  |  Link
l00t
Where's my loot?
 
Join Date: May 2019
Posts: 17
You may add a --pbratio switch, which acts similarly to ipratio (except it adjusts the P:B ratio). Please be aware, that x264 will ignore this switch when using MB-Tree, so adding a --no-mbtree is necessary in this case.
l00t is offline   Reply With Quote
Old 18th November 2019, 23:14   #5  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
Quote:
Originally Posted by l00t View Post
You may add a --pbratio switch, which acts similarly to ipratio (except it adjusts the P:B ratio). Please be aware, that x264 will ignore this switch when using MB-Tree, so adding a --no-mbtree is necessary in this case.
Hi, Ok.
But if I only change pb-ratio wouldn't it decrease p-frames quality ? (By taking extra bits from p-frames and allocate them to b-frames).
If yes, should I change ipratio too, in order to maintain p-frames quality ?
andiandi is offline   Reply With Quote
Old 18th November 2019, 23:21   #6  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
Quote:
Originally Posted by Rumbah View Post
and don't care that much about space
I forgot to reply to this.
Actually I care about space/filesize, but I guess that there will probably be no "miracle" if we use higher quality b-frames rather than default lower quality b-frames.

That's why I'm asking for other advices/tips to improve compression in that case.
andiandi is offline   Reply With Quote
Old 19th November 2019, 13:04   #7  |  Link
Rumbah
Registered User
 
Join Date: Mar 2003
Posts: 466
Well, you just have to test it for yourself to see what you like.

I did a quick test for you to perhaps give you a starting point:

Source is uncompressed Tears of Steel 1080p.
Base command line is x264 --preset veryslow --tune film --level 4.1

"Without b-frames" is with added --bframes 0.
"Pbratio 1" is with --pbratio 1.0 --no-mbtree.
"+10%" is with 10% bitrate added.



As you see the differences aren't that big, and without b-frames might even be better than with big b-frames and without mbtree.
__________________
x264 full help - x264 --fullhelp r2345
Cuttermaran HCEnc provider - Support for HCEnc in Cuttermaran
DualDVDRB - Dual core support for DVD-RB free
Rumbah is offline   Reply With Quote
Old 19th November 2019, 17:47   #8  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 2,977
Quote:
Originally Posted by Rumbah View Post
"Without b-frames" is with added --bframes 0.
"Pbratio 1" is with --pbratio 1.0 --no-mbtree.
"+10%" is with 10% bitrate added.



As you see the differences aren't that big, and without b-frames might even be better than with big b-frames and without mbtree.
I'm not sure how relevant averages of per frame scores are in this case, since the issue with B-frames is quality variability. Looking at the variance of VMAF scores is probably the easiest relevant thing to try.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 19th November 2019, 19:25   #9  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
Quote:
Originally Posted by Rumbah View Post
Well, you just have to test it for yourself to see what you like.

I did a quick test for you to perhaps give you a starting point:

Source is uncompressed Tears of Steel 1080p.
Base command line is x264 --preset veryslow --tune film --level 4.1

"Without b-frames" is with added --bframes 0.
"Pbratio 1" is with --pbratio 1.0 --no-mbtree.
"+10%" is with 10% bitrate added.



As you see the differences aren't that big, and without b-frames might even be better than with big b-frames and without mbtree.
Thank you.
Interesting, particularly for mbtree.
Maybe pb-ratio 1.0 is too much. I may be wrong but I guess that since b-frames are more efficient than p-frames, they can have a close quality to p-frames even with lower quantizers, which may improve compression since there no mbtree when pb-ratio is used.

Last edited by andiandi; 19th November 2019 at 19:41.
andiandi is offline   Reply With Quote
Old 19th November 2019, 19:30   #10  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
Quote:
Originally Posted by benwaggoner View Post
Looking at the variance of VMAF scores is probably the easiest relevant thing to try.
Can final ratefactor be a good way of comparison in that kind of case ?
Sometimes, I also check that to compare compression
andiandi is offline   Reply With Quote
Old 20th November 2019, 03:09   #11  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 2,977
Quote:
Originally Posted by andiandi View Post
Can final ratefactor be a good way of comparison in that kind of case ?
Sometimes, I also check that to compare compression
Maybe? I've not tested RF variance between I/P/B/b.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 25th November 2019, 17:54   #12  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 7
Hi.

I made some encoding tests with a full movie in 720p 1800Kbps which have few grain and many high motion scenes, to look at final ratefactor and frames quantizer :



- B-frames + mbtree (rc-lookahead:50) :

final ratefactor: 21.75
frame I:1543 Avg QP:19.34 size: 72976
frame P:35636 Avg QP:22.32 size: 19431
frame B:111983 Avg QP:24.61 size: 5236


- No B-frames + mbtree (rc-lookahead:50) :

final ratefactor: 22.82
frame I:3370 Avg QP:22.10 size: 34683
frame P:145792 Avg QP:24.11 size: 8770

- No-mbtree + pb-ratio 1.0 :

final ratefactor: 23.48
frame I:1521 Avg QP:21.07 size: 54209
frame P:36751 Avg QP:23.47 size: 15013
frame B:110890 Avg QP:23.37 size: 6827

- No-mbtree + pb-ratio 1.1 :

final ratefactor: 22.90
frame I:1521 Avg QP:21.09 size: 54120
frame P:36751 Avg QP:22.94 size: 16398
frame B:110890 Avg QP:23.54 size: 6377



As we can see, based on the final ractefactor (if it's relevant enough), it confirms that No B-frames + mbtree gives a better compression than pb-ratio without mbtree.

But frames quantizer shows that for No b-frames + mbtree, p-frames have a worse quantizer than both p-frames and b-frames with pb-ratio + no-mbtree.

I don't know how to feel about it since both (no b-frame + mbtree and pbratio + no-mbtree) seems to have their advantages.

Last edited by andiandi; 26th November 2019 at 08:29.
andiandi is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:55.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.