我正在制作一个网站,其中客户希望像u管一样显示视频库。在互联网上,我发现使用ffmpeg。我已经下载了ffmpeg adn pest in root directry。并创建类
<?php
class media_handler
{
function convert_media($filename, $rootpath, $inputpath,$outputpath,$width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;
$size = Width & "x" & Height;
$outfile = 'out_file.flv';
$ffmpegcmd1 = "ffmpeg -i '".$inputpath."'\'".$filename. "' -acodec mp3 -ar '" .$samplingrate."' -ab '".$bitrate."'
-f flv -s '".$size."' '".$outputpath."'\'".$outfile;
$ret = shell_exec($ffmpegcmd1);
return $outfile;
}
function set_buffering($filename,$rootpath,$path)
{
$_rootPath = $rootpath."\flvtool";
$ffmpegcmd1 = "flvtool2 -U '".$Path."'\'".$filename;
$ret = shell_exec($ffmpegcmd1);
}
function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath ="ffmpeg";
$size = $width. "x".$height;
$outfile = "sample.png";
$ffmpegcmd1 = "ffmpeg -i '".$inputpath."'\'".$filename."' -vframes '".$no_of_thumbs."' -ss 00:00:03 -an -vcodec '". $image_format."' -frawvideo -s '".$size. "''". $outputpath."'\'".$outfile ;
$ret = shell_exec($ffmpegcmd1);
return $outfile;
}
}
我使用过这个代码
$outfile=$_FILES['videofile']['name'];
$rootpath =$videoPath;
$outputpath=$videoPath;
$thumbpath=$videoPath;
**$image_name = $_mediahandler->grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);**
但它不起作用。