在我的托管服务器上,ffmpeg 是作为 php 模块安装的。我在将视频转换为 mp4格式时出错:
Error while opening the encoder for output stream # 0: 0 - maybe incorrect parameters such as bit_rate, rate, width or height
Ffmpeg 命令示例:
/usr/bin/ffmpeg -y -i /home/afk/public_html/webroot/files/video.flv -vcodec libx264 -acodec libvo_aacenc /home/afk/public_html/webroot/files/video_text.mp4 2 <& 1
我通过脚本中的 php exec ()函数运行这个命令:
<p>exec ($command, $res);</p>
<p>And here is the result that I get ($res array):</p>
<p>Array ( [0] => ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers [1] => built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16) [2] => configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libdc1394 --enable-libfaac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect [3] => libavutil 54. 20.100 / 54. 20.100 [4] => libavcodec 56. 26.100 / 56. 26.100 [5] => libavformat 56. 25.101 / 56. 25.101 [6] => libavdevice 56. 4.100 / 56. 4.100 [7] => libavfilter 5. 11.102 / 5. 11.102 [8] => libavresample 2. 1. 0 / 2. 1. 0 [9] => libswscale 3. 1.101 / 3. 1.101 [10] => libswresample 1. 1.100 / 1. 1.100 [11] => libpostproc 53. 3.100 / 53. 3.100 [12] => Input #0, flv, from '/home/afk/public_html/webroot/files/video.flv': [13] => Metadata: [14] => title : Title of the video [15] => encoder : Lavf56.25.101 [16] => Duration: 00:00:24.00, start: 0.000000, bitrate: 1364 kb/s [17] => Stream #0:0: Video: flv1, yuv420p, 500x500, 200 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc [18] => [libx264 @ 0x1ec6720] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [19] => Output #0, mp4, to '/home/afk/public_html/webroot/files/video_text.mp4': [20] => Metadata: [21] => title : Title of the video [22] => encoder : Lavf56.25.101 [23] => Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 25 fps [24] => Metadata: [25] => encoder : Lavc56.26.100 libx264 [26] => Stream mapping: [27] => Stream #0:0 -> #0:0 (flv1 (flv) -> h264 (libx264)) [28] => Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height )</p>
将任何视频转换为此格式时都会发生同样的错误。我已经使用了 ffmpeg 文档中的示例,但仍然存在错误。请帮助理解和解决这个问题。
同时,从 flv 到 ogg 格式的转换工作正常,或者从图像到 flv 和 ogg 格式的视频创建。