duanlan3598 2015-06-05 07:48
浏览 828

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'

  • 写回答

1条回答

  • douhuangjian9627 2015-06-05 08:19
    关注

    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'
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置