O
O
OKNOZA2015-05-27 08:50:47
PHP
OKNOZA, 2015-05-27 08:50:47

M3u8 does not start at the beginning of the playlist?

I am writing a channel through FFmpeg (in HLS format) cutting, a playlist is automatically created there, the question is, how can I play not from the beginning of the playlist, but for example from a certain moment?

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:11
#EXTINF:10.652922,
live000.ts
#EXTINF:9.480000 ,
live001.ts
#EXTINF:10.440000,
live002.ts
#EXTINF:9.480000,
live003.ts
#EXTINF:9.480000,
live004.ts
#EXTINF:10.440000,
live005.ts
#EXTINF:9.480000,
live006.ts
#EXTINF:10.440000,
live007 .ts
#EXTINF:9.480000,
live008.ts
#EXTINF:9.480000,
live009.ts
#EXTINF:10.440000,
live010.ts
#EXTINF:9.480000,
live011.ts
#EXTINF:10.440000,
live012.ts
#EXTINF:9.480000,
live013.ts
#EXTINF:10.440000,
live014.ts

For example, to play the last chunk live014.ts , preferably using PHP, since everything will be on the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OKNOZA, 2015-05-29
@OKNOZA

The problem was solved, on that day, I will unsubscribe now here.

#EXTM3U
 #EXT-X-TARGETDURATION:61
 #EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:60,
live000.ts
#EXTINF:60,
live001.ts
****
тут чанки ваши прописываем.
****
#EXTINF:60,
live005.ts
#EXT-X-ENDLIST

It turns out one chunk duration 60 sec = 1 minute.
You can set your own time in FFmpeg, the optimal time is 5 seconds. (60 is my expert.)
Also the PHP code for preparing the playlist.
$file = "record.m3u8";
//если файла нету... тогда
if( !file_exists($file)) {
$fp = fopen($file, "w"); // ("r" - считывать "w" - создавать "a" - добовлять к тексту), мы создаем файл
 fwrite($fp, "#EXTM3U\n #EXT-X-TARGETDURATION:10\n #EXT-X-PLAYLIST-TYPE:VOD\n");
 for($i =  0; $i < 6; ++$i){
    fwrite($fp, sprintf("#EXTINF:60,\nlive%03d.ts\n", $i));
 }
 fwrite($fp,"#EXT-X-ENDLIST");
fclose ($fp);
}

Attach it to the EPG, and you can make a video archive on the site. (and also in PHP replace with your own values)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question