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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th December 2009, 08:55   #1  |  Link
seanxu_2010
Registered User
 
Join Date: Nov 2009
Posts: 12
about real time encoding with 2pass

Hi, recently, I did some comparison between 1 pass ABR and 2 pass, obviously, 2 pass almostly uses less bit rate to produce more psnr, my issue is if I can use 2 pass method, when I want to implement real time encoding, certainly, it is not really real time, 10 or more second latency can be allowed, and my assumption is one pass generates stat in real time, meanwhile another pass encodes later than 10 seconds based on the stat, can X264 implement it? or somebody has considered it or implemented it based on X264? thanks
seanxu_2010 is offline   Reply With Quote
Old 26th December 2009, 09:17   #2  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Impossible in the general case since the purpose of 2-pass is to distribute bits over the whole video, while your plan would only distribute bits over, well, 10 seconds.

However, this is already implemented as RC-lookahead in x264, and is used for VBV, where one does in fact care about the next few seconds as opposed to the whole video.
Dark Shikari is offline   Reply With Quote
Old 26th December 2009, 10:07   #3  |  Link
seanxu_2010
Registered User
 
Join Date: Nov 2009
Posts: 12
Quote:
Originally Posted by Dark Shikari View Post
Impossible in the general case since the purpose of 2-pass is to distribute bits over the whole video, while your plan would only distribute bits over, well, 10 seconds.

However, this is already implemented as RC-lookahead in x264, and is used for VBV, where one does in fact care about the next few seconds as opposed to the whole video.
thanks a lot, I will try!
In fact, I attempt to encode some sport program(such as NBA) from 1080i to D1, as you know, the scene in NBA is always high complexed, my plan is encoding them in a very low bitrate, 800bps maybe, however, the result is awful, too obvious block-effect exist in edge for the complexed scene, I know it's because of the high QP for low bitrate, so I try some special methods to improve the quality, not for the psnr, but for the vision from human, and I denoise the raw data based on freq and time domain to smooth the detail, which maybe decrease the complexity for encoding and more or less can distribute some bits for reducing the block effect, could my attempt be available? or do you have any suggestion for the pre-posting or the encoding process for increasing the quality at low bitrate?
seanxu_2010 is offline   Reply With Quote
Old 26th December 2009, 23:40   #4  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
If you're having low quality due to high QPs, then you can do a few things:

1) Slow down x264 to increase its quality
2) Increase bitrate
3) Decrease resolution
4) Add denoising, either directly in x264, or ideally via more fancy stuff like AviSynth

How exactly are you processing your 1080i sources? Real-time is not my specialty, and probably rules out AviSynth, but maybe something can be done. Why the low bitrate restriction? What x264 command line exactly are you using? Your problem may be due to poorly chosen settings.

Are you going to 480p60 or 480p30? If you're coding interlaced - you probably shouldn't if you're trying to squeeze in as much quality as possible. The scaling / deinterlacing process can also heavily impact compressibility. So - how are you doing this?

800kbps is probably enough bitrate for 480p30 sports to look *okay*, not fabulous or anything, always hard to say - and always source specific!!

Moar info pls

~MiSfit
__________________
These are all my personal statements, not those of my employer :)

Last edited by Blue_MiSfit; 26th December 2009 at 23:42.
Blue_MiSfit is offline   Reply With Quote
Old 27th December 2009, 03:42   #5  |  Link
seanxu_2010
Registered User
 
Join Date: Nov 2009
Posts: 12
Quote:
Originally Posted by Blue_MiSfit View Post
How exactly are you processing your 1080i sources? Real-time is not my specialty, and probably rules out AviSynth, but maybe something can be done. Why the low bitrate restriction? What x264 command line exactly are you using? Your problem may be due to poorly chosen settings.

Are you going to 480p60 or 480p30? If you're coding interlaced - you probably shouldn't if you're trying to squeeze in as much quality as possible. The scaling / deinterlacing process can also heavily impact compressibility. So - how are you doing this?
Moar info pls

~MiSfit
uh...ok. I choose a clip from NBA, mainly including running and shooting, and the source is 1080i 60field, I used some tool to de-interlace, scale, and denoise it to 480p 30 frame(I also compare 480p 30 and 480p 60, it's trade off between quality and fluency, I selected the fore one because it seems more acceptable), then,I use the YUV420 raw data as input which 's quality is very good, and X264 command is below:
1 pass --bitrate 800 --ratetol 10 --qcomp 0.9 --profile baseline --me dia --ref 1;
2 pass --bitrate 800 --ratetol 10 --qcomp 0.9 --profile baseline --analysis all --me umh --ref 3 --deblock 3:3.

800bps is restricted by the network, but it allows 10 second latency, so I choose 10 as ratetol, and baseline is confined by the decoder, cabac and B can' t be used. and deblock alpha and beta is set as 3 3, which can help to decrease the block effect more or less I think.
however, all my attempts do not give me a obvious improvement, now my plan is below:
1 reduce some detail at pre-process, by using some strong denose tool or blur tool, because of scaling down too much.
2 because of NBA scene, what we concentrate on are always the athlete and ball, while the auditorium is ignored usually, so I can adjust the QP higher at center region, on the contrary, lower at around of the video, so maybe I add some code for ratecontrol based on the region adaptive.

that is my assumption, any suggestion?
seanxu_2010 is offline   Reply With Quote
Old 27th December 2009, 04:36   #6  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by seanxu_2010 View Post
uh...ok. I choose a clip from NBA, mainly including running and shooting, and the source is 1080i 60field, I used some tool to de-interlace, scale, and denoise it to 480p 30 frame(I also compare 480p 30 and 480p 60, it's trade off between quality and fluency, I selected the fore one because it seems more acceptable), then,I use the YUV420 raw data as input which 's quality is very good, and X264 command is below:
1 pass --bitrate 800 --ratetol 10 --qcomp 0.9 --profile baseline --me dia --ref 1;
2 pass --bitrate 800 --ratetol 10 --qcomp 0.9 --profile baseline --analysis all --me umh --ref 3 --deblock 3:3.

800bps is restricted by the network, but it allows 10 second latency, so I choose 10 as ratetol, and baseline is confined by the decoder, cabac and B can' t be used. and deblock alpha and beta is set as 3 3, which can help to decrease the block effect more or less I think.
however, all my attempts do not give me a obvious improvement, now my plan is below:
1 reduce some detail at pre-process, by using some strong denose tool or blur tool, because of scaling down too much.
2 because of NBA scene, what we concentrate on are always the athlete and ball, while the auditorium is ignored usually, so I can adjust the QP higher at center region, on the contrary, lower at around of the video, so maybe I add some code for ratecontrol based on the region adaptive.

that is my assumption, any suggestion?
That isn't how ratetol works.

Here's what you actually mean:

--bitrate 800 --vbv-maxrate 800 --vbv-bufsize 8000
Dark Shikari is offline   Reply With Quote
Old 27th December 2009, 05:15   #7  |  Link
seanxu_2010
Registered User
 
Join Date: Nov 2009
Posts: 12
Quote:
Originally Posted by Dark Shikari View Post
That isn't how ratetol works.

Here's what you actually mean:

--bitrate 800 --vbv-maxrate 800 --vbv-bufsize 8000
thanks, there may be some misunderstanding, I know the ratetol is relative with overflow, what I mean is set a bigger value for ratetol instead of the default value 1, so permit a higher overflow for abr.

And I just view some threads about CBR, you suggest me to use VBV buffer model, and according to my understanding, X264 set a 10 second video buffer for imitating the stream buffer at decoder, in purpose that X264 can distribute less bits for the low complexed scene, and more bits for the high ones, but the distribution is limited by the size of buffer to ensure the decoder stream buffer is not overflow and underflow, in a word, that means it produces a stream with constant bitrate in 10 seconds perspective and if we see the curve of bitrate, it must be fluctuant around --vbv-maxrate. is it correct? if so, what is --bitrate used for? and when we set VBV, has the --rc-lookahead been set as a default value? because, if not, how the x264 can guarantee the constant bitrate in a 10 seconds perspective?

Last edited by seanxu_2010; 27th December 2009 at 05:52.
seanxu_2010 is offline   Reply With Quote
Old 27th December 2009, 05:48   #8  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by seanxu_2010 View Post
thanks, there may be some misunderstanding, I know the ratetol is relative with overflow, what I mean is set a bigger value for ratetol instead of the default value 1, so permit a higher overflow for abr.

And I just view some threads about CBR, you suggest me to use VBV buffer model, and according to my understanding, X264 set a 10 second video buffer for imitating the stream buffer at decoder, in purpose that X264 can distribute less bits for the low complexed scene, and more bits for the high ones, but the distribution is limited by the size of buffer to ensure the decoder stream buffer is not overflow and underflow, in a word, that means it produces a stream with constant bitrate in 10 seconds perspective and if we see the curve of bitrate, it must be fluctuant around --vbv-maxrate. is it correct? and if so, what is --bitrate used for?
Maxrate is the maximum rate of flow of the input to the leaky buffer model of the VBV. Bitrate is the overall bitrate of the video. They really have nothing to do with each other, except that if bitrate == maxrate, you have CBR.
Dark Shikari is offline   Reply With Quote
Reply

Tags
2 pass, realtime, x264


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 11:04.


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