首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ffmpeg:打开编码器时出现Image2 =>错误

ffmpeg:打开编码器时出现Image2 =>错误
EN

Stack Overflow用户
提问于 2012-11-22 16:09:49
回答 2查看 2.7K关注 0票数 2

我得到以下错误ffmpeg。

打开输出流#0:0的编码器时出错-可能是bit_rate、速率、宽度或高度等参数不正确

代码语言:javascript
复制
ffmpeg -f image2 -i %05d.jpg -vcodec libx264 foo.mp4

我很确定我以前用过这个命令,它很好用。这是我的终端输出。任何帮助都将不胜感激。

代码语言:javascript
复制
$ ffmpeg -f image2 -i %05d.jpg -vcodec libx264 foo.mp4
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 22 2012 17:59:05 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
  libavutil      51. 73.101 / 51. 73.101

  libavcodec     54. 59.100 / 54. 59.100

  libavformat    54. 29.104 / 54. 29.104

  libavdevice    54.  2.101 / 54.  2.101

  libavfilter     3. 17.100 /  3. 17.100

  libswscale      2.  1.101 /  2.  1.101

  libswresample   0. 15.100 /  0. 15.100

  libpostproc    52.  0.100 / 52.  0.100

Input #0, image2, from '%05d.jpg':
  Duration: 00:00:04.44, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p, 1201x900 [SAR 1:1 DAR 1201:900], 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x7fab0881aa00] width not divisible by 2 (1201x900)
Output #0, mp4, to 'foo.mp4':
    Stream #0:0: Video: h264, yuvj420p, 1201x900 [SAR 1:1 DAR 1201:900], q=-1--1, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> libx264)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
EN

回答 2

Stack Overflow用户

发布于 2012-11-22 17:13:07

您必须裁剪输入图像,以便生成的宽度和高度除以2

裁剪滤镜:-vf "crop=in_w-1:in_h"

$ ffmpeg -f image2 -i %05d.jpg -vf "crop=in_w-1:in_h" -vcodec libx264 foo.mp4

更新

我们可以写出一般情况下的公式,这会导致偶数边

$ ffmpeg -f image2 -i %05d.jpg -vf "crop=((in_w/2)*2):((in_h/2)*2)" -vcodec libx264 foo.mp4

票数 6
EN

Stack Overflow用户

发布于 2019-05-29 08:08:25

一个对我有效的解决方案是使用

代码语言:javascript
复制
-vf scale=1920:1080

作为输出视频之前的选项,即

代码语言:javascript
复制
ffmpeg -y -loop 1 -i "input.png" -c:v libx264 -t 5 -pix_fmt yuv420p -vf scale=1920:1080 out.mp4

它会自动正确地调整图像大小,尽管我从未测试过当分辨率大于1920:1080 (待定)时会发生什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13508286

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档