Flex:动态创建视频预览图像
我正在使用 VideoDisplay 播放 flv、mov 和 mp4,一切正常。 它们都是通过渐进式下载加载的,并且不进行流式传输。 我想要做的是抓取单个指定帧(例如 10 秒标记处显示的任何帧),将其转换为位图并使用该位图作为视频的预览图像。 我想在运行时执行此操作,这样我就不必为要显示的每个视频创建预览图像。
关于如何做到这一点有什么想法吗? 我不想通过播放来伪造它 - 寻找特定的帧然后暂停它,但我可能没有其他选择?
I'm using the VideoDisplay to play flv's, mov's, and mp4's and everything is working great. They are all being loaded via progressive download and are not being streamed. What I'd like to do is to grab a single specified frame (like whatever is being shown at the 10 second mark), convert it to a bitmap and use that bitmap as the preview image for the video. I'd like to do this at runtime so I don't have to create a preview image for every video that would be shown.
Any idea's on how to do this? I'd rather not fake it by playing it - seeking for that specific frame and then pausing it but I may have no other choice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Ryan 和 James 是正确的——正确的方法可能是在上传/转码时提取帧。 但如果这不是一个选项,您可以选择使用您自己的某种默认/占位符图像(通用的或以某种方式适合尚未捕获拇指的所有视频),并且只需使用 VideoDisplay 的 DisplayObject-ness抓取然后将帧上传到您的服务器,例如:
同样,这可能不是最优雅的解决方案,但它确实有效。 这样,第一个用户会看到通用图像,但此后每个用户都会获得生成的缩略图。 (当然,到那时您已经上传并正确关联了。)有意义吗?
Ryan and James are correct -- the right way's probably to extract frames at upload/transcode-time. But if that's not an option, you could opt for using some sort of a default/placeholder image of your own (something generic or somehow suitable for all videos whose thumbs haven't yet been captured), and just use VideoDisplay's DisplayObject-ness to grab and then upload a frame to your server, e.g.:
Again, it's perhaps not the most elegant solution, but it certainly works. This way, the first user sees the generic image, but every user thereafter gets the generated thumbnail. (Which, of course, you'll have uploaded and properly associated by then.) Make sense?
我很确定这是不可能的。 很可能是……但不这么认为。 我认为加载视频的唯一方法是使用 NetStream 和 NetConnection 对象,正如您所知,这只是开始加载视频。
如果这是用户生成的视频,我认为最好的选择是使用一些服务器端脚本来生成预览图像。 不知道这是如何完成的,但认为这是大多数剪辑网站的工作方式。
如果所有视频都在您的控制范围内,则可以为其中一个视频编辑程序编写脚本,以自动从文件列表中生成特定帧的图像。 我认为这可能是您可以快速启动并运行的最佳替代路线。
抱歉,答案含糊不清……如果您需要快速解决方案,它可能会为您指明正确的方向。
I'm pretty sure this isn't possible. It may well be... but don't think so. I think the only way to load in video is to use the NetStream and NetConnection object, which as you know just kicks off the loading of the video.
If this is user generated video i think the best bet is to have some serever side script that generates the preview image. Have no idea how this is done but think this is how most clip sites work.
If all the videos are in your control it may be possible to write a script for one of the video editing programs to automate generating the image for a specific frame from a list of files. I think this is probably your best route as alternative that you could get up and running quickly.
Sorry for the vague answer... it may point you in the right direction if you need a quick solution.
我同意詹姆斯的观点,真正做到这一点的唯一方法是使用服务器端脚本并从视频中提取某些帧。 即使您可以使用 Flex 来完成此操作,您也确实不想将执行此操作的负担(我认为这将是处理器密集型)放在客户端计算机上。 更不用说,预先创建图像比让 Flex 确定每次加载时显示的缩略图要高效得多。
I agree with James, the only way to really do this would be to do it with a server side script and pull certain frames out of the video. Even if you could do this with flex, you really would not want to put the burden to do this (which would be processor intensive I would think) on the client machine. Not to mention it will be much more efficient to create the image before hand than to have flex determine the thumbnail to show every time it is loaded.