0

我想从托管在 Azure 存储中的 mp4 视频中提取缩略图。我在 C# 中的当前方法使用 NReco NuGet 包:

但这是一个本地文件。如何从 azure 存储文件中提取拇指。

string mp4inputpath = server.mappath("~/testfolder/myvideo.mp4");
string thumbOutputPath = server.mappath("~/testfolder/mythumb.jpg");
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
// Get the thumb at the frame 1 second into the video
ffMpeg.GetVideoThumbnail(mp4inputpath, thumbOutputPath, 1);

这样可行!但我需要为 mp4inputpath 使用 azure 存储文件 url。

我可以从 azure storage 下载 mp4 文件并将其临时保存到我的 azure web 应用程序中。我可以以编程方式做到这一点。

然后提取拇指,即ffMpeg.GetVideoThumbnail(mp4inputpath, thumbOutputPath, 1);

然后删除我的应用程序中的临时 mp4。

这可行,但我不知道将 mp4 文件下载到我的 azure web 应用程序中是否可取。我不知道它是否会扩展。到目前为止,这是我唯一的解决方案。

string mp4Url = @"https://mysorageaccount.blob.core.windows.net/mp4/vacation/summer/dogbarking.mp4";
string thumbOutputPath = server.mappath("~/testfolder/mythumb.jpg");
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
// Get the thumb at the frame 1 second into the video
ffMpeg.GetVideoThumbnail(mp4Url, thumbOutputPath, 1);

这似乎不起作用。没有错误,但 thumbOutputPath 文件为空。

4

1 回答 1

0

您所做的几乎就是您必须做的,因为您无法像打开本地文件一样在 Azure 存储中打开对象。因此,您需要将文件抓取到本地文件或流中。

至于扩展:这将取决于您在 Web 应用程序中运行的大小(和实例数量)。请注意,您应该将存储帐户和 Web 应用程序放在同一区域,以减少延迟并避免带宽出口费用。

于 2019-07-27T09:37:53.430 回答