转换flv1(flv)时的FFMPEG错误 - > h264(libx264)

时间:2016-07-03 13:13:23

标签: ffmpeg mp4 codec flv video-encoding

我正在尝试将mpv格式视频转换为带有mp4格式视频的h264编解码器,但面临以下错误:

我执行的命令:

ffmpeg -i input_video.flv -c:v libx264 output.mp4

错误: 打开输出流#0的编码器时出错:1 - 可能是不正确的参数,如bit_rate,rate,width或height

日志:

ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --enable-opencl --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, flv, from 'input.flv':
  Metadata:
    encoder         : Lavf53.24.2
  Duration: 00:00:53.32, start: 0.000000, bitrate: 787 kb/s
    Stream #0:0: Video: flv1, yuv420p, 320x240, 500 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, 5.1, fltp, 384 kb/s
[libx264 @ 0x7ff885000c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7ff885000c00] profile High, level 1.3
[libx264 @ 0x7ff885000c00] 264 - core 144 r2533 c8a773e - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libvo_aacenc @ 0x7ff885001e00] Unable to set encoding parameters
Output #0, mp4, to 'output1.mp4':
  Metadata:
    encoder         : Lavf53.24.2
    Stream #0:0: Video: h264 (libx264), yuv420p, 320x240, q=-1--1, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.41.100 libx264
    Stream #0:1: Audio: aac, 0 channels, 128 kb/s
    Metadata:
      encoder         : Lavc56.41.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (flv1 (flv) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

这可能是什么原因?

1 个答案:

答案 0 :(得分:1)

更新:根据Q中现在包含的控制台输出,该错误与视频无关,但如果有人发现此问题,我会在下面留下我之前的答案从视频编码器获得相同的错误。

第三方AAC编码器报告错误,该编码器现已过时,仅支持两个通道。

有三种方法可以解决这个问题:

#1 复制音频流

ffmpeg -i input.flv -c:a copy output.mp4

#2 升级到最近的FFmpeg并在问题中运行原始命令

#3 使用当前二进制和旧编码器(最少推荐)重新编码

ffmpeg -i input.flv -ac 2 -b:a 128k -strict -2 output.mp4

旧答案: 造成此错误的最常见原因是尺寸不是2的倍数,FFmpeg使用像素编码YUV420P输出,这需要它们。

尝试

ffmpeg -i input.flv -vf "scale=2*trunc(iw/2):-2" output.mp4

比例过滤器使两个尺寸均匀。