FFmpeg的那些坑-Too many packets buffered for output stream

前言

文章首发于Noah Sun’s Home FFmpeg的那些坑-Too many packets buffered for output stream

FFmpeg使用场景

使用FFmpeg给视频打水印

ffmpeg -i test.mp4 -i watermark.png -acodec copy -preset veryfast -filter_complex "overlay=x=20:y=20" -y wm_test.mp4

问题

报错Too many packets buffered for output stream 0:1.

ffmpeg version 3.3-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-8) 20170304
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  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
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.100
  Duration: 00:00:26.94, start: 0.000000, bitrate: 434 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 360x640, 367 kb/s, 6.16 fps, 14 tbr, 14336 tbn, 28 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, png_pipe, from 'watermark.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, pal8(pc), 205x39, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (h264) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
Too many packets buffered for output stream 0:1.
Conversion failed!

原因

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

解决办法

增大容器封装队列大小,比如

-max_muxing_queue_size 1024
ffmpeg -i test.mp4 -i watermark.png -max_muxing_queue_size 1024 -acodec copy -preset veryfast -filter_complex "overlay=x=20:y=20" -y wm_test.mp4

你可能感兴趣的:(FFmpeg,音视频)