Michael Niedermayer <[email protected]> added the comment:

On Thu, May 14, 2009 at 08:02:38PM +0000, Francois Visagie wrote:
> SITUATION AND PROBLEM DESCRIPTION
> ---------------------------------
> 
> Under certain conditions, lavc mpeg2video's -maxrate 
> option produces buffer underflow when transcoding from 
> DV AVI to DVD-compliant MPEG-2. I am using a Windows 
> XP SP3 system with FFmpeg 0.5.
> 
> COMMAND LINE 1
> --------------
> 
> I can 100% reliably recreate the buffer underflow 
> condition with the command line:
>  
> ffmpeg -top 0 -async 0 -nr 100 -i %AVSCRIPT% -aspect 
> 4:3 -target pal-dvd -muxrate 9928000 -acodec ac3 -ab 
> 128000 -flags ildct+ilme -g 15 -maxrate 9800000 -
> vcodec mpeg2video -b 9000000 -pass %PASS% %OUTPUT%
>  
> Although that bitrate is high, it's still legal and 

no, it is not, you have a audio bitrate of 128k and a video bitrate of
9800kbit that is too much for a muxrate of 9928kbit, mpeg-ps is not
 just raw audio + raw video, there are also mpeg-ps specific things that need
bits.

> was chosen to force the lavc mpeg2video buffer 
> underflow issue with my test clip. Much lower bitrates 
> (e.g. 5800) also produce buffer underflows on  
> production length videos, but then it's much more 
> difficult to find and create a short test clip that 
> reproduces the problem. (And encoding the production 
> video takes ~55h each time!)
> 
> -muxrate was chosen to indicate exceeded mux rate as 
> soon as video exceeds the allowed bitrate.
> 
> With the chosen settings this command line does not 
> exceed -maxrate by impressively much for the sample 
> clip below. However, on production length videos, or 
> by adding -mbd 2 -trellis and other high-quality 
> settings to this command line, video bitrate can 
> overshoot -maxrate spectacularly, to 11000kbps and 
> beyond in most cases.
> 

> This command line does not include -bufsize as the 
> documentation suggests. This was done on purpose to 
> demonstrate that -maxrate by itself causes buffer 
> underflow. This test was repeated with -bufsize, and 
> also without -maxrate, and results are below.

-target pal-dvd
sets a wide varity of parameters, amongth them bufsize so your
ommision of the bufsize parameter does nothing

> 
> This command line and sample clip should therefore be 
> treated as a valid instance of faulty buffer 
> underflow. More example command lines and their 
> results follow below. Pay particular attention to peak 
> and average video bitrate values and warnings either 
> reported or not.
> 
> SAMPLE DATA
> -----------
> 
> A sample video file which reproduces the buffer 
> underflow condition with the above command line has 
> been uploaded to 
> <ftp://upload.ffmpeg.org/MPlayer/incoming/lavc 
> mepg2video buffer underflow>. The file is 
> called "Underflow clip 1.rar", it was split into 
> roughly 10MB chunks "Underflow clip 1.rar.chunk1...20" 
> and uploaded. On Windows systems the video file can be 
> reconstituted with the uploaded batch file 
> Unde_Merge.bat, or the constituent files "Underflow 
> clip 1.rar.chunk1...20" can be similarly concatenated 
> with the cat command on ...x systems.
> 
> COMMAND LINE 1 RESULTS
> ----------------------
> No "impossible bitrate constraints, this will fail" 
> warning
> Buffer underflow

> Video Peak 9845 Average 8398

What tool was used to find these 2 values?

> 
> COMMAND LINE 1 CONSOLE OUTPUT
> -----------------------------
> FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice 
> Bellard, et al.
>   configuration: --enable-gpl --enable-postproc --
> enable-swscale --enable-avfilt
> er --enable-avfilter-lavf --enable-pthreads --enable-
> avisynth --enable-libfaac -
> -enable-libfaad --enable-libmp3lame --enable-libspeex -
> -enable-libtheora --enabl
> e-libvorbis --enable-libxvid --enable-libx264 --enable-
> memalign-hack
>   libavutil     49.15. 0 / 49.15. 0
>   libavcodec    52.20. 0 / 52.20. 0
>   libavformat   52.31. 0 / 52.31. 0
>   libavdevice   52. 1. 0 / 52. 1. 0
>   libavfilter    0. 4. 0 /  0. 4. 0
>   libswscale     0. 7. 1 /  0. 7. 1
>   libpostproc   51. 2. 0 / 51. 2. 0
>   built on Mar 16 2009 16:09:18, gcc: 4.2.4 [Sherpya]
> Input #0, avs, from 'INPUT.AVS':
>   Duration: 00:01:12.76, start: 0.000000, bitrate: 0 
> kb/s
>     Stream #0.0: Video: rawvideo, yuyv422, 720x576, 
> 165888 kb/s, 25 tbr, 25 tbn,
>  25 tbc
>     Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 
> s16, 1536 kb/s
> Output #0, dvd, to 'C:\Documents and 
> Settings\fvisagie\My Documents\My Videos\Ho
> me Videos\Testing\Underflow clip 1\Underflow clip 
> 1.avi.37.mpg':
>     Stream #0.0: Video: mpeg2video, yuv420p, 720x576 
> [PAR 16:15 DAR 4:3], q=2-31
> , pass 1, 9000 kb/s, 90k tbn, 25 tbc
>     Stream #0.1: Audio: ac3, 48000 Hz, stereo, s16, 
> 128 kb/s
> Stream mapping:
>   Stream #0.0 -> #0.0
>   Stream #0.1 -> #0.1
> Press [q] to stop encoding
> frame= 1819 fps= 30 q=1.6 Lsize=   72900kB time=72.72 
> bitrate=8212.3kbits/s
> video:70456kB audio:1136kB global headers:0kB muxing 
> overhead 1.826325%
> FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice 
> Bellard, et al.
>   configuration: --enable-gpl --enable-postproc --
> enable-swscale --enable-avfilt
> er --enable-avfilter-lavf --enable-pthreads --enable-
> avisynth --enable-libfaac -
> -enable-libfaad --enable-libmp3lame --enable-libspeex -
> -enable-libtheora --enabl
> e-libvorbis --enable-libxvid --enable-libx264 --enable-
> memalign-hack
>   libavutil     49.15. 0 / 49.15. 0
>   libavcodec    52.20. 0 / 52.20. 0
>   libavformat   52.31. 0 / 52.31. 0
>   libavdevice   52. 1. 0 / 52. 1. 0
>   libavfilter    0. 4. 0 /  0. 4. 0
>   libswscale     0. 7. 1 /  0. 7. 1
>   libpostproc   51. 2. 0 / 51. 2. 0
>   built on Mar 16 2009 16:09:18, gcc: 4.2.4 [Sherpya]
> Input #0, avs, from 'INPUT.AVS':
>   Duration: 00:01:12.76, start: 0.000000, bitrate: 0 
> kb/s
>     Stream #0.0: Video: rawvideo, yuyv422, 720x576, 
> 165888 kb/s, 25 tbr, 25 tbn,
>  25 tbc
>     Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 
> s16, 1536 kb/s
> Output #0, dvd, to 'C:\Documents and 
> Settings\fvisagie\My Documents\My Videos\Ho
> me Videos\Testing\Underflow clip 1\Underflow clip 
> 1.avi.37.mpg':
>     Stream #0.0: Video: mpeg2video, yuv420p, 720x576 
> [PAR 16:15 DAR 4:3], q=2-31
> , pass 2, 9000 kb/s, 90k tbn, 25 tbc
>     Stream #0.1: Audio: ac3, 48000 Hz, stereo, s16, 
> 128 kb/s
> Stream mapping:
>   Stream #0.0 -> #0.0
>   Stream #0.1 -> #0.1
> [mpeg2video @ 0x1733140][lavc rc] Using all of 
> requested bitrate is not necessar
> y for this video with these parameters.
> Press [q] to stop encoding
> [dvd @ 0x1748010]buffer underflow i=0 bufi=58292 
> size=61037=9896.7kbits/s
> [dvd @ 0x1748010]buffer underflow i=0 bufi=60316 
> size=61037

[...]
> COMMAND LINE 2
> --------------
> 
> Command line 1 with -bufsize 1835000 (DVD spec) added:
> 
> ffmpeg -top 0 -async 0 -nr 100 -i %AVSCRIPT% -aspect 
> 4:3 -target pal-dvd -muxrate 9928000 -acodec ac3 -ab 
> 128000 -flags ildct+ilme -g 15 -maxrate 9800000 -
> bufsize 1835000 -vcodec mpeg2video -b 9000000 -pass %
> PASS% %OUTPUT%
>  
> COMMAND LINE 2 RESULTS
> ----------------------
> No "impossible bitrate constraints, this will fail" 
> warning
> Buffer underflow
> Video Peak 9845 Average 8398
> 

> COMMAND LINE 3
> --------------
> 
> Command line 2 with -maxrate 9800000 removed:

as long as you keep -target pal-dvd there is a maxrate

> 
> ffmpeg -top 0 -async 0 -nr 100 -i %AVSCRIPT% -aspect 
> 4:3 -target pal-dvd -muxrate 9928000 -acodec ac3 -ab 
> 128000 -flags ildct+ilme -g 15 -bufsize 1835000 -
> vcodec mpeg2video -b 9000000 -pass %PASS% %OUTPUT%
>  
> COMMAND LINE 3 RESULTS
> ----------------------
> 
> "impossible bitrate constraints, this will fail" 
> warning displayed
> No buffer underflow
> Video Peak 9113 Average 7739
> Encode is ~50% slower than above two command lines!
> 
> WHAT WE KNOW SO FAR
> -------------------
>  
> a) Buffer underflows seem to occur more severely 
> with "high quality" encodes that involve e.g. -mbd 2 -
> trellis. Both average and peak bitrate are also higher.

> b) Hervé found that reducing -buf_size avoids 
> excessive bitrate, but at the expense of DVD-Video 
> compliance of course. It's unclear whether this was in 
> the presence of the -maxrate option.

what i know is that you guys dont know too much.
a increase in bufsize breaks compliance, a decrease does not normally
also iam not convinced that there is any bug in libav* at all
at least you have not provided a non contradictionary case
that produced any issues

[...]
> CLOSE
> -----
>  
> I am under lots of pressure to finish my current DVD 
> magnum opus soon, and if there's any prospect of 
> investigating and hopefully fixing this bug in the 
> near future, please let me know where I can help with 
> testing and/or more information.

given that you managed to feed ffmpeg with contradictionary
parameters the buffer underflows you report are just a case
of garbage in, garbage out.

If you can provide a minimal command line with non contradictionary
paremeters (you need a gap between muxrate and the sum
of all video and audio max rates),
how large that gap has to be, i dont know but not 0, and also not
0.1%, mpeg-ps is a mildly bloated format it does need some space for its
bloat!

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator

----------
status: open -> closed
substatus: open -> invalid

_____________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/roundup/ffmpeg/issue1081>
_____________________________________________________

Reply via email to