php 如何为视频创建缩略图或预览?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2265572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create thumbnails or preview for videos?
提问by Vijay
i want to display thumbnails or preview panels for videos listed on my site, i want to fetch a single frame from a video (from a particular time i.e get a frame of exactly after 1 min) and display them as thumbnails as in youtube...
我想显示我网站上列出的视频的缩略图或预览面板,我想从视频中获取单个帧(从特定时间开始,即在 1 分钟后获得一帧)并将它们显示为缩略图,就像在 youtube 中一样。 .
Any help?
有什么帮助吗?
采纳答案by Napolux
Take a look at the ffmpeg-php library. It's the only simple way to manipulate videos of different formats in PHP.
看看 ffmpeg-php 库。这是在 PHP 中操作不同格式视频的唯一简单方法。
There's also a wrapper called PHP Video Toolkit, you can find it here: http://sourceforge.net/projects/phpvideotoolkit/
还有一个名为PHP Video Toolkit的包装器,您可以在这里找到它:http: //sourceforge.net/projects/phpvideotoolkit/
回答by cregox
Adding to how to use the ffmpeg answer, this is the parameters you're looking for:
添加到如何使用 ffmpeg 答案,这是您正在寻找的参数:
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
回答by Thomas
In modern browsers you can also use the video tag and canvas to capture a frame and save it as an image.
在现代浏览器中,您还可以使用视频标签和画布来捕获帧并将其保存为图像。
see How can we get the screenshot of the video in html5 using canvas

