因此,如果现在解决了我的 ffmpeg 旅程的所有问题,我只需要在转换视频后立即在 Flash 播放器中播放,无需等到视频 100% 加载我使用:
if ($success_msg) {
$tmp_parts = explode('.', $file['name']);
$ext = array_pop($tmp_parts);
$ext = strtolower($ext);
if($ext == "avi" && $convert_avi == true) {
$convert_source = _VIDEOS_DIR_PATH.$new_name;
$conv_name = substr(md5($file['name'].rand(1,888)), 2, 10).".mp4";
$converted_file = _VIDEOS_DIR_PATH.$conv_name;
$ffmpeg_command = 'ffmpeg -i '.$convert_source.' -acodec libfaac -vcodec libx264 -s 1280x720 -ar 44100 -async 44100 -r 29.970 -ac 2 -qscale 5 '.$converted_file;
echo exec($ffmpeg_command);
$sql = "UPDATE pm_temp SET url = '".$conv_name."' WHERE url = '".$new_name."' LIMIT 1";
$result = @mysql_query($sql);
unlink($convert_source);
}
echo $success_msg;
}
转换视频
编辑#1 ffmpeg concole 输出与快速启动功能:
root@1tb:~# ffmpeg -i sample.avi -movflags faststart -acodec libfaac -vcodec libx264 -s 1280x720 -ar 44100 -async 44100 -r 29.970 -ac 2 -qscale 5 consample.mp4
ffmpeg version 0.7.15, Copyright (c) 2000-2013 the FFmpeg developers
built on Feb 22 2013 07:18:58 with gcc 4.4.5
configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libfreetype --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.123. 0 / 52.123. 0
libavformat 52.111. 0 / 52.111. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
[mp3 @ 0x15389100] Header missing
[mpeg4 @ 0x15386dc0] Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from 'sample.avi':
Metadata:
encoder : VirtualDubMod 1.5.10.2 (build 2540/release)
Duration: 00:01:01.81, start: 0.000000, bitrate: 1194 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 640x352 [PAR 1:1 DAR 20:11], 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s
[MOV/3GP/MP4/3G2 muxer @ 0x15386c80] [Eval @ 0x7ffffec71230] Undefined constant or missing '(' in 'faststart'
[MOV/3GP/MP4/3G2 muxer @ 0x15386c80] Unable to parse option value "faststart"
Invalid value 'movflags' for option 'faststart'