I wish to extract parts from an m3u8 hls playlist given 'start time' and 'end unix time'
Assuming,
start unix time = 1667112116900
end unix time = 1667112133040
Example input file =
#EXTINF:5.9610000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112094442.ts
#EXTINF:5.3340000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112100495.ts
#EXTINF:5.2380000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112106453.ts
#EXTINF:5.4280000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112111854.ts
#EXTINF:5.3340000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112116984.ts
#EXTINF:5.3330000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112122404.ts
#EXTINF:6.6370000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112127907.ts
#EXTINF:6.2000000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112133401.ts
#EXTINF:6.2000000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112139827.ts
Required output file =
#EXTINF:5.3340000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112116984.ts
#EXTINF:5.3330000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112122404.ts
#EXTINF:6.6370000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112127907.ts
#EXTINF:6.2000000000,
/home/aanisnoor/Videos/DVR/segments_test_push/1667112133401.ts
There are more than 4000 lines from which I need to extract. Apologies for no code included as it was very incomplete. Python/C++ would work.
You don't show the complete playlist but if you have one or more EXT-X-PROGRAM-DATE-TIME tag in your playlist then you can easily relate the start of each segment to a wall clock time. Then you could convert that to a Unix time and easily make the comparison.
The implied time of each segment is the sum of the PROGRAM-DATE-TIME, plus all the durations from the EXTINF preceeding the segment in question.
In Python, it would probably be easiest to do this with a library like m3u8.