Opened 6 months ago

Last modified 3 weeks ago

#6375 reopened defect

[bug][regression] Too many packets buffered for output stream

Reported by: p137 Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: regression
Cc: cus Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
Trying to transcode some video file fails in the latest ffmpeg master with this message:
Too many packets buffered for output stream 0:1.

It works in 3.2.4 and stopped working in 3.3.0. Using git bisect I could identify this commit as the first bad commit: af1761f7b5b1b72197dc40934953b775c2d951cc

How to reproduce:

% ffmpeg -y -i "./too_many_packets_buffered_example.mp4" -f mp4 out.mp4
ffmpeg version N-83725-gaf1761f7b5 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/Users/peter/ffmpeg_latest --disable-doc
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/peter/Downloads/too_many_packets_buffered_example.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.25.101
  Duration: 00:00:32.46, start: 0.000000, bitrate: 133 kb/s
    Stream #0:0(und): Audio: aac (Main) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Stream #0:1(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1024x768, 4 kb/s, 1.95 fps, 100 tbr, 19200 tbn, 1200 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> mpeg4 (native))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Too many packets buffered for output stream 0:1.
[aac @ 0x7fa762809000] Qavg: 639.028
[aac @ 0x7fa762809000] 2 frames left in the queue on closing
Conversion failed!

Attachments (5)

too_many_packets_buffered_example.mp4 (527.3 KB) - added by p137 6 months ago.
sample video
ffmpeg-20170505-182833.log (16.8 KB) - added by p137 6 months ago.
Output for running with -report
video_info.log (200.7 KB) - added by p137 6 months ago.
result of running "ffmpeg -v 9 -loglevel 99 -i ./too_many_packets_buffered_example.mp4"
46564100.mp3 (931.9 KB) - added by NoX 4 months ago.
mp3 with png cover
ffmpeg-20170726-150739.log (18.7 KB) - added by t.rapp 3 months ago.

Download all attachments as: .zip

Change History (20)

Changed 6 months ago by p137

sample video

Changed 6 months ago by p137

Output for running with -report

Changed 6 months ago by p137

result of running "ffmpeg -v 9 -loglevel 99 -i ./too_many_packets_buffered_example.mp4"

comment:1 Changed 6 months ago by cus

  • Cc cus added
  • Keywords regression added
  • Priority changed from normal to important
  • Reproduced by developer set

comment:2 follow-up: Changed 6 months ago by gjdfgh

  • Resolution set to worksforme
  • Status changed from new to closed

Not a bug. The file has somewhat sparse video or audio frames, and increasing the packet queue size helps:

ffmpeg -i too_many_packets_buffered_example.mp4 -max_muxing_queue_size 400 out.mp4

comment:3 in reply to: ↑ 2 Changed 5 months ago by cehoyos

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Replying to gjdfgh:

Not a bug. The file has somewhat sparse video or audio frames, and increasing the packet queue size helps:

The explanation contradicts the resolution...

comment:4 Changed 5 months ago by lucasstreamable

I can second this issue. Just started popping up with 3.3. Extending the queue size does not fix it.

comment:5 Changed 5 months ago by rogerz42892

I can third this issue. We have many examples of this failure. Providing the -max_muxing_queue_size argument is a workaround, but not a fix.

comment:6 Changed 5 months ago by ObvB

Additional data point ... just in case it helps ...

I was encountering this problem on a Raspberry Pi 2.

pi:~/ffmpeg_sources/ffmpeg-3.3$ ./ffmpeg -vcodec mpeg2_mmal -i CBS-Evening-News-With-Scott-Pelley.ts -f null -
ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --enable-mmal --enable-decoder=mpeg2_mmal --enable-decoder=mpeg4_mmal --enable-decoder=h264_mmal
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
Input #0, mpegts, from 'CBS-Evening-News-With-Scott-Pelley.ts':
  Duration: 00:30:00.50, start: 24953.710244, bitrate: 16569 kb/s
  Program 1
    Stream #0:0[0x31]: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p(top first), 320x240, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x35](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, mono, fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (mpeg2_mmal) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (ac3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Too many packets buffered for output stream 0:1.
Conversion failed!
pi:~/ffmpeg_sources/ffmpeg-3.3$

When attempting to decode an HD ATSC broadcast TV .ts file made by tvheadend, using the decoder mpeg2_mmal, it failed with the message "Too many packets buffered for output stream"

Decoding without specifying the mmal decoder worked.
Decoding an SD (704x480) file worked with (and without) using decoder mpeg2_mmal
ffmpeg 3.2.4 worked in all of the above cases.

As a workaround, allocating more memory to the GPU worked. Setting gpu_mem=256 in /boot/config.txt "fixes" the problem in my case.

comment:7 follow-up: Changed 4 months ago by MarcSB

We have the same problem with some videos. Increasing the max_muxing_queue_size param didn't help.

With ffmpeg 3.2.4 everything works fine.

comment:8 in reply to: ↑ 7 Changed 4 months ago by cus

Replying to MarcSB:

We have the same problem with some videos. Increasing the max_muxing_queue_size param didn't help.

With ffmpeg 3.2.4 everything works fine.

Please provide a sample and a sample command line where increasing max_muxing_queue_size does not help.

comment:9 Changed 4 months ago by NoX

Similar problem with ffmpeg 3.3.2 and MP3-file with PNG cover.
-max_muxing_queue_size 9999 resolve problem.
No problems with ffmpeg 3.2.6

ionice -c 3 nice /usr/bin/ffmpeg -y -i "/home/nox/46564100.mp3" -acodec libmp3lame -ab 128k -ac 2 "/home/nox/46564100_b128f0d146.mp3"
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (Gentoo 6.3.0 p1.0)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-3.3.2/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -march=native -pipe -fomit-frame-pointer' --disable-static --enable-avfilter --enable-avresample --disable-stripping --enable-version3 --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --enable-version3 --enable-version3 --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --disable-gnutls --enable-gmp --enable-gpl --enable-hardcoded-tables --enable-iconv --disable-lzma --disable-network --disable-openssl --enable-postproc --disable-libsmbclient --disable-ffplay --disable-sdl2 --disable-vaapi --disable-vdpau --disable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --disable-opengl --disable-libv4l2 --disable-libpulse --enable-libopencore-amrwb --enable-libopencore-amrnb --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libcelt --disable-libgme --disable-libgsm --disable-mmal --disable-libmodplug --disable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libschroedinger --disable-libspeex --disable-libvorbis --disable-libvpx --disable-libzvbi --disable-libbs2b --disable-chromaprint --disable-libflite --disable-frei0r --disable-libfribidi --enable-fontconfig --disable-ladspa --disable-libass --enable-libfreetype --disable-librubberband --disable-netcdf --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --enable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --disable-nvenc --disable-libopenh264 --disable-libsnappy --disable-libtheora --disable-libtwolame --disable-libwavpack --disable-libwebp --enable-libx264 --disable-libx265 --disable-libxvid --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx2 --disable-fma3 --disable-fma4 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Incorrect BOM value
Error reading comment frame, skipped
Incorrect BOM value
Error reading lyrics, skipped
[mp3 @ 0xad3400] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/home/nox/46564100.mp3':
  Metadata:
    title           : 24дня [Новый Рэп] Это реальный трек От реальных реалистов Про реальные расклады В реале Я не тру мы true (ахаха) Я уверин на все сто что, Ты ты ты ▒
    artist          : [muzmo.ru] Allj(Элджей)
    album           : [muzmo.ru]
    copyright       : http://muzmo.ru
  Duration: 00:02:26.08, start: 0.000000, bitrate: 324 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
    Stream #0:1: Video: png, rgb24(pc), 300x300 [SAR 11811:11811 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      title           : 3.png
      comment         : Other
Stream mapping:
  Stream #0:1 -> #0:0 (png (native) -> png (native))
  Stream #0:0 -> #0:1 (mp3 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Too many packets buffered for output stream 0:1.
[libmp3lame @ 0xb13c60] 4 frames left in the queue on closing
Conversion failed!

Changed 4 months ago by NoX

mp3 with png cover

comment:10 Changed 3 months ago by guillaumekh

Deleted

Last edited 3 months ago by guillaumekh (previous) (diff)

Changed 3 months ago by t.rapp

comment:11 Changed 3 months ago by t.rapp

Also stumbled over the issue with FFmpeg v3.3.2 (see attached report file). In my case I was able to work-around the issue by limiting the number of threads with "-threads 2".

Further noticed that the log output contains a lot of "cur_dts is invalid" lines.

comment:12 Changed 3 months ago by afarah

I have a specific video file (below) which ffmpeg from git-master (at 1193301758b8af2ccd05e0dba5c4320e1e0702ac) fails to process with Too many packets buffered for output stream 0:1, unless -max_muxing_queue_size 9999 is passed as an argument, as reported by NoX (above). The input video file was successfully generated using ffmpeg itself (more precisely with ffmpeg -i original.mp4 -ss 01:34:56 -t 00:00:38 -c copy input.mp4, where original.mp4 is a 3GB file, using ffmpeg 3.2.4).

Full command line to reproduce the error: ffmpeg -v 9 -loglevel 99 -i input.mp4 /tmp/out.mp4

[Full output for ffmpeg from git master](https://paste.ubuntu.com/25224478/).

ffmpeg 3.2.4 fails with a different error than the one from git master, and passing the aforementioned parameter does not fix the issue. Namely, it fails with Unable to parse option value "-1" as pixel format. [Compile options, full command line and output](https://paste.debian.net/plainh/7c7a9177). I can provide more info if necessary. Notice that I built ffmpeg from git master on a Debian system whereas 3.2.4 was built on Gentoo (I can (re)build both on the same system if need be).

The file is 20MB so [externally uploaded](http://inf.ufrgs.br/~afarah/files/ffmpeg_bug_report.mp4), sorry, making it shorter "solves" the issue.

comment:13 Changed 8 weeks ago by keynet

I've also experienced this with recent git N-87068-g8a0954dd51 on some DVB recordings converted by ffmpeg last year. It happens on recordings with sparse AAC-LC sound tracks (Audio Description). I had some issues last year playing back AD streams converted to AAC (or MP3 actually), so now the vdr-convert script only copies these MP2 tracks, it doesn't try to compress to anything more modern. The ones giving me trouble are some test conversions that got away.

I set -max_muxing_queue_size 4000 and it's OK so far.

comment:14 Changed 4 weeks ago by lkiesow

Same issue here with 3.3.4 and some input files. Using -max_muxing_queue_size 1000 solved the issue for me but since it seems to be more common than expected, I am wondering if it would make sense to increase the default value?

comment:15 Changed 3 weeks ago by brinaca

It looks like the default value is 128? With -max_muxing_queue_size 400 we're still occasionally hitting errors.

If it is advised that we tweak this option to workaround the issue, can you please provide some further guidance on what is a sane range of values? In this report I see 400, 1000, and 9999 all mentioned. https://ffmpeg.org/ffmpeg.html#Advanced-options states "The default value of this option should be high enough for most uses, so only touch this option if you are sure that you need it.", which makes me feel like we probably don't want to be configuring this value too high over the default.

Note: See TracTickets for help on using tickets.