使用 NuGet 包 M3USharp 解析 M3U8

发布于 2025-01-12 15:39:30 字数 443 浏览 1 评论 0原文

我需要读入 m3u8 主播放列表、各个块播放列表和各个二进制数据块。我只是移动数据,不进行任何播放。

我使用 NuGet 包 M3USharp 来解析主播放列表,它为我提供了流列表。从每个单独的流中,我可以获得每个chuck 播放列表。但我无法解析块列表来获取各个块。我找不到任何示例来说明如何使用此包执行此操作。

这是我的代码:

var content = getMasterFilePlaylist();
M3UFile m3u8File = M3UReader.Parse(content);

foreach(var stream in m3u8File.Streams)
{
     Console.WriteLine(stream.Path);

     // do stuff here...
}

但我找不到任何用于配对块列表的示例。 我还应该使用其他软件包吗?

I need to read in an m3u8 master playlist, the individual chunk playlists, and the individual binary data chunks. I am just moving the data around, not doing any playbacks.

I'm using a NuGet package M3USharp to parse the master playlist, which gives me a list of streams. From each individual stream, I can get each chuck playlist. but I can not parse the chunk lists to get the individual chunks. I can not find any examples showing how to do this with this package.

this is my code:

var content = getMasterFilePlaylist();
M3UFile m3u8File = M3UReader.Parse(content);

foreach(var stream in m3u8File.Streams)
{
     Console.WriteLine(stream.Path);

     // do stuff here...
}

But I can not find any examples for paring the chunk lists.
are there any other packages I should be using?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

同展鸳鸯锦 2025-01-19 15:39:30

尝试使用 https://www.nuget.org/packages/M3U8Parser/ 代替。

喜欢:

var masterPlaylist = MasterPlaylist.LoadFromFile("master.m3u8");

// Example, list all stream uri
foreach(var stream in masterPlaylist.Streams)
{
    Console.WriteLine("Uri:" + stream.Uri);
}

或:

var mediaPlaylist = MediaPlaylist.LoadFromFile("playlist.m3u8");

Console.WriteLine(mediaPlaylist.HlsVersion);
Console.WriteLine(mediaPlaylist.PlaylistType);

foreach (var mediaSegment in mediaPlaylist.MediaSegments)
{
    foreach (var segment in mediaSegment.Segments)
    {
        Console.WriteLine(segment.Uri);
        Console.WriteLine(segment.ByteRangeLentgh);
        Console.WriteLine(segment.ByteRangeStartSubRange);
        Console.WriteLine(segment.Duration);
    }
}

Try to use https://www.nuget.org/packages/M3U8Parser/ instead.

Like :

var masterPlaylist = MasterPlaylist.LoadFromFile("master.m3u8");

// Example, list all stream uri
foreach(var stream in masterPlaylist.Streams)
{
    Console.WriteLine("Uri:" + stream.Uri);
}

OR :

var mediaPlaylist = MediaPlaylist.LoadFromFile("playlist.m3u8");

Console.WriteLine(mediaPlaylist.HlsVersion);
Console.WriteLine(mediaPlaylist.PlaylistType);

foreach (var mediaSegment in mediaPlaylist.MediaSegments)
{
    foreach (var segment in mediaSegment.Segments)
    {
        Console.WriteLine(segment.Uri);
        Console.WriteLine(segment.ByteRangeLentgh);
        Console.WriteLine(segment.ByteRangeStartSubRange);
        Console.WriteLine(segment.Duration);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文