Jump to content
Serios

ANSWERED DLNA support of external subtitles

Recommended Posts

Serios

Is it possible to add support for external subtitles trough DLNA to MB?

Currently MB transcodes every item that has external subtitles to burn them in, which is K.I.I.S. solution. The DLNA standard actually support additional subtitle (.srt) files, for example Serviio serves external subtitles to the client as item within the ContentDirectory:
"urn:schemas-upnp-org:service:ContentDirectory:1":

...
  <res protocolInfo="http-get:*:text/srt:*">http://192.168.1.5:8895/resource/6/SUBTITLE.srt</res>
</item>

The URI to the .srt file is given in the media directory and can be read through HTTP, so DLNA media render can access it.
 
I get that, transcoding is the "last hope" when nothing else work but in this case, something else work, and why to force transcoding when natively can get without.

Edited by Serios

Share this post


Link to post
Share on other sites
Luke

we already do this, based on the subtitle profiles of the dlna device profile

Share this post


Link to post
Share on other sites
Serios

we already do this, based on the subtitle profiles of the dlna device profile

 

Well not according to the log file

<item restricted="1" id="06d0ff366497d215115fee09e79bb7ad" parentID="18f9496d52aa086f5bb7fdb903b5ab2f">
<dc:title>The Hitchhiker's Guide to the Galaxy</dc:title>
<upnp:class>object.item.videoItem.movie</upnp:class>
........
<upnp:director>Garth Jennings</upnp:director>
<upnp:actor>Martin Freeman</upnp:actor>
<upnp:actor>Zooey Deschanel</upnp:actor>
<upnp:actor>Sam Rockwell</upnp:actor>
<upnp:actor>Mos Def</upnp:actor>
<res duration="01:48:46.5300000" size="2773702656" nrAudioChannels="6" resolution="1280x536" sampleFrequency="48000" bitrate="3388836" protocolInfo="http-get:*:video/x-msvideo:DLNA.ORG_PN=AVI;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01D00000000000000000000000000000">http://192.168.1.50:8096/mediabrowser/videos/06d0ff366497d215115fee09e79bb7ad/stream.avi?Params=a090a433ae628a3636d4372d1d113d76;test;06d0ff366497d215115fee09e79bb7ad;true;;;;;;;;;;;0;;;;;</res>
<upnp:albumArtURI dlna:profileID="JPEG_SM">http://192.168.1.50:8096/mediabrowser/Items/06d0ff366497d215115fee09e79bb7ad/Images/Primary/0/2d7e60917a6736ef0a858ca9f51ddded/jpg/480/480/0</upnp:albumArtURI>
<upnp:icon>http://192.168.1.50:8096/mediabrowser/Items/06d0ff366497d215115fee09e79bb7ad/Images/Primary/0/2d7e60917a6736ef0a858ca9f51ddded/jpg/48/48/0</upnp:icon>
</item>

Although I have .srt file named exactly as the movie and in my device dlna profile srt files have set the following settings:

Format: srt

Method: External download

Didl mode: res element

 

If you want I can attach both  log file and dlna profile

Edited by Serios

Share this post


Link to post
Share on other sites
Luke

i've tested this without any problem. maybe the server never recognized the subtitles to begin with. or maybe it's the wrong dlna profile. you'll have to investigate.

Share this post


Link to post
Share on other sites
Serios

Well I can see them, when open movie in web library:

 

Subtitle
Codec SRT
Default No
Forced No
External Yes

 

Strange thing is in the log I don't get any of srt files from other movies too it's like completely ignoring all subtitles files, but when preview movie in web dashboard it shows that there is sub file.

 

Heres my dlna profile

LG WebOS.xml

Edited by Serios

Share this post


Link to post
Share on other sites
Serios

Ok I'm in "the ignore this guy" list, but please someone... I even capture the response from MB trough Wireshark and there is no trace of subtitle node in item node. I don't get it, it should work... I don't get any errors in the log about DLNA profile, MB recognize it so what's wrong with damn subtitles I'm sure defined subtitles profiles are ok, even reinstalled MB completely and the installed it again - result is the same. Do I need to clear cache or something?

Share this post


Link to post
Share on other sites
Luke

the most likely answer has been given to you. you configured the subtitle profiles but make sure the dlna device profile is actually being used. you can check that in the server log.

Share this post


Link to post
Share on other sites
Serios

Yes, it is:
Dlna: Found matching device profile: LG WebOS

 

that's why I'm wondering whats wrong

Share this post


Link to post
Share on other sites
Beardyname

Have you setup subtitles to be used for your user? aka if you try to play the same item in the web-client will the subtitles appear or do you have to select them?

 

I could be totally wrong but as far as i know this has not been talked about yet :)

Edited by Beardyname

Share this post


Link to post
Share on other sites
Serios

As the matter of fact they do appear in the web client (even if they are gibberish because the encoding)  if I made naming convention with the language code they start automatically if not (just movie file name)  I can select them from captions menu and they appear. I browsed the MB source code on github for the last couple of days and indeed as Luke said it must include subtitles file in the stream to dlna device i see that portion, but why is not firing? Also can someone too confirm this, when subtitles format is .sub there is a problem with transcoding - it fails creating temp file so error is returned.

Edited by Serios

Share this post


Link to post
Share on other sites
Luke

double check your user profile subtitle preferences

Share this post


Link to post
Share on other sites
Serios

My user profile language preferences:

 

546ac70a1b8eb_Untitled1.jpg

  • Like 1

Share this post


Link to post
Share on other sites
Beardyname

Will it behave the same if you change Subtitle Mode to Always or similiar? (can't remember exactly) but with theese settings it will only play subtitles if the "main" language differs from Bulgarian.

Share this post


Link to post
Share on other sites
Serios

Yes I tried that, but no change

Share this post


Link to post
Share on other sites
Luke

try the dev server and see if it makes a difference

Share this post


Link to post
Share on other sites
anks

Have you tried using XBMC as the DMR and see if the subtitles appear using this profile?

Edited by anks

Share this post


Link to post
Share on other sites
Serios

try the dev server and see if it makes a difference

 

Not at all, still no subtitles.

 

 

Have you tried using XBMC as the DMR and see if the subtitles appear using this profile?

 

Yes I tried, the result is the same, also tried to load movie from serviio and it played without a problem with subtitles  :(

 

 

Pardon me if the next sounds very stupid but I see the logic behind subtitles listing like this:

When started MB check each movie folder for list of files and grab them - >

On dlna client request it loads dlna profile and If subtitle file is discovered it's check against to see if device supports this type of file -> 

If Yes: it is added to the proper movie item as res, then nodes list is send to the client

if Not: the movie item is marked for transcoding and again nodes list is send to the client

 

Not very good explanation but still, for me there are 3 breaking points, one is file grabbing process, the second one is check for the type, third one is the inclusion point

Share this post


Link to post
Share on other sites
Serios

Sorry to bring back this again, but problem still persists I tried everything but it seems MB completely ignores the subtitle file when streaming over dlna. I'm desperate, can someone help me with this

Share this post


Link to post
Share on other sites
Serios

I noticed something else, although don't know if is related, but anyway - when playing movie in web client subtitles are shown, if I go to metadata manager for the item and go to to subtitles tab i see them listed, when click on them it should bring some kind of editor in html dialog, but nothing is returned. When trace, I see that the query returns 404 error:

NetworkError: 404 Not Found - http://localhost:8096/mediabrowser/Videos/30971a5fb4956ee52c56e489b72b335c/Subtitles/2

 
Don't know is this related in anyway to didl builder or is just a web interface bug, but I think it should be mentioned.

Edited by Serios

Share this post


Link to post
Share on other sites
Serios

Oook after some fiddling around with the source code, I managed to trace the problem up to the AddSubtitle method in MediaBrowser.Model\Dlna\StreamInfo.cs, we have the following:

 

 

        private void AddSubtitle(List<SubtitleStreamInfo> list, MediaStream stream, string baseUrl, long startPositionTicks)
        {
            string url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
                baseUrl,
                ItemId,
                MediaSourceId,
                StringHelper.ToStringCultureInvariant(stream.Index),
                StringHelper.ToStringCultureInvariant(startPositionTicks),
                SubtitleFormat);

            list.Add(new SubtitleStreamInfo
            {
                Url = url,
                IsForced = stream.IsForced,
                Language = stream.Language,
                Name = stream.Language ?? "Unknown",
                Format = SubtitleFormat
            });
        }

and for some reason SubtitleFormat is always returned as blank, thus why logic in method AddSubtitleElement in \MediaBrowser.Dlna\Didl\DidlBuilder.cs always returning subtitleProfile as null. Which bring us to the point that subtitles stream is actually never added to the xml.

If someone from dev team can take a look at this, will be nice :)

  • Like 1

Share this post


Link to post
Share on other sites
Serios

Ok If i replace SubtitleFormat with stream.Codec which subtitle resolver is returning as part of subtitle stream it's working, but since I'm not a c# developer, not sure if that is the proper way to be done. Please dev guys, any comment on this will really be good.

Share this post


Link to post
Share on other sites
Luke

before even worrying about the profile, you should verify the subs are being burned in via transcoding. that's step 1. then after that you can optimize the profile to deliver them in a more efficient way.

 

skimming through page 1 it appears you've already done that, although if not, then you need to go back and start from there.

 

once you've verified basic support via burning them in, then you can use the profile editor to add a subtitle profile to indicate the format(s) the player can support.

Share this post


Link to post
Share on other sites
Serios

Well, in my previous posts I said that's all done. Subtitles are working via transcoding and in web player, also I setup my dlna profile and it's working. The point that subtitles are not properly loaded or subtitle file is not found etc etc is not in the matter here, since when I tweaked the code as I mention in my previous post "...replace SubtitleFormat with stream.Codec...", managed to get them working quite well. I also should mention, that to trace the problem up to the AddSubtitle method I tweaked the DidlBuilder.css to return in the log the AddSubtitleElement method parameters, just to check exactly that thing, you had in mind. Yes, I also doubted, that subtitle file is loaded at all, but after checking the log, any doubt was cleared, the subtitle file is loaded, so for every subtitle stream I got in the log:
 
This is before SubtitleFormat change...

Debug - UpnpContentDirectory: Test stream Url: http://192.168.1.50:8096/mediabrowser/Videos/9c0469a0120372b22bb6e890b5a9fad3/9c0469a0120372b22bb6e890b5a9fad3/Subtitles/2/0/Stream.
Debug - UpnpContentDirectory: Test stream IsForced: False
Debug - UpnpContentDirectory: Test stream Language: bul
Debug - UpnpContentDirectory: Test stream Name: bul
Debug - UpnpContentDirectory: Test stream Format: 
...

 
This is after replacing SubtitleFormat with stream.Codec

Debug - UpnpContentDirectory: Test stream Url: http://192.168.1.50:8096/mediabrowser/Videos/9c0469a0120372b22bb6e890b5a9fad3/9c0469a0120372b22bb6e890b5a9fad3/Subtitles/2/0/Stream.srt
Debug - UpnpContentDirectory: Test stream IsForced: False
Debug - UpnpContentDirectory: Test stream Language: bul
Debug - UpnpContentDirectory: Test stream Name: bul
Debug - UpnpContentDirectory: Test stream Format: srt
...

I also created subtitles files with ass, ssa, sub extensions just to test is this working properly and it is. With sub file although, it triggering transcoding...

 

So again, I don't think the problem is in the dlna profile for the device or that MB doesn't get the subtitle file, the problem is that SubtitleFormat is never returned so in DidlBuilder this:

 

var subtitleProfile = _profile.SubtitleProfiles
                .FirstOrDefault(i => string.Equals(info.Format, i.Format, StringComparison.OrdinalIgnoreCase) && i.Method == SubtitleDeliveryMethod.External);

is always null, which brings us here:

            if (subtitleProfile == null)
            {
                return;
            }

And no subtitle stream is added to the xml :)

  • Like 1

Share this post


Link to post
Share on other sites
Luke

great work. you don't actually want to use codec in place of SubtitleFormat, because Codec is the input, the subtitle format is the output. so we need to figure out why SubtitleFormat is empty

Share this post


Link to post
Share on other sites
Luke

ok, i've checked in some changes that should cause SubtitleFormat to get populated. great investigative work on your part!

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...