Welcome to Doom9's Forum, THE inplace 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. 


Thread Tools  Search this Thread  Display Modes 
29th December 2019, 04:33  #1  Link 
Registered User
Join Date: Feb 2017
Posts: 13

Libav/ffmpeg transcoding code showing MB rate (125337600) > level limit (2073600)
I'm writing a part of a tutorial of libav/ffmpeg that is focused at the transcoding process.
The code is working but it's showing the, I suppose from x264 lib, message: Code:
MB rate (125337600) > level limit (983040) Code:
encoder_codec_context>profile = FF_PROFILE_H264_HIGH_422; encoder_codec_context>level = 51; 
29th December 2019, 10:10  #2  Link 
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,240

Never used libav, but with x264 cli you need to set the vbv restrictions settings properly otherwise level&profile will only be signaled, but not really used.
> my guess is you also need to properly set the vbv restrictions to avoid the message. 
29th December 2019, 15:35  #6  Link  
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 6,240

Quote:
Code:
profile high level 5.1 vbvmaxrate 300000vbvbufsize 300000 level;maxrate 5.2;240000 5.1;240000 5.0;135000 5;135000 4.2;62500 4.1;62500 4.0;25000 4;25000 3.2;20000 3.1;14000 3.0;10000 3;10000 2.2;4000 2.1;4000 2.0;2000 2;2000 1.3;2000 1.2;1000 1.1;500 1b;350 1.0;175 times 1.25 in case high is used. see also https://github.com/FFmpeg/FFmpeg/blo.../h264_levels.c or h.264 specs for the base data. Cu Selur 

29th December 2019, 16:05  #7  Link  
Registered User
Join Date: Feb 2017
Posts: 13

Thanks, it makes sense. I tried to set manually the rc control but it didn't work, I'll continue researching to see if this is the right way to do it with libav.
Quote:


29th December 2019, 23:21  #8  Link 
Registered User
Join Date: Jul 2007
Posts: 537

This doesn't say me anything about which exact resolution and fps was your sample. This warining doesn't have anything todo with VBV and caused by too big or incorrect resolution*fps i.e. context fields: width, height, framerate.num, framerate.den (and time_base.den, time_base.num, ticks_per_frame if framerate field wasn't specified). By bet is that your framerate is not specified (i.e. zero and VFR timebase is used) or incorrect.

29th December 2019, 23:48  #9  Link  
Registered User
Join Date: Feb 2017
Posts: 13

Quote:
Quote:
Quote:
Last edited by leandro; 30th December 2019 at 00:01. 

30th December 2019, 01:22  #10  Link 
Registered User
Join Date: Jul 2007
Posts: 537

Code:
MB rate = (width+15)/16 * (height+15)/16 * tb.den / (tb.num * ticks) = (1920+15)/16 * (1080+15)/16 * 15360 / (1 * 1) = 120 * 68 * 15360 = 125337600 Code:
MB rate = (width+15)/16 * (height+15)/16 * fr.num / fr.den 
30th December 2019, 01:37  #11  Link  
Registered User
Join Date: Feb 2017
Posts: 13

Quote:
Code:
LOG: Video LOG: ================================================= LOG: decoder LOG: AVFormatContext LOG: start_time=0 duration=10022000 bit_rate=2631572 start_time_realtime=0 LOG: AVCodecContext LOG: bit_rate=2228686 ticks_per_frame=2 width=1920 height=1080 gop_size=12 keyint_min=25 sample_rate=0 profile=100 level=42 LOG: avc>time_base=num/den 0/2 LOG: avc>framerate=num/den 0/1 LOG: avc>pkt_timebase=num/den 0/1 LOG: AVStream LOG: index=0 start_time=0 duration=153600 LOG: avs>time_base=num/den 1/15360 LOG: avs>sample_aspect_ratio=num/den 1/1 LOG: avs>avg_frame_rate=num/den 60/1 LOG: avs>r_frame_rate=num/den 60/1 LOG: ================================================= LOG: Video LOG: ================================================= LOG: encoder LOG: AVFormatContext LOG: start_time=0 duration=0 bit_rate=0 start_time_realtime=0 LOG: AVCodecContext LOG: bit_rate=0 ticks_per_frame=1 width=1920 height=1080 gop_size=1 keyint_min=1 sample_rate=0 profile=99 level=99 LOG: avc>time_base=num/den 1/15360 LOG: avc>framerate=num/den 0/1 LOG: avc>pkt_timebase=num/den 0/1 LOG: AVStream LOG: index=0 start_time=0 duration=0 LOG: avs>time_base=num/den 1/15360 LOG: avs>sample_aspect_ratio=num/den 0/1 LOG: avs>avg_frame_rate=num/den 0/0 LOG: avs>r_frame_rate=num/den 0/0 LOG: ================================================= LOG: ================================================= LOG: Audio LOG: ================================================= LOG: decoder LOG: AVFormatContext LOG: start_time=0 duration=10022000 bit_rate=2631572 start_time_realtime=0 LOG: AVCodecContext LOG: bit_rate=393736 ticks_per_frame=1 width=0 height=0 gop_size=0 keyint_min=0 sample_rate=48000 profile=1 level=99 LOG: avc>time_base=num/den 1/48000 LOG: avc>framerate=num/den 0/1 LOG: avc>pkt_timebase=num/den 0/1 LOG: AVStream LOG: index=1 start_time=0 duration=480000 LOG: avs>time_base=num/den 1/48000 LOG: avs>sample_aspect_ratio=num/den 0/1 LOG: avs>avg_frame_rate=num/den 0/0 LOG: avs>r_frame_rate=num/den 0/0 LOG: ================================================= LOG: ================================================= LOG: Audio LOG: ================================================= LOG: encoder LOG: AVFormatContext LOG: start_time=0 duration=0 bit_rate=0 start_time_realtime=0 LOG: AVCodecContext LOG: >NULL LOG: AVStream LOG: index=1 start_time=0 duration=0 LOG: avs>time_base=num/den 0/0 LOG: avs>sample_aspect_ratio=num/den 0/1 LOG: avs>avg_frame_rate=num/den 0/0 LOG: avs>r_frame_rate=num/den 0/0 LOG: ================================================= Last edited by leandro; 30th December 2019 at 01:45. 

30th December 2019, 02:08  #12  Link 
Registered User
Join Date: Feb 2017
Posts: 13

Now the encoder AVStream is using the same timing parameters as the decoder but I'm still seeing the messages, I'm gonna try to equalize AVCodecContext next.
Code:
LOG: Video LOG: ================================================= LOG: decoder LOG: AVFormatContext LOG: start_time=0 duration=10022000 bit_rate=2631572 start_time_realtime=0 LOG: AVCodecContext LOG: bit_rate=2228686 ticks_per_frame=2 width=1920 height=1080 gop_size=12 keyint_min=25 sample_rate=0 profile=100 level=42 LOG: avc>time_base=num/den 0/2 LOG: avc>framerate=num/den 0/1 LOG: avc>pkt_timebase=num/den 0/1 LOG: AVStream LOG: index=0 start_time=0 duration=153600 LOG: avs>time_base=num/den 1/15360 LOG: avs>sample_aspect_ratio=num/den 1/1 LOG: avs>avg_frame_rate=num/den 60/1 LOG: avs>r_frame_rate=num/den 60/1 LOG: ================================================= LOG: Video LOG: ================================================= LOG: encoder LOG: AVFormatContext LOG: start_time=0 duration=0 bit_rate=0 start_time_realtime=0 LOG: AVCodecContext LOG: bit_rate=0 ticks_per_frame=1 width=1920 height=1080 gop_size=1 keyint_min=1 sample_rate=0 profile=99 level=99 LOG: avc>time_base=num/den 1/15360 LOG: avc>framerate=num/den 0/1 LOG: avc>pkt_timebase=num/den 0/1 LOG: AVStream LOG: index=0 start_time=0 duration=153600 LOG: avs>time_base=num/den 1/15360 LOG: avs>sample_aspect_ratio=num/den 1/1 LOG: avs>avg_frame_rate=num/den 60/1 LOG: avs>r_frame_rate=num/den 60/1 LOG: ================================================= 
30th December 2019, 02:18  #13  Link 
Registered User
Join Date: Feb 2017
Posts: 13

The message MB rate (125337600) > level limit (983040) is gone. I first tried to equalize the timing parameters for AVStream but it didn't solve then I tried to replicate the AVCodecContext from the decoder to the encoder but I couldn't because its tb was `0/2` what I did was to set the AVCodecContext>tb = AVStream>avg_frame_rate it worked but I really didn't understand what I did and I'm not sure if that will cause another problem.
The message forced frame type (5) at 80 was changed to frame type (3) is still showing up but this seems to be a warning expected from the gop conversion. Last edited by leandro; 30th December 2019 at 02:41. 
Tags 
ffmpeg, h264, level, libav, profile 
Thread Tools  Search this Thread 
Display Modes  

