glut23 / webvtt-py

Read, write, convert and segment WebVTT caption files in Python.
MIT License
188 stars 56 forks source link

add support for parsing HLS WebVTT X-TIMESTAMP-MAP tag #25

Open omerholz opened 4 years ago

omerholz commented 4 years ago

Adding support for parsing HLS WebVTT X-TIMESTAMP-MAP tag. for more details see: https://tools.ietf.org/html/rfc8216#section-3.5

This PR keeps full backward compatibility. It adds a new structure TimestampMap to store the timestamp map, a new parser HlsWebVTTParser to parse webvtt payload that may or may not have X-TIMESTAMP-MAP tag and a new HlsWebVTT class to tie everything together:

vtt = HlsWebVTT.read('my_hls_subtitle_segment.vtt')
vtt.captions
vtt.timestamp_map.local
vtt.timestamp_map.mpegts
omerholz commented 4 years ago

@glut23 would love your feedback

glut23 commented 4 years ago

Hi @omerholz apologies for replying this late. I am thinking that we could incorporate this parsing functionality as part of the WebVTT class, so the user can parse a vtt file and read the HLS data if present. What do you think? Thanks for your contribution.

omerholz commented 4 years ago

I'm game to place it there @glut23 I'll ping you once I get to it