简体   繁体   中英

php - convert avi to mp4, webm and flv using ffmpeg command

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'

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM