是什么导致“未指定的像素格式”和“打开过滤器错误!” ffmpeg错误?

时间:2019-02-17 09:34:14

标签: ffmpeg mp4 hls

我正在编写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的大小无关。

1 个答案:

答案 0 :(得分:0)

事实证明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的样子。工人正在大声疾呼。

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" ]