ffmpeg - 是什么导致 ffmpeg 中出现 "unspecified pixel format"和 "Error opening filters!"错误?

标签 ffmpeg mp4 http-live-streaming

我正在编写一个 mp4 到 HLS 转码过程,该过程在小于 7 GB 的文件(样本大小为 100 个视频)上按预期工作。尝试对大于 7GB 的任何内容进行转码时,它会崩溃。

命令:

ffmpeg 
  -i large_file.mp4 -y 
  -vf scale=w=1920:h=1080:force_original_aspect_ratio=decrease 
  -c:a aac 
  -ar 48000 
  -c:v h264 
  -profile:v main 
  -crf 20 
  -sc_threshold 0 
  -g 48 
  -keyint_min 48 
  -hls_time 4 
  -hls_playlist_type vod 
  -b:v 5000k 
  -maxrate 5350k 
  -bufsize 7500k 
  -b:a 192k 
  -hls_segment_filename /1080p_%03d.ts 
  -threads 0 
  /tmp/output-ef42dc65-1d3d-4682-b32b-68d7c712fb9c-raw-test/1080p.m3u8

错误:
ffmpeg version 3.2.12-1\x7edeb9u1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x555888d821c0] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720, 3856 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'large_file.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.26.101
  Duration: 05:56:12.51, start: 0.000000, bitrate: 4061 kb/s
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), none, 1280x720, 3856 kb/s, 29.99 fps, 30 tbr, 100k tbn, 200k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 194 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[buffer @ 0x555888d88180] Unable to parse option value "-1" as pixel format
    Last message repeated 1 times
[buffer @ 0x555888d88180] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x555888d81e40] Error applying options to the filter.
Error opening filters!

错误提示尝试增加 analyzedurationprobesize ,我将其设置为最大值(基于 this 帖子的回答),但这似乎并没有改变行为。我还怀疑该文件已损坏,但是对于所有大于 7GB 的文件都失败了,这使得建议它与 mp4 的大小无关的事情变得更加困难。

最佳答案

comment by Gyan结果证明是正确的。我们使用 docker 进行部署(转码器是利用 fluent-ffmpeg 的 node.js),因此升级并不像您想象的那么简单,因为我们需要在同一个镜像中进行多个构建(也称为多阶段构建) .

我们遇到的问题:

  • ffmpeg image by jrottenberg继续生产error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or director .有一个issue开着,虽然
    没有提供解决方案,我自己也找不到解决方案。
  • 我们找到了 ffmpeg 4.1 image by alfg , 但是,那
    可执行文件放在opt/ffmpeg/bin而不是我们预期的地方
    它是,/usr/local/bin .

  • 鉴于此,这就是我们的 Dockerfile 的样子。 worker 正在大文件中发出呼噜声。
    FROM alfg/ffmpeg AS ffmpeg # stored at /opt/ffmpeg/bin/ffmpeg
    FROM node:10.10.0-alpine AS build
    RUN npm install --global yarn@1.10.1
    WORKDIR /app
    # need these for native libraries like bcrypt
    RUN apk update && apk add python g++ make && rm -rf /var/cache/apk/*
    COPY . ./
    RUN yarn install --pure-lockfile
    
    FROM node:10.10.0-alpine
    COPY --from=build /usr/lib/libgcc* /usr/lib/libstdc* /usr/lib/
    COPY --from=ffmpeg / /
    COPY --from=build /app /
    
    # add ffmpeg's location to path
    ENV PATH="/opt/ffmpeg/bin/:${PATH}"
    
    CMD [ "yarn", "start" ]
    

    关于ffmpeg - 是什么导致 ffmpeg 中出现 "unspecified pixel format"和 "Error opening filters!"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54731858/

    相关文章:

    video - 为什么从 avi 容器解码帧并将它们编码为 h264/mp​​4 不起作用?

    bash - Mac 终端命令列出文件并按日期排序以在 ffmpeg 中使用

    ffmpeg - 加速视频编码

    windows - IMFMediaSink无法在具有AMD GPU的PC上添加第二个音频输出流

    c - FFmpeg 解码 .mp4 视频文件

    ios - SDL 在 iOS 上保存屏幕截图

    video - 调试由 VLC 但不是由 ffplay 打开的 MP4

    objective-c - iOS:直播AVPlayer

    mediaelement.js - 用m3u8播放列表播放分段的hls流

    nginx - 接收 HLS 流并重播