从ts文件列表创建m3u8文件 [英] Create m3u8 file from list of ts files

查看:245
本文介绍了从ts文件列表创建m3u8文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从ts文件列表中创建"m3u8"文件.我该怎么办?

I want to create 'm3u8' file from the list of ts files. How can I do it?

我确实在Google&中搜索阅读了ffmpeg的文档,但我什么也没找到.

I did search in google & read documentation of ffmpeg but I didn't find anything.

推荐答案

目前尚不清楚您要询问以下哪种情况,因此以下是这两种情况的快速解答:

It's not clear which of the following cases you're asking about, so here's a quick answer for both:

1)如果您从包含内容的单个文件开始这是最常见的情况.通常,从源材料创建可播放的Hls流需要执行三个步骤.

1) If you're starting with a single file that contains your content This is the most common case. In general, there are three steps to creating a playable HlS stream from source material.

  • 对于每个所需的输出级别(为简单起见,请使用比特率"),您需要创建分段的.ts文件的集合.
  • 对于每个输出级别,您需要一个播放列表清单(m3u8),其中包含组成内容的段文件列表.
  • 对于整个流,您需要一个主清单(另一个m3u8)来列出播放列表.

FFMpeg可以完成所有这三个操作.

FFMpeg can do all three of these.

2)如果您从.ts文件的集合开始如果您确实是从.ts文件的集合开始的,则可以按照上一个答案中的说明手工构建m3u8文件,也可以编写脚本来完成.

2) If you're starting with a collection of .ts files If you really are starting with a collection of .ts files, you could either hand-build an m3u8 file as described in the previous answer, or you could write a script to do it.

在任何一种情况下,.ts文件都有一些注意事项:

In either case, there are some considerations for the .ts files:

  • 如果段文件不属于不间断序列(就像它们是从单个源剪辑中转码以用于HLS)一样,则需要在段之间插入EXT-X-DISCONTINUITY标签没有相同的编码特性或没有单调增加的PTS(表示时间戳)值.

  • If the segment files do not belong to an uninterrupted sequence (as they would if they were transcoded from a single source clip for use in HLS), you’ll need to insert EXT-X-DISCONTINUITY tags between segments that don’t have the same encoding characteristics or that don’t have monotonically increasing PTS (presentation timestamp) values.

虽然分段的长度不必全部相同,但最长的分段不得超过EXT-X-TARGETDURATION标记中指定的(整数)秒.

While the segments don't need to all be the same length, the longest one must not exceed the (integer) number of seconds specified in the EXT-X-TARGETDURATION tag.

所有段的最大比特率不得超过EXT-X-TARGETDURATION标记中指定的值.

The maximum bitrate for all the segments must not exceed the value specified in the EXT-X-TARGETDURATION tag.

构建m3u8文件后,可以通过验证程序运行该文件以查找任何问题.这比挠头想知道为什么HLS流在播放器/浏览器之间播放效果差或不一致要容易得多.

When you've built your m3u8 file, it helps to run it through a validator to find any problems.This is a lot easier than scratching your head wondering why an HLS stream plays poorly or inconsistently across players/browsers.

  • mediaStreamValidator on macOS is very good https://developer.apple.com/documentation/http_live_streaming/about_apple_s_http_live_streaming_tools
  • Also consider the online tool at Theo: http://inspectstream.theoplayer.com/

这篇关于从ts文件列表创建m3u8文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆