【问题标题】:Extracting audio from a video from ".m3u8" URL从“.m3u8” URL 的视频中提取音频
【发布时间】: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

【问题讨论】:

    标签: c# .net-core ffmpeg


    【解决方案1】:

    我自己找到了解决方案。我使用了“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();
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-09
      • 2020-06-26
      • 1970-01-01
      • 1970-01-01
      • 2011-01-08
      • 2012-07-10
      • 2011-07-27
      相关资源
      最近更新 更多