Page 1 of 1

Problem with subtitles

PostPosted: Mon Sep 28, 2020 7:44 pm
by raynbow
Hello!
I try to watch anime with subtitles on my LG Smart TV, but the subtitles shows up in this way https://imgur.com/B656DAc . I think the problem is that the TV does not recognize the font style. Is it possible to fix this issue?

Re: Problem with subtitles

PostPosted: Mon Sep 28, 2020 8:29 pm
by atc98092
Just a guess on my part, but I don't think Serviio has any control over subtitle format. I see a setting for burned-in subs to set a font face, but nothing else. If the subs are embedded in the media file, the font is being specified within it.

Re: Problem with subtitles

PostPosted: Tue May 09, 2023 12:01 am
by Kagami
The problem is caused by FFmpeg’s srt encoder: it tries to preserve styles of the ASS subtitle format and in particular uses <font> tag to specify same font that was used in ASS styles.

Media player in LG Smart TV, at least the one I have, doesn’t support those font tags in SRT subtitles, so it renders them just as a plain text.

I enabled debug logging for Serviio and here is the command it uses to convert ASS to SRT:
  Code:
DEBUG [ProcessExecutor] Starting ffmpeg -sub_charenc ISO-8859-1 -i /media/serviio/subtitle.ass -an -vn -c:s srt -f srt pipe:

To reproduce, try the following: save this to 1.ass
  Code:
[Script Info]

[V4+ Styles]
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,Liberation Sans,50,&H00FFFFFF,&H000000FF,&H56000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,0,2,10,10,20,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:11.78,0:00:13.26,Default,,0,0,0,,Test

Run this:
  Code:
ffmpeg -i 1.ass -c:s srt 1.srt

The result is:
  Code:
1
00:00:11,780 --> 00:00:13,260
<font face="Liberation Sans" size="50"><b>Test</b></font>

Now, the solution is simple. Just use text encoder to produce tag-less SRT file:
  Code:
ffmpeg -i 1.ass -c:s text 2.srt

The result is:
  Code:
1
00:00:11,780 --> 00:00:13,260
Test

So, @zip, could you please add an option to Serviio, to pass -c:s text to FFmpeg instead of -c:s srt?

Re: Problem with subtitles

PostPosted: Tue May 09, 2023 10:33 am
by Kagami
I found another way. My LG Smart TV actually supports external ASS subtitles.

So you can just change in Generic DLNA profile:
  Code:
-                       <SoftSubs mime-type="text/srt" type="srt" character-encoding="utf-8" />
+                       <SoftSubs mime-type="text/ass" type="ass" character-encoding="utf-8" />

That way Serviio will convert all subtitle formats to ASS and it works fine because all features of SRT are supported in ASS.
But this requires update to the Profiles.xsd schema.

Not sure what's the best way to handle this, needs additional testing. There are 3 options:
  • Convert ASS to SRT with text encoder, serve SRT as is
  • Convert SRT to ASS, serve ASS as is
  • Serve both SRT and ASS as is