解决FFmpeg抛出的“Too many packets buffered for output stream 0:1.”异常

1. 异常复现

in.mp4转为out.mp4

ffmpeg -i .\in.mp4 out.mp4

提示:

ffmpeg version 4.2.3 Copyright © 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘.\in.mp4’:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.28.101
Duration: 00:17:10.33, start: 0.000000, bitrate: 155 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1024x768, 84 kb/s, 3 fps, 3 tbr, 12288 tbn, 6 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Too many packets buffered for output stream 0:1.
[aac @ 000001fe3eace600] Qavg: 123.130
[aac @ 000001fe3eace600] 2 frames left in the queue on closing
Conversion failed!

2. 解决办法

该异常抛出的原因是有些视频数据有问题,导致视频处理过快,容器封装时队列溢出。

我们可以增大容器封装队列大小来解决,比如设置一下最大封装队列的大小为1024:

-max_muxing_queue_size 1024

具体完整的用法如下:

ffmpeg -i .\in.mp4 -max_muxing_queue_size 1024 out.mp4
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页