SUPtitles renders Blu-ray subtitles(.sup) in the browser using JS. This project is still in development.
Display subtitles in the browser without using OCR or other methods to pre-process the subtitles. No changes to the original text and styling(OCR is not always reliable).
Thanks to this article by TheScorpius666, I was able to parse the .sup files and display them by using a HTML canvas.
The subtitles(.sup) can be extracted from a video using ffmpeg
ffmpeg -i video.mkv -map 0:s:0 -c copy subtitle.sup
Download dist folder or run
npm i suptitles
import SUPtitles from 'suptitles' // Or './dir/to/index.js'
const videoElement = document.getElementById('video')
// Pass video element and subtitle url to constructor
const sup = new SUPtitles(videoElement, './exampleSubtitle.sup')
SUPtitles will make a canvas covering 100% of its parent. For the subtitles to overlay the video properly, add a container with the position property set to relative.
<div style="position:relative;">
<video
controls
style="width:100%;"
id="video"
></video>
</div>
To dispose of SUPtitles call the dispose method.
const sup = new SUPtitles(videoElement, './exampleSubtitle.sup')
sup.dispose()
- After seeking the current subtitle will be skipped
- No feedback from constructor, invalid files will not output any error
- Probably more..
- Change tsconfig.json to fit your preferences
- Run tsc