【发布时间】:2021-05-16 02:26:45
【问题描述】:
我正在尝试从“.m3u8”网址中的视频中提取音频。它适用于下面说明的这个命令,但我找不到如何使用 C# 包装库(如 Xabe.FFmpeg、FFMPEGCore)来做到这一点。有人知道怎么做吗?
PS:我使用的是.net core
ffmpeg -i "https://blablabla/playlist.m3u8" -acodec mp3 -ab 128k test.mp3
【问题讨论】:
我正在尝试从“.m3u8”网址中的视频中提取音频。它适用于下面说明的这个命令,但我找不到如何使用 C# 包装库(如 Xabe.FFmpeg、FFMPEGCore)来做到这一点。有人知道怎么做吗?
PS:我使用的是.net core
ffmpeg -i "https://blablabla/playlist.m3u8" -acodec mp3 -ab 128k test.mp3
【问题讨论】:
我自己找到了解决方案。我使用了“Xabe.FFmpeg”库。 你可以看下面的代码。
internal class Program
{
private static string link = "yourlink/playlist.m3u8";
private static async Task Main(string[] args)
{
var mediaInfo = await FFmpeg.GetMediaInfo(link);
var conversion = await FFmpeg.Conversions.FromSnippet.ExtractAudio(mediaInfo.Path, "test.mp3");
conversion.OnProgress += async (sender, args) =>
{
await Console.Out.WriteLineAsync($"[{args.Duration}/{args.TotalLength}][{args.Percent}%]");
};
await conversion.SetAudioBitrate(128000).SetOutputFormat(Format.mp3).Start();
Console.ReadKey();
}
}
【讨论】: