宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应

[FFmpeg]PHP程序转换mp4视频并截图视频预览图(ffmpeg应用)

2016-10-13 00:16:48 点击量:18 标签: 收藏本文

[FFmpeg]PHP程序转换mp4视频并截图视频预览图(ffmpeg应用)

  1. <?php 
  2. flv_convert_get_thumb('input.avi', 'output.jpg', 'output.ogm'); 
  3. // code provided and updated by steve of phpsnaps ! thanks 
  4. // accepts: 
  5. // 1: the input video file 
  6. // 2: path to thumb jpg 
  7. // 3: path to transcoded mpeg? 
  8. function flv_convert_get_thumb($in, $out_thumb, $out_vid) 
  9.   // get thumbnail 
  10.   $cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 5 -vcodec mjpeg 
    -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb; 
  11.   $res = shell_exec($cmd); 
  12.   // $res is the output of the command 
  13.   // transcode video 
  14.   $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=1threads=auto 
    -oac mp3lame'; 
  15.   $res = shell_exec($cmd); 
  16. ?> 

 FFmpeg是用于录制、转换和流化音频和视频的完整解决方案,一套领先的音/视频编解码类库。官方正式版ffmpeg不支持rmvb和rm格式. 不过有很多解决方法