[英]Capture a frame of video file (.Net core)
我花了一些時間找到了一個.Net Core 的庫,並用它在某個特定點捕獲一幀視頻文件。 我知道那里有一些,例如我使用了 Mediatoolkit ,但它與 .net 核心不兼容。
它們都與 .net 框架兼容。 有幫助嗎?
您可以使用 ffmpeg 提取幀: https ://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
您必須知道您使用的是什么操作系統(Linux 或 Windows)才能提供兼容的 ffmpeg 二進制文件。
使用此 API,您可以使用參數從 C# 調用 ffmpeg(適用於 .NET Core): https ://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=netframework-4.7 .2
var process = new Process
{
StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
FileName = "ffmpeg", // or path to the ffmpeg
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = "your arguments here"
}
};
process.Start();
process.WaitForExit(10000); // wait for exit 10000 miliseconds
現在您只需要從文件系統讀取輸出(圖像文件)。
我使用了 Xabe.FFmpeg。 https://ffmpeg.xabe.net/docs.html
// sudo apt install ffmpeg
FFmpeg.SetExecutablesPath("/usr/bin/");
var conversion = await FFmpeg.Conversions.FromSnippet.Snapshot(newPath1, newPath2, TimeSpan.FromSeconds(0));
var result = await conversion.Start();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.