Grabbing a thumbnail from a video when uploading. (Azure Blob Storage)

自闭症网瘾萝莉.ら 提交于 2019-12-08 07:45:08

问题


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);

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?

I have tried:

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

  • 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);)

Thanks in advance for any help!


回答1:


Note that GetVideoThumbnail method always creates temporary file for output jpeg file even when overload that accepts Stream is used.

If you goal is to avoid creation of temporary file you can use FFMpegConverter.ConvertLiveMedia overload that accepts inputSource from file and writes result to output stream (extracting video thumbnail is equivalent to conversion to MJPEG stream with only 1 frame).




回答2:


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);


来源:https://stackoverflow.com/questions/23232056/grabbing-a-thumbnail-from-a-video-when-uploading-azure-blob-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!