$video_name = $_FILES['video_file']['name'];
$video_tmp_name = $_FILES['video_file']['tmp_name'];
$video_size = $_FILES['video_file']['size'];
// where ffmpeg is located
$ffmpeg = 'C:\\ffmpeg\bin\\ffmepg';
//video dir
$video = $video_tmp_name;
//where to save the image
$image = 'video/image.jpg';
//time to take screenshot at
$interval = 5;
//screenshot size
$size = '640x480';
//ffmpeg command
echo $cmd = $ffmpeg ."-i". $video ." -an -ss".$interval." -s ".$size . "-vcodec mjpeg ".$image ." 2>&1";
shell_exec($cmd);
我写下代码。但它没有创造从视频中任意缩略图,。我不能理解的是,这段代码有什么不对。
您的代码可能相当Linux特有的( “2>&!”)的一部分。
在Windows上我成功使用此选项:
ffmpeg -y -i klip.flv -f mjpeg -ss 10 -vframes 1 160x120 thumb.jpg
这是视频缩略图的C#代码段。
fullVideoPath=@"C:\Users\Madan\Desktop\wpflib\10.wmv"
thumbnailPath=@ "C:\Users\Madan\Desktop\wpflib\Thumbnail\10.jpg"
ffmpeg = new Process();
ffmpeg.StartInfo.Arguments = " -i " + "\"" + fullVideoPath+ "\"" + " -ss 00:00:02 -vcodec mjpeg -vframes 1 -an -f rawvideo -s 200x200 " + "\"" + thumbnailPath+ "\"";
ffmpeg.StartInfo.FileName = ffmepgPath;
ffmpeg.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
var status = ffmpeg.Start();
使用此它可以帮助你。我已经具有以下扩展名进行了测试
{ ".wmv", ".avi", ".mpg", ".mpeg", ".mp4", ".mkv", ".flv", ".mov", ".vob", ".3gp" }