本文实例讲述了PHP实现将视频转成MP4并获取视频预览图的方法。分享给大家供大家参考。具体实现方法如下:
<?php<br />flv_convert_get_thumb('input.avi', 'output.jpg', 'output.ogm');<br />// code pr<span style="color:transparent">本文来源gaodai#ma#com搞*!代#%^码$网!</span><strong>搞代gaodaima码</strong>ovided and updated by steve of phpsnaps ! thanks<br />// accepts:<br />// 1: the input video file<br />// 2: path to thumb jpg<br />// 3: path to transcoded mpeg?<br />function flv_convert_get_thumb($in, $out_thumb, $out_vid)<br />{<br /> // get thumbnail<br /> $cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 5 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;<br /> $res = shell_exec($cmd);<br /> // $res is the output of the command<br /> // transcode video<br /> $cmd = 'mencoder '.$in.' -o '.$out_vid.' -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame';<br /> $res = shell_exec($cmd);<br />}<br />?>
希望本文所述对大家的php程序设计有所帮助。