gpt4 book ai didi

c# - 从 ".m3u8"URL 的视频中提取音频

转载 作者:行者123 更新时间:2023-12-04 23:33:26 25 4
gpt4 key购买 nike

我正在尝试从“.m3u8”URL 的视频中提取音频。它适用于下面所述的这个命令,但我找不到如何使用 C# 包装库(如 Xabe.FFmpeg、FFMPEGCore)来做到这一点。有人知道该怎么做吗?
PS:我正在使用.net核心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();
}
}

关于c# - 从 ".m3u8"URL 的视频中提取音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66170117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com