我正在用 php 中最新版本的 ffmpeg 转换视频文件:
exec("ffmpeg -y -i capture.wmv capture.mp4 2>&1", $output);
var_dump($output);
这是结果:
array(21) {
[0]=>
string(99) "FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.3, Copyright (c) 2000-2009 Fabrice Bellard, et al."
[1]=>
string(451) " configuration: --extra-version=4:0.5.9-0ubuntu0.10.04.3 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static"
[2]=>
string(35) " libavutil 49.15. 0 / 49.15. 0"
[3]=>
string(35) " libavcodec 52.20. 1 / 52.20. 1"
[4]=>
string(35) " libavformat 52.31. 0 / 52.31. 0"
[5]=>
string(35) " libavdevice 52. 1. 0 / 52. 1. 0"
[6]=>
string(35) " libavfilter 0. 4. 0 / 0. 4. 0"
[7]=>
string(35) " libswscale 0. 7. 1 / 0. 7. 1"
[8]=>
string(35) " libpostproc 51. 2. 0 / 51. 2. 0"
[9]=>
string(43) " built on Jan 24 2013 19:42:59, gcc: 4.4.3"
[10]=>
string(34) "Input #0, asf, from 'capture.wmv':"
[11]=>
string(60) " Duration: 00:04:11.45, start: 3.000000, bitrate: 1755 kb/s"
[12]=>
string(62) " Stream #0.0: Audio: wmav2, 44100 Hz, stereo, s16, 128 kb/s"
[13]=>
string(82) " Stream #0.1: Video: wmv2, yuv420p, 1280x720, 1600 kb/s, 1k tbr, 1k tbn, 1k tbc"
[14]=>
string(33) "Output #0, mp4, to 'capture.mp4':"
[15]=>
string(83) " Stream #0.0: Video: mpeg4, yuv420p, 1280x720, q=2-31, 200 kb/s, 90k tbn, 1k tbc"
[16]=>
string(62) " Stream #0.1: Audio: 0x0000, 44100 Hz, stereo, s16, 64 kb/s"
[17]=>
string(15) "Stream mapping:"
[18]=>
string(21) " Stream #0.1 -> #0.0"
[19]=>
string(21) " Stream #0.0 -> #0.1"
[20]=>
string(40) "Unsupported codec for output stream #0.1"
}
我需要一个标准的 mp4 文件来使用 html5 在 web 中播放。问题可能出在哪里?没有安装codex?还是控制台命令有问题?
编辑:使用静态构建后,我尝试将 wmv 转换为 mp4
exec("/www/htdocs/xxxx/video/ffmpeg -y -i capture.wmv capture.mp4 2>&1", $output);
结果文件的大小只有一些字节 - 这是输出:
array(40) {
[0]=>
string(77) "ffmpeg version N-49805-gfd6a021 Copyright (c) 2000-2013 the FFmpeg developers"
[1]=>
string(61) " built on Feb 11 2013 05:23:18 with gcc 4.6 (Debian 4.6.3-1)"
[2]=>
string(609) " configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx"
[3]=>
string(40) " libavutil 52. 17.101 / 52. 17.101"
[4]=>
string(40) " libavcodec 54. 91.102 / 54. 91.102"
[5]=>
string(40) " libavformat 54. 62.100 / 54. 62.100"
[6]=>
string(40) " libavdevice 54. 3.103 / 54. 3.103"
[7]=>
string(40) " libavfilter 3. 37.101 / 3. 37.101"
[8]=>
string(40) " libswscale 2. 2.100 / 2. 2.100"
[9]=>
string(40) " libswresample 0. 17.102 / 0. 17.102"
[10]=>
string(40) " libpostproc 52. 2.100 / 52. 2.100"
[11]=>
string(54) "Guessed Channel Layout for Input Stream #0.0 : stereo"
[12]=>
string(34) "Input #0, asf, from 'capture.wmv':"
[13]=>
string(11) " Metadata:"
[14]=>
string(32) " WMFSDKNeeded : 0.0.0.0000"
[15]=>
string(32) " DeviceConformanceTemplate: @"
[16]=>
string(37) " WMFSDKVersion : 12.0.7601.17514"
[17]=>
string(23) " IsVBR : 0"
[18]=>
string(60) " Duration: 00:04:13.40, start: 0.000000, bitrate: 1742 kb/s"
[19]=>
string(90) " Stream #0:0(ger): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, fltp, 128 kb/s"
[20]=>
string(125) " Stream #0:1(ger): Video: wmv2 (WMV2 / 0x32564D57), yuv420p, 1280x720, 1600 kb/s, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn, 1k tbc"
[21]=>
string(35) "[libx264 @ 0x2f082e0] using SAR=1/1"
[22]=>
string(63) "[libx264 @ 0x2f082e0] MB rate (3600000) > level limit (2073600)"
[23]=>
string(88) "[libx264 @ 0x2f082e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX"
[24]=>
string(45) "[libx264 @ 0x2f082e0] profile High, level 5.2"
[25]=>
string(684) "[libx264 @ 0x2f082e0] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00"
[26]=>
string(33) "Output #0, mp4, to 'capture.mp4':"
[27]=>
string(11) " Metadata:"
[28]=>
string(32) " WMFSDKNeeded : 0.0.0.0000"
[29]=>
string(32) " DeviceConformanceTemplate: @"
[30]=>
string(37) " WMFSDKVersion : 12.0.7601.17514"
[31]=>
string(23) " IsVBR : 0"
[32]=>
string(35) " encoder : Lavf54.62.100"
[33]=>
string(122) " Stream #0:0(ger): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 16k tbn, 1k tbc"
[34]=>
string(90) " Stream #0:1(ger): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s"
[35]=>
string(15) "Stream mapping:"
[36]=>
string(39) " Stream #0:1 -> #0:0 (wmv2 -> libx264)"
[37]=>
string(45) " Stream #0:0 -> #0:1 (wmav2 -> libvo_aacenc)"
[38]=>
string(31) "Press [q] to stop, [?] for help"
[39]=>
string(96) "frame= 158 fps=0.0 q=33.0 size= 0kB time=00:00:00.10 bitrate= 3.6kbits/s dup=155 drop=0"
}
slhck - 感谢您的提示 - 您看到问题了吗?