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. |
24th May 2020, 17:51 | #1 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
x265 buffer underflows
Getting buffer underflow errors when encoding CBR with x265 using strict-cbr. Is it a known issue?
Another issue could be fact that I'm forcing I frames with ffmpeg's -force_key_frames "expr:eq(mod(n,50),0)" This may be messing with rate control. Is there any other way of getting fixed 2 seconds IDR frame distance (and still letting encoder to use I frames inside those 2 seconds)? Using latest ffmpeg. Last edited by kolak; 24th May 2020 at 18:26. |
24th May 2020, 18:51 | #2 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
Or -x265-params keyint=50 |
|
24th May 2020, 19:31 | #3 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
g or keying itself means max GOP size. It doesn't guarantee you IDR frame at every n*50fps at all (only that no GOP will be bigger than 50).
I need IDR frame at ever n*50 + I frames (to cover scene changes etc.) in between if encoder decides so. Last edited by kolak; 24th May 2020 at 20:25. |
24th May 2020, 21:36 | #6 | Link | |
Derek Prestegard IRL
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
|
Quote:
|
|
24th May 2020, 22:29 | #7 | Link | ||
Testeur de codecs
Join Date: May 2003
Location: France
Posts: 2,484
|
Quote:
Quote:
Reuse encoding use complete research from first pass and refine Rate Control at really high speed (like fastest preset speed but with veryslow preset quality). And reuse mode will refine and refine and refine again Rate Control in Npass mode certainely with better quality than classic 2 pass RC mode, and with better constrained Rate Control at each pass. IMO with this particular mode encoding, --strict-cbr will be even useless if you use many pass and you can expect better quality too.
__________________
Le Sagittaire ... ;-) 1- Ateme AVC or x264 2- VP7 or RV10 only for anime 3- XviD, DivX or WMV9 |
||
24th May 2020, 22:38 | #8 | Link |
Testeur de codecs
Join Date: May 2003
Location: France
Posts: 2,484
|
and you can certainely expect more constant overall quality and less underflow with something like that:
--bitrate 1900 --vbv-maxrate 2000 --vbv-bufsize 12000 if your target bitrate is 2000, choose little lower bitrate like 1900 to have better buffer gestion and more constant quality in GOP between I, P and Bframe.
__________________
Le Sagittaire ... ;-) 1- Ateme AVC or x264 2- VP7 or RV10 only for anime 3- XviD, DivX or WMV9 |
24th May 2020, 23:14 | #13 | Link |
Testeur de codecs
Join Date: May 2003
Location: France
Posts: 2,484
|
Well if you have multiple consecutive pure black frame, encoder will certainely never use high bitrate for that ... ;-)
__________________
Le Sagittaire ... ;-) 1- Ateme AVC or x264 2- VP7 or RV10 only for anime 3- XviD, DivX or WMV9 |
24th May 2020, 23:21 | #15 | Link | |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
Quote:
Strange getting GOPs at 61, 72 ... for keyint=minkeyint=50 (update: it was due to gop-lookahead not been set to 0) I'm actually not getting underflow errors anymore (at least not so far), so looks like ffmpeg's force_keyframe option messes a bit with rate control in x265. Last edited by kolak; 26th May 2020 at 16:40. |
|
2nd June 2020, 15:08 | #17 | Link | |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
I did not understand it either, now I think I do.
Let's say you have keyint set to 50 frames. If you set gop-lookahead to eg. 25 frames, then x265 will look those 25 further ahead to see if it may be better to set an IDR frame somewhere there. It may decide that best IDR place will be eg. 10 frames after those 50, so you will end up with 60 frames GOP. If you do the same, but set gop-lookahead=0 at those 10 frames pass 50 frames x265 will most likely set I frame (not an IDR). This will properly respect 50 frames maximum GOP. With gop-lookahead your longest GOP is keyint+gop-lookahead. I may be wrong No idea how it's different than setting keyint=75 Quote:
Last edited by kolak; 2nd June 2020 at 15:14. |
|
2nd June 2020, 20:12 | #18 | Link |
Derek Prestegard IRL
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
|
Ah, so if you do want constant IDR cadence (like for ABR streaming) then you would presumably want to make sure that's disabled! (it is by default)
Seems like a great feature for a satellite / broadcast feed where the main constraint on keyint is latency and channel switch time. Having slight wiggle room is probably acceptable in those cases. |
4th June 2020, 20:34 | #19 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
|
Quote:
Seems worthy of some testing. |
|
4th June 2020, 23:18 | #20 | Link | |
Derek Prestegard IRL
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
|
Quote:
Put another way, starting at frame 0, assuming scene change detection is not triggered from frames 0-49, frame 50 will be an IDR... UNLESS frames 51-74 are flagged by scene change detection, in which case the earliest of those will be the IDR. At least.. I think I did the math right there I always have to think twice about duration vs frame number etc! Last edited by Blue_MiSfit; 4th June 2020 at 23:24. |
|
|
|