[英]Getting image from mp4 video using ffmpeg in YII
I have written a code to get an image from an uploaded mp4 video using ffmpeg in YII. 我编写了一个代码,在YII中使用ffmpeg从上传的mp4视频中获取图像。
In localhost, when i have written absolute path like d:/wamp/www/projectname/ffmpeg
like this, it is working perfectly and i am getting image but when I tried like below using baseurl
在本地主机中,当我像这样写了绝对路径
d:/wamp/www/projectname/ffmpeg
,它工作正常,并且我正在获取图像,但是当我尝试使用baseurl
如下操作baseurl
$var="http://".$_SERVER['HTTP_HOST'].Yii::app()->request->baseUrl;
$ffmpeg = $var."/ffmpeg/bin/ffmpeg.exe";
I am unable to get the image from video. 我无法从视频中获取图像。
Here is my code 这是我的代码
$var="http://".$_SERVER['HTTP_HOST'].Yii::app()->request->baseUrl;
$ffmpeg = $var."/ffmpeg/bin/ffmpeg.exe";
// $uploaddir is my file upload path
$video = $uploaddir.$image_name;
//where to save the image
$iname = basename($image_name, ".mp4");
$image = $uploaddir.'/'.$iname.'_img.jpg';
//time to take screenshot at
$interval = 5;
//screenshot size pn
$size = '640x480';
//ffmpeg command
$cmd="$ffmpeg -i ".$video." -ss 00:00:01.100 -f image2 -vframes 1 ".$image;
exec($cmd);
it is not possible to execute " http://foo.bar/ffmpeg/ffmpeg.exe ", exec requires a absolute path to the binary: 无法执行“ http://foo.bar/ffmpeg/ffmpeg.exe”,exec需要指向二进制文件的绝对路径:
/**
* return d:/wamp/www/projectname
*/
$var = dirname(Yii::app()->getBasePath());
$ffmpeg = $var."/ffmpeg/bin/ffmpeg.exe";
if(!file_exists($ffmpeg))
exit("sorry dude, i cant find ffmpeg.exe!");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.