MKV files can have subtitles embedded within the file. It would be great if they could be selected by WebTorrent.
Same with OGV files. I'd like to support both. It's tricky, though, since the <video> tag doesn't support embedded subtitles directly. That means we have to parse them out of the video stream ourselves, convert them to VTT format, and stick them into a <track> tag.
Wow, I just found https://www.npmjs.com/package/matroska-subtitles which is written by @mathiasvr. Do you have plans to send a PR to add this to WebTorrent Desktop anytime soon?
Modules ftw!
@feross I am working on integrating this with the video tag and have several improvements in mind, especially regarding seeking, but this might take a while because i'm targeting the browser as well. Supporting WebTorrent Desktop could be done earlier though, so let me know if this is urgent.
@mathiasvr It's not super urgent, but would be nice to at least support basic embedded subtitles if the whole file is downloaded. No rush. Curious how your seeking improvements will work -- that sounds potentially really cool.
@feross Guess it's time to focus on implementing this in WebTorrent Desktop 😄
A problem with that is that I have primarily used the addTextTrack method of the html video element to dynamically add subtitles as they are parsed, which does not play well with the way WT separates the view and currently adds subtitles.
Another way is to parse the entire file and create a .vtt subtitle file, but this has the downside of only working when the whole file is downloaded. This should not be too complicated though so I can probably send a PR for this in the next couple of days.
A problem with that is that I have primarily used the addTextTrack method of the html video element to dynamically add subtitles as they are parsed, which does not play well with the way WT separates the view and currently adds subtitles.
Can you explain further?
Another way is to parse the entire file and create a .vtt subtitle file, but this has the downside of only working when the whole file is downloaded. This should not be too complicated though so I can probably send a PR for this in the next couple of days.
I think this approach would work fine for now. If there's some way to detect the presence of subtitles in the file, even if they're not parsed yet because the file is still downloading, that would be acceptable IMO.
We can notify the user in the UI that subtitles were detected and they will be available once the file completely downloads. Can the parser tell based on the .mkv metadata at the beginning of the file whether there are subtitles or not?
Can you explain further?
I don't see an easy way to access the video dom element from the SubtitlesController (or determine when it's created). Also we are currently parsing audio metadata in the WebTorrent process because that's the only place we can access the torrent file stream. So I haven't figured out whether to pass dom between processes or somehow expose the WebTorrent file stream? Maybe there is a better option?
Can the parser tell based on the .mkv metadata at the beginning of the file whether there are subtitles or not?
Yes this information (Track section) is usually available early in the file, but could in practice be placed at the end of it. I have written code that can read the position (file offset) of the Track section so this might not be a problem. But if the file has not been downloaded fully we need to use the WebTorrent file stream and not read from disk right?
Yes this information (Track section) is usually available early in the file, but could in practice be placed at the end of it. I have written code that can read the position (file offset) of the Track section so this might not be a problem.
If you know where the track information will be, then you can fetch it with file.createReadStream({ start: xx, end: xx}).
But if the file has not been downloaded fully we need to use the WebTorrent file stream and not read from disk right?
Correct. I would use the webtorrent file stream even if the file is fully downloaded, since it will just read it from disk in that case.
Hey guys any update on this? will this still take too long to implement (。•︿•。) ಥ_ಥ
Hi, guys,
I already posted in PR #855, but I'm interested in working on this feature. What's the state of PR #855 and is it salvageable, or should I start from scratch?
Interested in this feature too.
ping
pong
...ball
Is this still being worked on? :/
Most helpful comment
...ball