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 Global定义全局变量使用说明

很不习惯PHP中的变量作用域,PHP中函数变量和全局是完全隔绝的,也就是无法相互访问。比如下面这样:复制代码 代码如下:$test = 123; abc(); //这里什么都不...

浅谈PHP中JSON数据操作

JSON,全称是JavaScript Object Notation。它是基于JavaScript编程语言ECMA-262 3rd Edition-December 1999标准的一种轻...

学习php设计模式 php实现模板方法模式

学习php设计模式 php实现模板方法模式

一、意图 定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。Template Method 使得子类可以在不改变一个算法的结构的情况下重定义该算法的某些特定的步骤【GOF95】 二、...

ThinkPHP路由详解

有了基本配置,我们就可以来访问我们的应用默认首页了。进入到项目目录,可以直接使用PHP内置服务器来开始访问,比如: php -S localhost:8999 浏览器输入loc...

php查找字符串中第一个非0的位置截取

php查找字符串中第一个非0的位置截取

话不多说,请看代码: $str = '00000000000000000000000000000000000000001234506'; $preg = '/[0]*/'; $res...