Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing m3u8 file dynamically during runtime (iOS)

Does anyone know if I can change a m3u8 file dynamically during runtime of the app?

The scenario is as follows: lets say i have multiple .ts files ready to play in a sequence, for example 1.ts , 2.ts , 3.ts etc...

Now during run time, i want to change the order to 1.ts , 3.ts and only then 2.ts.

Is this possible?

Thanks,

like image 211
orrko Avatar asked May 15 '11 11:05

orrko


People also ask

How do I edit a M3U8 file?

M3U8 files can be edited and read by most text editors, including Notepad in Windows. However, as you can see below, opening one with Notepad only lets you read the file references.

What is index M3U8?

An M3U8 file is a playlist file used by various audio and video players. It contains plain text that describes where the audio and video files included in the playlist are located. These descriptions may take the form of file paths or URLs.

What is HLS playlist?

HLS or HTTP Live Streaming is an HTTP-based adaptive bitrate video streaming protocol introduced by Apple in 2009 that describes a set of tools and procedures for streaming video and audio over the internet.

What is the format of an M3U8 file?

What is a M3U8 file? The M3U8 file format is used by audio and video playback programs to store playlists. The playlist consists of an Internet web path or URL, along with information about each track in the list (playtime duration). M3U8 files use UTF-8 character encoding as compared to M3U file types.


1 Answers

The answer is in the HLS standard (August 2017):

The server MUST NOT change the Media Playlist file, except to:

o  Append lines to it (Section 6.2.1).

o  Remove Media Segment URIs from the Playlist in the order that they
 appear, along with any tags that apply only to those segments
 (Section 6.2.2).

o  Increment the value of the EXT-X-MEDIA-SEQUENCE or EXT-X-
 DISCONTINUITY-SEQUENCE tags (Section 6.2.2).

o  Add an EXT-X-ENDLIST tag to the Playlist (Section 6.2.1).

Note the standard draft (circa 2012) from the original answer was slightly different:

The server MUST NOT change the Playlist file, except to:

Append lines to it (Section 6.2.1).

Remove media URIs from the Playlist in the order that they appear, along with any tags that apply only to those media URIs (Section 6.2.2).

Increment the value of the EXT-X-MEDIA-SEQUENCE tag (Section 6.2.2).

Add or remove EXT-X-STREAM-INF tags or EXT-X-I-FRAME-STREAM-INF tags (Section 6.2.4). Note that clients are not required to reload variant Playlist files, so changing them may not have immediate effect.

Add an EXT-X-ENDLIST tag to the Playlist (Section 6.2.1).

All in all, what you aim at is not supported by the protocol.

Anyway it's rather pointless as segments may correlate between themselves in order (has common key-frames).

like image 84
Daniel Bauke Avatar answered Sep 25 '22 22:09

Daniel Bauke