Is there a way to programmatically read the contents of a subtitle text stream embedded in an mkv file without extracting the track altogether?

2

Extracting a subtitle track from an mkv would take a bit of a long time, well over a few minutes in the case of huge video filesizes (>10GB), and I think analyzing the text contents of a subtitle stream would be beneficial to figuring out if I want to extract it or not.

A video player is able to seemingly read the entire contents of a subtitle stream from the getgo, so I assume there is a way.

IdontLikeSand

Posted 2018-06-05T07:44:40.947

Reputation: 21

What is the difference between “reading” and “extracting”? – szatmary – 2018-06-05T15:05:58.773

@szatmary Extracting the track takes a long time. A video player is able to read the entire text stream as soon as the video file is loaded, so it must be doing something different than extracting and then reading – IdontLikeSand – 2018-06-05T18:58:02.407

“A video player is able to seemingly read the entire contents of a subtitle stream from the getgo,” <- this is your faulty assumption. A video player is not magic. So either the player has a separate file (like an srt) or there is something wrong with how you “extract” – szatmary – 2018-06-05T19:03:21.970

the subtitle is embedded into the mkv file. I use mkvmerge to extract the subtitle file. With a 10GB mkv file, it takes upwards of 4-5 minutes to extract the subtitle track from the mkv with mkvmerge. – IdontLikeSand – 2018-06-06T03:53:43.563

mkvmerge must be doing more that just reading the subtitles. Or you have a slow hard drive. BTW, how do you know the player has ALL the sub titles when it starts to render, and it not reading them just in time to display? – szatmary – 2018-06-06T03:57:06.810

I tested it by adding a subtitle line at the very end of an SRT file, wrote the timestamp as '00:00:00,500 --> 00:00:02,000' and re-muxed it back into the mkv file using mkvtoolnix. The video player displayed the subtitle just fine. This was a 3-hour long 15GB video – IdontLikeSand – 2018-06-06T04:06:03.833

1I’m not sure what that proves except the SRT parser can reorder entries before writing them to the file. – szatmary – 2018-06-06T04:10:04.957

No answers