我正在开发一个人们可以提交视频链接的网站。然后我就嵌入它。但是,我想获取视频的缩略图而不将视频保存在我的服务器中。这样当我列出视频时,我可以使用缩略图而不是嵌入所有视频。
我的服务使用 PHP。假设视频为 SWF 格式。
或标签中是否有任何内容可以让我“抓取”缩略图?或者在PHP中,有什么我可以远程获取远程视频的缩略图(或帧)吗?
有什么想法吗?
I am working on a site that people can submit the video's link. Then I just embed it. However, I want to get the thumbnail of the videos without saving the videos in my server. So that when I list the vidoes, I can use the thumbnails instead of embedding all videos.
My serve uses PHP. Assume the video is in SWF format.
is there anything in the or tag that I can 'grap' the thumbnail? or in PHP, is there anything that I can remotely get the thumbnail (or a frame ) of the remote video?
any idea?
发布评论
评论(2)
您可以使用“ffmpeg”。通过使用PHP来调用它。
很遗憾,我还没有测试过,所以先尝试一下。
编辑:只是为了好玩,我将其设为一个函数。这里是:
此功能还缓存缩略图,并确保在修改 VDO 时重新创建更新缩略图。
享受
You can use 'ffmpeg'. by using PHP to call it.
I am sorry to say that I've not test it so try it first.
EDIT: Just for fun, I make it a function. Here it is:
This function also cache the thumbnail and also ensure that the update thumbnail is recreated if the VDO is modified.
Enjoy
我使用上面的一些片段和其他一些来源让它工作,这是我的一些代码:
显然,如果您要在自己的类中使用这些函数,您需要用
自己的配置选项替换这些行。
完整的插件和框架 可在 github 上找到,此代码片段来自的特定文件是 此处。
I got it working using some snippets from above and some other sources, here's some of my code:
Obviously if you're going to use these functions in your own class, you'll need to replace the lines
with your own configuration options.
The full plugin and framework are available on github, the particular file this snippet is from is here.