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日期时间运算汇总

实例讲解之前,先来介绍几个核心函数:  mktime 函数 mktime() 函数返回一个日期的 Unix 时间戳。 参数总是表示 GMT 日期,因此 is_dst 对结果没有...

php curl批处理实现可控并发异步操作示例

本文实例讲述了php curl批处理实现可控并发异步操作。分享给大家供大家参考,具体如下: 通常情况下 PHP 中的 cURL 是阻塞运行的,就是说创建一个 cURL 请求以后必须等它执...

PHP JSON格式数据交互实例代码详解

在PHP中解析JSON主要用到json_encode和json_decode两个PHP JSON函数,比PHP解析XML方便很多,下面详细介绍下PHP JSON的使用。JSON基础介绍...

smarty巧妙处理iframe中内容页的代码

废话不多说,进去正题 做过后台的,应该都知道,经常要用到iframe来处理导航,如果按一般的思路来做这个功能,还是挺简单的 可是当我用smarty的时候,就发现了问题,比如,一个ifra...

thinkphp3.2点击刷新生成验证码

thinkphp3.2点击刷新生成验证码

再介绍thinkphp3.2验证码的使用方法之前,先为大家详细介绍ThinkPHP 验证码,具体内容如下 ThinkPHP 内置了验证码的支持,可以直接使用。要使用验证码,需要导入扩展类...