FFmpeg 无法转码 dsmall.mp4。报告错误
PHPVideoToolkit error: Execute error. It was not possible to encode "/var/www/vhosts/imodb.ir/cinemagram.ir/sites/default/files/videos/original/dsmall_5.mp4" as FFmpeg returned an error. The error is with the video codec of the input file. FFmpeg reports the error to be "Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height".
执行的命令和输出
/usr/local/bin/ffmpeg -i '/var/www/vhosts/imodb.ir/cinemagram.ir/sites/default/files/videos/original/dsmall_5.mp4' -vf 'scale=498:360' -strict experimental -vcodec 'libx264' -acodec 'alac' -ac '2' -pass '1' -passlogfile '/tmp/1408770806-53f822f6bbf29-multipass' -y /tmp/1408770806-53f822f6bbe41.mp4
FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
built on Aug 14 2014 22:54:14 with gcc 4.4.7 20120313 (Red Hat 4.4.7-4)
configuration: --enable-libfaac --enable-shared --enable-memalign-hack --enable-gpl --enable-libtheora --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-avfilter --enable-swscale
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/vhosts/imodb.ir/cinemagram.ir/sites/default/files/videos/original/dsmall_5.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
creation_time : 2010-03-20 21:29:11
encoder : HandBrake 0.9.4 2009112300
Duration: 00:00:05.56, start: 0.000000, bitrate: 551 kb/s
Stream #0.0(und): Video: h264, yuv420p, 560x320, 465 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc
Metadata:
creation_time : 2010-03-20 21:29:11
Stream #0.1(eng): Audio: aac, 48000 Hz, mono, s16, 83 kb/s
Metadata:
creation_time : 2010-03-20 21:29:11
[buffer @ 0xb13d80] w:560 h:320 pixfmt:yuv420p
[scale @ 0xb142f0] w:560 h:320 fmt:yuv420p -> w:498 h:360 fmt:yuv420p flags:0xa0000004
[libx264 @ 0xa62cd0] broken ffmpeg default settings detected
[libx264 @ 0xa62cd0] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0xa62cd0] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0xa62cd0] speed presets are listed in x264 --help
[libx264 @ 0xa62cd0] profile is optional; x264 defaults to high
Output #0, mp4, to '/tmp/1408770806-53f822f6bbe41.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 498x360, q=2-31, pass 1, 200 kb/s, 90k tbn, 30 tbc
Metadata:
creation_time : 2010-03-20 21:29:11
Stream #0.1(eng): Audio: alac, 48000 Hz, 2 channels, s16, 64 kb/s
Metadata:
creation_time : 2010-03-20 21:29:11
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
更新
我们安装ffmpeg
具有以下属性的新版本
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandi
r=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enabl
e-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11gra
b --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-
libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenco
re-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enab
le-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx2
64 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_F
ORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -m
tune=generic -fPIC' --disable-stripping
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
我想将每个视频转换为mp4
,什么是适合我的目标的预设?
答案1
我很确定错误在于您的原始视频只有单声道音频,而您请求两个通道输出。
但话又说回来,你使用的版本太旧了ffmpeg
。它太古老了,FFmpeg 项目甚至不再使用 SVN——那是 2011 年的事了。旧版本可能存在错误,导致无法运行该命令。
你应该下载一个更新的(静态构建之一)并使用它,甚至自己编译。较新的版本修复了数千个错误,具有更合理的默认行为,并且在发生问题时为您提供更有意义的错误。
由于你似乎正在使用 PHPVideoToolkit,它是还过时,考虑切换到phpvideotoolkit-v2它至少支持 ffmpeg 1.2。不过当前的 ffmpeg 是 2.3。或者你可以使用PHP-FFMpeg,似乎也正在积极开发中。
关于您的命令行,我假设您不想要alac
音频编解码器,但是aac
。ALAC 是 Apple 的无损音频编解码器,而对于 H.264 视频,您通常需要 AAC 音频。将其更改为-acodec aac
(或使用较新的语法-c:a aac
)。当然,如果您选择正确的设置,PHP 框架会自动为您执行此操作。