dragonflylee/switchfin

Some external subtitle doesn't work

Closed this issue · 13 comments

As title, I think this client don't support CJK subtitles by default (only squares are shown) and the ones with custom style(ex. fancy ASS subs) doesn't even get displayed.

While I'm not sure if it's doable to force disable custom style, I checked the code to see if I can fix plain CJK sub and saw that it seems I could place different fonts in /switch/Switchfin as font.ttf, but that doesn't work for me, already tried to hack the source around but no luck so far, any suggestion?

There should be two ways to achieve this:

The first way is to modify mpv to load system fonts. Here's a simple example for displaying OSD text: xfangfang/mpv@58f275c. Subtitles can also be handled similarly.

The second way is to place custom font file in the configuration directory. According to mpv's documentation: https://mpv.io/manual/stable/#options-sub-font-provider, you can put subfont.ttf in the configuration directory.

The first way is to modify mpv to load system fonts. Here's a simple example for displaying OSD text: xfangfang/mpv@58f275c. Subtitles can also be handled similarly.

The second way is to place custom font file in the configuration directory. According to mpv's documentation: https://mpv.io/manual/stable/#options-sub-font-provider, you can put subfont.ttf in the configuration directory.

@xfangfang I didn't find where I could apply the first method so I just tried the second one, and it works flawlessly, thanks a lot! Do you also know how should I deal with those fancy subs with custom style?

@dic1911
I haven't actually tested it, but subtitles that work properly on MPV should also work properly in switchfin.

If you have tested that a content is good in MPV, but it does not display correctly in switchfin, you can post the ass subtitle file here.

I guess some font settings in the ass subtitle may be causing it to not run properly.

@xfangfang Just tested and confirmed it's working with mpv, but nothing is visible with Switchfin, anyway here's the sub:
[Nekomoe kissaten&LoliHouse] Megami no Cafe Terrace - 01 [WebRip 1080p HEVC-10bit AAC ASSx2].JPTC.zip

This subtitle requires some fonts:

Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,FZLanTingHei-DB-GBK,48,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,3,0,1,2.5,0,2,15,15,15,1
Style: Text_CN,FZLanTingYuan-DB-GBK,48,&H00FFFFFF,&H000000FF,&H005051E0,&H00000000,0,0,0,0,100,100,2,0,1,2.5,0,2,15,15,32,1
Style: Text_JP,FOT-Seurat ProN B,32,&H00FFFFFF,&H000000FF,&H005051E0,&H00000000,0,0,0,0,100,100,1.5,0,1,2,0,2,15,15,5,1
Style: Text_CNTOP,FZLanTingYuan-DB-GBK,46,&H00FFFFFF,&H000000FF,&H005051E0,&H00000000,0,0,0,0,100,100,2,0,1,2.5,0,8,15,15,36,1
Style: Text_JPTOP,FOT-Seurat ProN B,30,&H00FFFFFF,&H000000FF,&H005051E0,&H00000000,0,0,0,0,100,100,1.5,0,1,2,0,8,15,15,5,1
Style: Title_SC,FZFW ZhuZi A YuanS B,40,&H00FFFFFE,&H000000FF,&H00514A3C,&H00FFFFFF,0,0,0,0,100,100,2,0,1,1.6,0,2,0,0,10,1
Style: Title_TC,FZLanTingYuan-DB-GBK,33,&H00FFFFFE,&H000000FF,&H00514A3C,&H00FFFFFF,0,0,0,0,100,100,2,0,1,1.6,0,2,0,0,10,1
Style: Screen,FZLanTingHei-DB-GBK,50,&H00FFFFFF,&H000000FF,&H00000000,&H00FFFFFF,0,0,0,0,100,100,0,0,1,0,0,7,15,15,15,1
Style: Comment,FZLanTingYuan-DB-GBK,30,&H00FFFFFF,&H000000FF,&H005051E0,&H00000000,0,0,0,0,100,100,2,0,1,2,0,7,15,15,15,1
Style: Staff,FZLanTingYuan-DB-GBK,36,&H00FFFCFD,&H000000FF,&H00CD6F63,&H00000000,0,0,0,0,100,100,1,0,1,1.3,0,8,15,15,8,1
Style: Furi,FZLanTingYuan-DB-GBK,24,&H00FFFFFF,&H000000FF,&H005051E0,&H00000000,0,0,0,0,100,100,2,0,1,2,0,2,15,15,80,1
Style: OP_JP,FOT-TsukuBRdGothic Std D,44,&H00FFFFFF,&H000000FF,&H005A515E,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,10,10,10,1
Style: OP_SC,FZFW ZhuZi A YuanS D,38,&H00FFFFFF,&H000000FF,&H005A515E,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,10,10,15,1
Style: OP_TC,FZLanTingYuan-M-GBK,34,&H00FFFFFF,&H000000FF,&H005A515E,&H00000000,0,0,0,0,100,100,3,0,1,2,0,8,10,10,15,1
Style: ED_JP,FOT-UDMarugo_Large Pr6N M,54,&H00FFFFFF,&H000000FF,&H00FFFFFF,&H00000000,0,0,0,0,100,100,1,0,1,0.9,0,2,10,10,10,1
Style: ED_CN,FZLanTingYuan-L-GBK,35,&H00FFFFFF,&H000000FF,&H00FFFFFF,&H00000000,0,0,0,0,100,100,1,0,1,0.9,0,8,10,10,15,1
Style: ED_JP_EP04,FOT-UDMarugo_Large Pr6N M,54,&H00FDFCFA,&H000000FF,&H00555250,&H00717174,0,0,0,0,100,100,1,0,1,2,0,7,20,10,10,1
Style: ED_JP2_EP04,FOT-UDMarugo_Large Pr6N M,54,&H00FDFCFA,&H000000FF,&H00555250,&H00717174,0,0,0,0,100,100,1,0,1,2,0,9,10,20,10,1
Style: ED_CN_EP04,FZLanTingYuan-L-GBK,35,&H00FDFCFA,&H000000FF,&H00555250,&H00717174,0,0,0,0,100,100,1,0,1,2,0,7,20,10,65,1
Style: ED_CN2_EP04,FZLanTingYuan-L-GBK,35,&H00FDFCFA,&H000000FF,&H00555250,&H00717174,0,0,0,0,100,100,1,0,1,2,0,9,10,20,65,1
Style: IN_EP05_JP,FOT-UDKakugo_Large Pr6N B,54,&H00E8E8E8,&H000000FF,&H00FE1EFB,&H00FFFD6F,0,0,0,0,100,100,0,0,1,1,2,2,10,10,15,1
Style: IN_EP05_CN,FZLanTingHei-B-GBK,38,&H00E8E8E8,&H000000FF,&H00FE1EFB,&H00FFFD6F,0,0,0,0,100,100,0,0,1,1,2,8,10,10,25,1

You can try placing the fonts it needs in the fonts folder of the configuration directory。

refer to: https://mpv.io/manual/stable/#options-sub-fonts-dir

@xfangfang Thanks for replying but unfortunately placing fonts in the fonts folder doesn't change anything(there's nothing visible, even no squares were rendered), I think we might have different problem than just rendering the font, for example, there are chances when I tried to open subtitle selector again after selecting subtitle, it just shows none is selected.

@dic1911 You can try reading the ass subtitle file, comparing the differences between normal working and abnormal working files, and then try making changes yourself. I think if there are subtitles that work properly, then the problem still lies in the subtitle file itself.

@dic1911 there is a bug on https://github.com/dragonflylee/switchfin/blob/dev/app/src/view/video_view.cpp#L394
subtitle didn't add when transcoding。

item should replace with this->itemSource

@xfangfang Thanks for the suggestion, I don't know much about ass/ssa subtitle so I just exported it to srt format and it's still not working.

@dragonflylee ooh, thanks, let me try to patch that part and trigger playback with transcode, I think we still have other problem for subtitle selector though (as not even srt is working)

Just patched the source and compiled to test, it seems patching that line wasn't enough, usually it would take a few sec before it starts to play again when I switch between subtitles if transcode is needed for playback, but Switchfin behaves like I did nothing(as if no sub is specified) when I try to select subtitle in this case.

Update: I just checked with playback info OSD, the language ID displayed is always 0 when it's not working (yes, even with the mentioned line patched)

@dic1911 please try https://github.com/dragonflylee/switchfin/actions/runs/5796974539 and put font to sd card /switch/Switchfin/subfont.ttf

but subtitle didn't sysc to video

@dragonflylee The linked build stuck for the first two attempts when I tried to play the video with linked sub above(maybe too many fonts for the sub?), but after that it kinda works, just sub being out of sync as you mentioned.

Another thing is that I noticed that for somehow the audio track selector display is broken for this build

Switchfin_20230808_233644_00

I overlooked my Switch and it seems to be fine with latest commits, guess it's safe to close this issue now.