bennettpeter / android-MythTV-Leanfront

:tv: MythTV Android TV frontend
GNU General Public License v3.0
45 stars 9 forks source link

Cannot enable subtitles while playing h.264 video with 2 vobsub tracks in mkv container #23

Closed faginbagin closed 2 years ago

faginbagin commented 2 years ago

I can play a video in our v29 library, but I cannot turn on subtitles via the Options menu. When I try, I get an error dialog:

Playback Failed.
Unexpected Runtime exception
Unexpected runtime error
                Exit   Continue

If I choose "Continue", I'm returned to the same dialog. Exit takes me back to the video's "info" screen, where I can choose to play from bookmark or from start. I have added the following files to: https://drive.google.com/drive/folders/1mtT77n88n_CWH6vWnmCb-37zktPtsk3r?usp=sharing

1228-312-subtitle.log - "adb logcat" output that covers the time when the error occurs 1228-IMG_20211228_182612585.jpg - screenshot just before selecting English subtitle 1228-IMG_20211228_182624276.jpg - screenshot of error dialog after selecting subtitle 1228-mediainfo.out - Output from mediainfo for the video file

Note: the screenshots were taken after the log was captured, so the timestamps won't line up.

I have a variety of media to choose, with different subtitle types and captions. I'll wait for feedback before testing more types.

bennettpeter commented 2 years ago

I have never tested it with vobsub subtitles, so not surprising. At least the program does not crash.

Can you supply a sample of video that fails.

faginbagin commented 2 years ago

I added leanfront-issue-23.mkv to google drive. It's a 21MB file containing one chapter of the source video, with a duration of 2:24, although mythfrontend and leanfront think it's 2:27.

bennettpeter commented 2 years ago

There is some inconsistency in the ExoPlayer code, where it has code to extract vobsubs from mkv files, but then when you enable them it throws an error saying that they are not supported. I suspect there is an ExoPlayer bug.

It is time to upgrade leanfront to the latest ExoPlayer version, and then dig into the ExoPlayer code to make this work. That will have to wait until next week.

faginbagin commented 2 years ago

Do you know what types of subtitles/captions do and don't work in leanfront? I have a variety of samples, including the really old NuppelVideo format with .nuv extension recorded with framebuffer tuners; ivtv encoded captions recorded with Hauppauge's PVR-150 analog to MPEG2 tuners. as well as ATSC and clearQAM recordings. Then my video library has a mix of caption types, including SRT muxed into MKV containers. and tx3g subtitles in mp4 containers. Would it help if I tested leanfront's ability to play any or all of these types?

bennettpeter commented 2 years ago

Thank you for your help in improving leanfront. If you have other types to try please go ahead and I will make any fixes necessary.

Looking at it more closely, it seems that vobsub is not supported by ExoPlayer. See https://github.com/google/ExoPlayer/issues/3008 and https://github.com/google/ExoPlayer/issues/8260

The extractor does extract vobsub subtitles from mkv files, but fails when there is no decoder to process them.

Subtitle Decoders are available for these: WebVTT (WebvttDecoder) WebVTT (MP4) (Mp4WebvttDecoder) TTML (TtmlDecoder) SubRip (SubripDecoder) SSA/ASS (SsaDecoder) TX3G (Tx3gDecoder) Cea608 (Cea608Decoder) Cea708 (Cea708Decoder) DVB (DvbDecoder) PGS (PgsDecoder) Exoplayer Cues (ExoplayerCuesDecoder)

I don't know if all of them are supported in mkv files. Some may be specific to streaming playback or other situations. Note there is support in Exoplayer for srt file subtitles but I have not added the necessary code to leanfront. My feeling is that these are out of date, having been mainly for use with avi files. If you have an srt file, mkvmerge will add it to your video easily and that will be supported.

I see that PGS is a bitmap type subtitle like vobsub and is now supported.

They are waiting for somebody to submit a decoder for inclusion in the code. I have found Exoplayer to be very responsive to code submissions. I wonder how hard it is to build a decoder ...

faginbagin commented 2 years ago

I have both srt muxed into mkv containers and separate srt files alongside their mkv counterparts. The pgs subtitles are for blu ray and vobsub are for dvd. I find it surprising that they had pgs support before vobsub.

bennettpeter commented 2 years ago

I have added code to leanfront that displays a toast if you select an unsupported subtitle type. At least this way it does not crash when you select one.

bennettpeter commented 2 years ago

All changes have now been incorporated in release version 20220113-leanfront-release-v0-326-g2e67802.apk