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中访问修饰符的知识点总结

为什么需要访问权限? 防止覆盖变量名称和函数名称 我们下来看一下public的使用,public是可以从任何地方访问的最广泛的访问限定符。 假设A先生开发overlapFuncBase,...

PHP根据手机号判断运营商(详细介绍附代码)

道理很简单,知道手机号规则 进行正则判断就可以 移动:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188 联通:130、131...

php数组函数序列之array_intersect() 返回两个或多个数组的交集数组

array_intersect() 定义和用法 array_intersect() 函数返回两个或多个数组的交集数组。 结果数组包含了所有在被比较数组中,也同时出现在所有其他参数数组中的...

如何打开php的gd2库

如何打开php的gd2库

第一步:找到 php.ini 通常,该文件在php安装目录下,如果忘记路径可以在你使用的web服务软件上查询。 第二步:用记事本打开该文件,并按 “ctrl+F” 输入 “extens...

phpadmin如何导入导出大数据文件及php.ini参数修改

最近遇到了数据库过大的时候用phpadmin导入的问题,新版本的phpadmin导入限定是8M,老版本的可能2M,我的数据库有几十兆这可怎么办呢? 首先如果你有独立服务器或vps的话可以...