$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" }