php - 使用ffmpeg命令将avi转换为mp4,webm和flv

My problem is I am trying to convert and upload videos into three formats at upload button. I am stuck at the very first step when i am trying to convert avi to mp4, webm and flv. I have tried various commands to convert in to mp4 and webm but nothing worked. its converting to flv smoothly. i searched a lot on internet but none of the commands worked. i have set execution_time to 0 and set_time_limit(0) as well for unlimited execution time. here are the commands i tried to convert in to mp4 and webm

**For mp4:**

exec("ffmpeg -i input.avi -c:v libx264 -crf 19 output.mp4");
exec("ffmpeg -i input.avi -c:v libx264 -pix_fmt yuv420p output.mp4");
exec("ffmpeg -i input.avi -c:v libx264 -c:a libfaac \ -movflags +faststart output.mp4");

**For webm** 
passthru("ffmpeg -i input.avi output.webm");
passthru("ffmpeg -i input.avi -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 output.webm");

Note: For avi to mp4 files that are less than 1mb are converting successfully but more than 1mb files are showing its converting but its size is 0bytes.

Similarly, i am facing a problem in converting mp4 to flv. Some files are converting and some are not. Some of the large files are converting but some small files are not converting. It was strange. there was no problem of permission or php configuration settings all was fine. I tried renaming a file which was not converting and it got uploaded. I am confused why this happened.

Any help for both the issues is highly appreciated.

Thanks in advance.

Edited /bin$ ffmpeg -v ffmpeg version 0.10.15 Copyright (c) 2000-2014 the FFmpeg developers built on Aug 30 2014 15:49:19 with gcc 4.4.7 20120313 (Red Hat 4.4.7-3) configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags='-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-libass --enable-libcdio --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect libavutil 51. 35.100 / 51. 35.100 libavcodec 53. 61.100 / 53. 61.100 libavformat 53. 32.100 / 53. 32.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 61.100 / 2. 61.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 6.100 / 0. 6.100 libpostproc 52. 0.100 / 52. 0.100 Missing argument for option 'v'


echo </ code>您的 exec </ code>并使用与运行Apache相同的用户将其放入shell中。</ p>

如果没有ffmpeg的日志,我们无法帮助您。</ p>

< p>对于我的视频我正在使用它将AVI转换为mp4:</ p>

  ffmpeg -i'filename.ext'-threads 0 -c:v libx264 -preset slow  -  crf 19 -qmin 10 -qmax 51 -c:libfdk_aac -b:128k -y'output.mp4'
</ code> </ pre>
</ div>



Ok first you need to debug your exec with files not encoded. echo your exec and put it into your shell with the same user than run Apache.

With no log of ffmpeg we can't help you.

For my videos i'm using this for convert avi to mp4 :

ffmpeg -i 'filename.ext' -threads 0 -c:v libx264 -preset slower -crf 19 -qmin 10 -qmax 51 -c:a libfdk_aac -b:a 128k -y 'output.mp4'

dongxun4110 如果你在像ubuntu这样的linux上你可以这样做apt-get remove --purge ffmpeg
大约 5 年之前 回复
drbhjey445647 如何取消旧的ffmpeg? 请你告诉我
大约 5 年之前 回复
dongliang_bj2016 你需要unistall ffmpeg并使用这个编码器来构建它 - 比如libvpx ...查看文档ffmpeg [link]
大约 5 年之前 回复
dongxingdu9594 它显示未知编码器'libvpx'并使用其他命令显示未知编码器'libvorbis'甚至这些库并安装
大约 5 年之前 回复
dongyu8664 ffmpeg -i input.mp4 -c:v libvpx -qmin 0 -qmax 50 -crf 5 -b:v 1M -c:libvorbis output.webm
大约 5 年之前 回复
dongyun3805 请你再帮我一件事。 我应该用哪个库转换成webm?
大约 5 年之前 回复
douji3426 libmp3lame工作...感谢这个伟大的帮助..... :)
大约 5 年之前 回复
dpj96988 aahhh .... lipmp3也不起作用:(
大约 5 年之前 回复
douang4294 好的,这是正常的,因为你没有用这个lib构建ffmpeg; 尝试用你的libmp3替换它并重试
大约 5 年之前 回复
doudun5009 我在shell WINSCP中执行命令并使用您的命令显示此错误未知编码器'libfdk_aac'
大约 5 年之前 回复
duankangzi766767 exec命令命令只显示Array()。 我已经在问题区域粘贴了ffmpeg -v看看
大约 5 年之前 回复
dongpixi2648 首先使用ffmpeg -v检查你的ffmpeg构建,然后在那个测试之后通过它来输出带有转换视频bug的日志
大约 5 年之前 回复
dqyz48470 exec(“ffmpeg -i'filename.ext' -threads 0 -c:v libx264 -preset slow -crf 19 -qmin 10 -qmax 51 -c:a libfdk_aac -b:a 128k -y'output.mp4'”, $ output)print_r($ output)
大约 5 年之前 回复
drgd73844 好的,请你告诉我该命令如何回显文件信息
大约 5 年之前 回复
Csdn user default icon