[FFmpeg-user] buffer underflow when muxing with ntsc-dvd

Matthew Morgan matthew at lifandi.org
Wed May 15 03:22:01 CEST 2013


I've been using Cinelerra for a while to generate DVD's, and my workflow
involves: rendering the audio and video separately from Cinelerra,
muxing them with ffmpeg using -target ntsc-dvd, then following the
normal dvd-author workflow after that.  Up until recently there'd been a
different bug that prevent me from using the latest ffmpeg for this, but
that bug had been fixed.  So, I did a git merge a few days ago and
compiled the latest version of ffmpeg.

Now I'm having a weird problem with the muxing process.  The video file
in question is actually a slideshow of still images with a crossfade
transition between each, thus the stream doesn't demand a very high
bitrate.  When I try to mux that file with its corresponding audio, I
get this:  (note, in the example I'm using a shorter test version of the
file - same results).

ffmpeg -i test.m2v -i test.wav -target ntsc-dvd test.mpg
ffmpeg version N-53018-ge70e258 Copyright (c) 2000-2013 the FFmpeg
developers
  built on May 13 2013 07:50:37 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/opt/mmedia --enable-libxvid --enable-gpl
--enable-libtheora --enable-libmp3lame --enable-libfaac --enable-nonfree
--enable-libv4l2 --enable-x11grab --enable-libvpx
  libavutil      52. 30.100 / 52. 30.100
  libavcodec     55.  9.100 / 55.  9.100
  libavformat    55.  7.100 / 55.  7.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 65.100 /  3. 65.100
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpegvideo @ 0xa2b9d20] max_analyze_duration 5000000 reached at 5005000
microseconds
Input #0, mpegvideo, from 'test.m2v':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR
4:3], 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc
[wav @ 0xa413900] max_analyze_duration 5000000 reached at 5013333
microseconds
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, wav, from 'test.wav':
  Duration: 00:02:54.71, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo, s16, 1536 kb/s
Output #0, dvd, to 'test.mpg':
  Metadata:
    encoder         : Lavf55.7.100
    Stream #0:0: Video: mpeg2video, yuv420p, 720x480 [SAR 8:9 DAR 4:3],
q=2-31, 6000 kb/s, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> mpeg2video)
  Stream #1:0 -> #0:1 (pcm_s16le -> ac3)
Press [q] to stop, [?] for help
buffer underflow i=1 bufi=1657 size=1792B time=00:02:44.76
bitrate=2322.6kbits/s   
[dvd @ 0xa2ca900] buffer underflow i=1 bufi=1657 size=1792
    Last message repeated 2 times
buffer underflow i=1 bufi=1664 size=1792B time=00:02:52.85
bitrate=2270.1kbits/s   
[dvd @ 0xa2ca900] buffer underflow i=1 bufi=1664 size=1792
    Last message repeated 2 times
frame= 5236 fps=173 q=2.0 Lsize=   48212kB time=00:02:54.71
bitrate=2260.6kbits/s   
video:37146kB audio:9555kB subtitle:0 global headers:0kB muxing overhead
3.234747%

Using the full version of the file, I get a LOT more of those buffer
underflows, but you get the idea.  It turns out that the older version
of ffmpeg that I'd been using (0.10.6) had this problem too.  A bit of
research on google led me a to a post which suggested using `-minrate
1000k` after `-target ntsc-dvd` in my command line.  This got rid of the
buffer underflows in 0.10.6, but not my git build.  With all this
weirdness, I decided I'd better poke around the input file and see if I
could figure out what was weird, and I just ran into more weirdness.

Here's an ffprobe of the input file using my git version of ffmpeg:
ffprobe version N-53018-ge70e258 Copyright (c) 2007-2013 the FFmpeg
developers
  built on May 13 2013 07:50:37 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/opt/mmedia --enable-libxvid --enable-gpl
--enable-libtheora --enable-libmp3lame --enable-libfaac --enable-nonfree
--enable-libv4l2 --enable-x11grab --enable-libvpx
  libavutil      52. 30.100 / 52. 30.100
  libavcodec     55.  9.100 / 55.  9.100
  libavformat    55.  7.100 / 55.  7.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 65.100 /  3. 65.100
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpegvideo @ 0xa0929a0] max_analyze_duration 5000000 reached at 5005000
microseconds
Input #0, mpegvideo, from 'test.m2v':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR
4:3], 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc

What?  It doesn't know what the bitrate is?

Here's the output of ffprobe from 0.10.6:
ffprobe version 0.10.6 Copyright (c) 2007-2012 the FFmpeg developers
  built on Mar 14 2013 20:38:10 with gcc 4.6.3
  configuration: --prefix=/opt/mmedia --enable-libxvid --enable-gpl
--enable-libtheora --enable-libmp3lame --enable-libfaac --enable-nonfree
--enable-libv4l2 --enable-x11grab --enable-libvpx
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[mpegvideo @ 0x9ca6ce0] max_analyze_duration 5000000 reached at 5005000
[mpegvideo @ 0x9ca6ce0] Estimating duration from bitrate, this may be
inaccurate
Input #0, mpegvideo, from 'test.m2v':
  Duration: 00:00:33.68, bitrate: 8999 kb/s
    Stream #0:0: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR
4:3], 9000 kb/s, 29.97 fps, 29.97 tbr, 1200k tbn, 59.94 tbc

It works fine!

The weirdest part of it all is that Cinelerra is actually using ffmpeg
to create the m2v in the first place!  The git version is what's in my
path so it's using that.  Here's the Cinelerra output from creating the
m2v in the first place:
ffmpeg version N-53018-ge70e258 Copyright (c) 2000-2013 the FFmpeg
developers
  built on May 13 2013 07:50:37 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/opt/mmedia --enable-libxvid --enable-gpl
--enable-libtheora --enable-libmp3lame --enable-libfaac --enable-nonfree
--enable-libv4l2 --enable-x11grab --enable-libvpx
  libavutil      52. 30.100 / 52. 30.100
  libavcodec     55.  9.100 / 55.  9.100
  libavformat    55.  7.100 / 55.  7.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 65.100 /  3. 65.100
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, yuv4mpegpipe, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x480,
SAR 10:11 DAR 15:11, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
Assuming NTSC for target.
Output #0, mpeg2video, to
'/home/lytithwyn/Videos/grandma_memorial/test.m2v':
  Metadata:
    encoder         : Lavf55.7.100
    Stream #0:0: Video: mpeg2video, yuv420p, 720x480 [SAR 10:11 DAR
15:11], q=2-31, 6000 kb/s, 90k tbn, 29.97 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
frame= 5236 fps= 69 q=2.0 Lsize=   37003kB time=00:02:54.67
bitrate=1735.4kbits/s   
video:37003kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.000000%

I hope I haven't overloaded you with command line output, but I didn't
know what else to do.  ;)

Here are download links for the sample files:
http://lifandi.org/ffmpeg/test.m2v (37 MB)
http://lifandi.org/ffmpeg/test.wav (32 MB)


More information about the ffmpeg-user mailing list