上传时从视频中获取缩略图. (Azure Blob存储) [英] Grabbing a thumbnail from a video when uploading. (Azure Blob Storage)

查看:130
本文介绍了上传时从视频中获取缩略图. (Azure Blob存储)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个将视频上传到Azure blob存储并可以正常工作的系统.我想实现一项功能,该功能可以在上传时从视频中获取缩略图,并将其也推送到Azure.

I currently has a system that uploads videos to Azure blob storage and works fine. I would like to implement a feature that grabs a thumbnail from the video while uploading and pushes it to Azure as well.

我尝试按照建议使用它:

I tried using this as suggested:

new FFMpegConverter().GetVideoThumbnail(file, outputJPEG);

问题在于我不确定要用作outputJPEG,因为我没有要写入的文件,而是想将该文件写入Azure的Blob存储.

The problem is that I am not sure what to use as outputJPEG as I don't have a file I am writing to, but rather want to write that file to Azure's blob storage.

有人可以帮我解决这个问题,或者建议其他方法吗?

Can anyone help me figure out this issue, or perhaps suggest an alternative method?

我尝试过:

  • 创建一个新的空HttpPostedFileBase作为outputJPEG文件,但这是不可能的,因为它仅接受用户上传的文件.

  • Creating a new, empty HttpPostedFileBase as the outputJPEG file but this is impossible as it only accepts user uploaded files.

使用文件流,但这似乎不起作用,因为它需要写入文件的位置,而不是让我直接进入blob存储. (通过:blob.UploadFromStream(file.InputStream);)

Using filestream but this does not seem to work as it requires a location of a file it's writing to, rather than letting me just push to the blob storage. (via: blob.UploadFromStream(file.InputStream);)

在此先感谢您的帮助!

推荐答案

似乎有一个覆盖了流的替代项,因此您可以将其写入内存流,然后获取该内存流并在其中创建一个新文件. Blob存储区:

It looks like there is an override that takes a stream, so you could write it to a memory stream and then take the memory stream and create a new file in the blob store:

MemoryStream ms = new MemoryStream();
var converter = new FFMpegConverter();

converter.GetVideoThumbnail(file, ms);

ms.Position = 0;

// Write ms to a blob object here
blockblob.UploadFromStream(ms);

这篇关于上传时从视频中获取缩略图. (Azure Blob存储)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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