2024-06-06, 09:45 PM
(This post was last modified: 2024-07-11, 08:52 PM by Arcus. Edited 6 times in total.
Edit Reason: Updated todo list
)
Hello,
I'm currently working on a way to enable native PGS support without transcoding in the web-version of Jellyfin.
Problem:
I really dislike burned-in subtitles. I like my my media library to be as clean and as complete as possible with all audio tracks and all subtitles when digitize my Blue Rays. Blue Rays always have graphical subtitles (PGS - .sub) that cannot be converted into text subtitles. Graphical subtitles can only be displayed with video transcoding. I'm using a NAS without GPU support, so transcoding even a 1080p video is reaching the CPUs limit. Also the video quality drops.
I've built a tool that converts the video with all audio tracks into a MP4 using stream-friendly codecs. Then I extract all PGS subtitles, store them as .sub files next to the video. Then I run an automatic script to OCR the images and create an SRT file. The OCR only works half the time. Some images can't be read at all and are empty and every tenth word has a typo.
Yes, I'm obsessed with having a perfect media collection...
Solution:
Allow Jellyfin to stream raw .sub files to the client and let the client render the graphical subtitles on-top of the video.
Tasks / Status:
Problems and limitations...
Repositories:
Is this something anyone is interested in or am I the only one who would benefit from this? Is this even in the spirit of the Jellyfin project? Is it worth to build a clean implementation from the prototype, so it could be merged some day?
Thanks for reading all of this!
I'm currently working on a way to enable native PGS support without transcoding in the web-version of Jellyfin.
Problem:
I really dislike burned-in subtitles. I like my my media library to be as clean and as complete as possible with all audio tracks and all subtitles when digitize my Blue Rays. Blue Rays always have graphical subtitles (PGS - .sub) that cannot be converted into text subtitles. Graphical subtitles can only be displayed with video transcoding. I'm using a NAS without GPU support, so transcoding even a 1080p video is reaching the CPUs limit. Also the video quality drops.
I've built a tool that converts the video with all audio tracks into a MP4 using stream-friendly codecs. Then I extract all PGS subtitles, store them as .sub files next to the video. Then I run an automatic script to OCR the images and create an SRT file. The OCR only works half the time. Some images can't be read at all and are empty and every tenth word has a typo.
Yes, I'm obsessed with having a perfect media collection...
Solution:
Allow Jellyfin to stream raw .sub files to the client and let the client render the graphical subtitles on-top of the video.
Tasks / Status:
- JavaScript PGS renderer - Implemented
- Steam external PGS (.sup / .sub files) - Implemented
- Steam embedded PGS (eg. from .mkv) - Implemented
- Subtitle time offset - Implemented
- Background rendering via WebWorker - Implemented
- Compression - Pending
- Setting to disable/enable PGS streaming - Implemented
- Jellyfin Web - Implemented
- Jellyfin Vue - Implemented
- Jellyfin Android (web player) - Implemented by web player
- Jellyfin Android (exo player) - Not supported by Exo
- Jeyllfin Chromecast App - Implemented by web player
- Jeyllfin Chromecast Quick Cast - Not supported by Chromecast?
- Jeyllfin iOS - Missing hardware / Can't test
- Jeyllfin AppleTV - Missing hardware/ Can't test
Problems and limitations...
- Currently the subtitle must be external. However, it is possible to use ffmpeg to export PGS streams.
- PGS files are large ~ 20-40mb per full language per episode. Even more for movies.
- Downloading can take some time on slower connections. It may delay the playback or subtitles aren't ready for the first seconds. I implemented an async pgs stream reader. Early subtitles can can be displayed while the rest of the pgs file is still downloading. Big win!
- The player must load the whole PGS file into memory on playback. Partial reading isn't possible.
- The PGS renderer has to be implemented for every player: Web, Android, iOS, etc.
- Subtitle cropping isn't implemented yet. It is also not implemented in FFmpeg and the feature is properly not used anywhere...
Repositories:
- libpgs-js: https://github.com/Arcus92/libpgs-js
- jellyfin: https://github.com/Arcus92/jellyfin/tree/native-pgs
- jellyfin-web: https://github.com/Arcus92/jellyfin-web/tree/native-pgs
- jellyfin-vue: https://github.com/Arcus92/jellyfin-vue/tree/native-pgs
Is this something anyone is interested in or am I the only one who would benefit from this? Is this even in the spirit of the Jellyfin project? Is it worth to build a clean implementation from the prototype, so it could be merged some day?
Thanks for reading all of this!