Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate m3u8 file with Extended M3U directives by ffmpeg

Tags:

ffmpeg

I am generating m3u8 files by using ffmpeg.

Command is like below:

ffmpeg -i sourcefile.mp4 -vcodec libx264 -acodec libvo_aacenc -b:v 128k -flags -global_header -map 0:0 -map 0:1 -f segment -segment_time 4 -segment_list_size 0 -segment_list testlist.m3u8 -segment_format mpegts stream%05d.ts

This is creating m3u8 files successfully, but it does not add extended m3u8 directives.

So , how to add those directives ?

Thanking in Advance,

Sagar Joshi

like image 823
Sagar Joshi Avatar asked Oct 07 '22 17:10

Sagar Joshi


1 Answers

According to the HTTP Live Streaming specification, and unless you're using an older version of ffmpeg (I'm using 1.0), the m3u8 file it creates is fine.

Mine looks like this (while ffmpeg is still encoding):

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOWCACHE:1
#EXTINF:8.308300,
stream00000.ts
#EXTINF:8.341667,
stream00001.ts

By omitting the #EXT-X-ENDLIST tag the client should know to reload this m3u8 file for more media. That is outlined here. As soon as ffmpeg quits (or I ctrl-c out of it) #EXT-X-ENDLIST is added to the end of the file.

like image 123
MithrilTuxedo Avatar answered Oct 10 '22 02:10

MithrilTuxedo