I'm attempting to take a 5-minute video file and produce a single-file HLS playlist with this command
ffmpeg -i video.mp4 -codec copy -bsf:v h264_mp4toannexb -hls_time 4 -hls_flags single_file -hls_list_size 0 video.m3u8
Produces a playlist like so:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.338667,
#EXT-X-BYTERANGE:535424@0
video.ts
#EXTINF:5.338667,
#EXT-X-BYTERANGE:316592@535424
video.ts
#EXTINF:5.338667,
#EXT-X-BYTERANGE:285384@852016
video.ts
#EXT-X-ENDLIST
What I wanted to:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.338667,
#EXT-X-BYTERANGE:535424@0
video-0-535424.txt
#EXTINF:5.338667,
#EXT-X-BYTERANGE:316592@535424
video-535424-316592.txt
#EXTINF:5.338667,
#EXT-X-BYTERANGE:285384@852016
video-852016-285384.txt
#EXT-X-ENDLIST
Or:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.338667,
#EXT-X-BYTERANGE:535424@0
video.txt#0-535424
#EXTINF:5.338667,
#EXT-X-BYTERANGE:316592@535424
video.txt#535424-316592
#EXTINF:5.338667,
#EXT-X-BYTERANGE:285384@852016
video.txt#852016-285384
#EXT-X-ENDLIST
I still want to convert to one single .ts/or anything else, just want to edit how it write in video.m3u8. Is it possible with ffmpeg only? If so, how can it be done? Or are there any js/nodejs module that can rewrite video.m3u8 to something like video.txt#range-here
So what you can do is, you can parse the .m3u8 file using m3u8-parser
You need to parse the .m3u8 file, extract each line and check if that line contains .ts. If it contains, replace it with .txt. That's the hack i did in my project.