从视频流创建视频缩略图 [英] Create Video Thumbnails from Video Stream

查看:148
本文介绍了从视频流创建视频缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,用户可以在其中上传视频.
我将它们上传到sqlserver中的varbinary(max)数据类型中.这很好用,我可以使用我编写的通用处理程序从流中观看视频.

我的问题是,如何为视频创建缩略图?

我一直在看FFMPEG和相关的帖子;但是,这对我不起作用,因为我没有将视频保存到物理路径.
我将pics和vids都存储在sql数据库中,没有任何问题,除了这一点! :)

有人知道上传后如何从视频中创建缩略图吗?

这是我正在使用的简单处理程序中的代码.

..获取图片
context.Response.BinaryWrite((byte [])v.sVideo.ToArray);

预先谢谢您

I am developing a website in which users can upload videos.
I am uploading them into a varbinary(max) datatype in sqlserver. This works great, and I can view the video from the stream using a generic handler I have written.

My question is, how can I create a thumbnail for the video?

I have been looking at FFMPEG and related postings; however, this will not work for me because I am not saving the video to a physical path.
I am storing both pics and vids in the sql database with no issues,,, except this one! :)

Does anyone know how I can create a thumbnail from the video upon upload?

Here is the code in the simple handler I am using.

..get the pic
context.Response.BinaryWrite((byte[])v.sVideo.ToArray);

thank you in advance

推荐答案

chevy914写道:
chevy914 wrote:

因为我没有保存视频到物理路径.

because I am not saving the video to a physical path.



如果不将视频写入文件系统,则无法生成缩略图. Quicktime允许从内存中加载视频,但是Windows不允许这样做.



If you don''t write the video to the file system, then you cannot generate thumbnails. Quicktime allows loading a video from memory, but Windows does not, sadly.

double pos = 1;
double percentage = 0.05;

DexterLib.MediaDetClass mediaDet = new DexterLib.MediaDetClass();
mediaDet.Filename = filename;
mediaDet.CurrentStream = 0;
String tmpBitmapFile = System.IO.Path.GetTempFileName() + ".bmp";

int height = 240;
int width = 180;

mediaDet.WriteBitmapBits(percentage * mediaDet.StreamLength, width, height, tmpBitmapFile);



我是使用Windows的一部分DexterLib来做到这一点的.



is how I do it, using DexterLib, which is part of Windows.


这篇关于从视频流创建视频缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆