PHP实现将视频转成MP4并获取视频预览图的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了PHP实现将视频转成MP4并获取视频预览图的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:
<?php
flv_convert_get_thumb('input.avi', 'output.jpg', 'output.ogm');
// code provided and updated by steve of phpsnaps ! thanks
// accepts:
// 1: the input video file
// 2: path to thumb jpg
// 3: path to transcoded mpeg?
function flv_convert_get_thumb($in, $out_thumb, $out_vid)
{
  // get thumbnail
  $cmd = 'ffmpeg -v 0 -y -i '.$in.' -vframes 1 -ss 5 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$out_thumb;
  $res = shell_exec($cmd);
  // $res is the output of the command
  // transcode video
  $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';
  $res = shell_exec($cmd);
}
?>

希望本文所述对大家的php程序设计有所帮助。

相关文章

PHP中计算字符串相似度的函数代码

similar_text — 计算两个字符串的相似度 int similar_text ( string $first , string $second [, float &$perc...

PHP判断远程图片是否存在的几种方法

在做一个图片预览中图的东西,遇到一个问题,就是要判断远程文件是否存在(不是同一台服务器)。代码如下:复制代码 代码如下://方法一function file_exists($url){$...

PHP图片加水印实现方法

本文实例讲述了PHP图片加水印实现方法。分享给大家供大家参考,具体如下: <?php echo img_water_mark("20081120232044234778...

PHP高精确度运算BC函数库实例详解

本文实例讲述了PHP高精确度运算BC函数库。分享给大家供大家参考,具体如下: <?php /*************************************...

用PHP将Unicode 转化为UTF-8的实现方法(推荐)

实例如下: function unescape($str) { $str = rawurldecode($str); preg_match_all("/(?:%u.{...