Subtitles for Samsung devices

Discuss issues related to PS3 Media Server development (only for programmers)

Subtitles for Samsung devices

Postby SamiMakinen » Tue Dec 06, 2011 7:10 pm

Hi!

I responded to the feature request discussion in here: viewtopic.php?f=15&t=3811&p=60478 with the code below. It adds a custom header to the video-file request which tells Samsung devices to go get the subtitles from the URL specified in the header. And it also adds handling for a subtitle requests with the same way thumbnails are being handled (with the addition of file-extension in the filename since the devices seems to need it for recognizing the format). Sorry for this not being a diff but the code is added to RequestV2.java between the thumbnail and video-file handling. I've marked the additions with <addition> comments:

This code and discussion is found in viewtopic.php?f=15&t=3811&p=60478:
Code: Select all
               inputStream = dlna.getThumbnailInputStream();
                    // <addition>
                } else if (fileName.indexOf("subtitle0000") > -1) {

                    output.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
                    output.setHeader(HttpHeaders.Names.EXPIRES,  getFUTUREDATE() + " GMT");
                    List<DLNAMediaSubtitle> subs = dlna.getMedia().getSubtitlesCodes();
                    if(subs != null && !subs.isEmpty()) {
                        // TODO: maybe loop subs to get the requested subtitle type instead of using the first one
                        DLNAMediaSubtitle sub = subs.get(0);
                        inputStream = new java.io.FileInputStream(sub.getFile());
                    }
                    // </addition>
            } else {
               // This is a request for a regular file.

               // If range has not been initialized yet and the DLNAResource has its
               // own start and end defined, initialize range with those values before
               // requesting the input stream.
               Range.Time splitRange = dlna.getSplitRange();

               if (range.getStart() == null && splitRange.getStart() != null) {
                  range.setStart(splitRange.getStart());
               }

               if (range.getEnd() == null && splitRange.getEnd() != null) {
                  range.setEnd(splitRange.getEnd());
               }

               inputStream = dlna.getInputStream(Range.create(lowRange, highRange, range.getStart(), range.getEnd()), mediaRenderer);
                    // <addition>
                    List<DLNAMediaSubtitle> subs = dlna.getMedia().getSubtitlesCodes();
                    if(subs != null && !subs.isEmpty()) {
                        DLNAMediaSubtitle sub = subs.get(0);

                        int type = sub.getType();
                        if(type < DLNAMediaSubtitle.subExtensions.length) {
                            String strType = DLNAMediaSubtitle.subExtensions[type -1];
                            output.setHeader("CaptionInfo.sec", "http://"+PMS.get().getServer().getHost()+':'+PMS.get().getServer().getPort()+"/get/"+id+"/subtitle0000." + strType);
                        }
                    }
                    // </addition>


Could this be added to the codebase?
SamiMakinen
 
Posts: 10
Joined: Thu Oct 27, 2011 6:40 pm

Re: Subtitles for Samsung devices

Postby SubJunk » Tue Dec 06, 2011 9:01 pm

Hi, thanks a lot for the code :)
Do you anticipate any problems with other renderers?
SubJunk
 
Posts: 1212
Joined: Fri Mar 27, 2009 5:25 am

Re: Subtitles for Samsung devices

Postby SamiMakinen » Wed Dec 07, 2011 12:44 am

Other renderers shouldn't be affected, I've tested it with ps3 besides my samsung tv. It only adds the http header which clients should disregard if they don't know what to do with it. If they do, they will call the subtitle url specified in the header.

But this being Samsung specific, atleast the header name (CaptionInfo.sec) should propably come from a renderer conf.
SamiMakinen
 
Posts: 10
Joined: Thu Oct 27, 2011 6:40 pm

Re: Subtitles for Samsung devices

Postby ybby » Fri Dec 09, 2011 7:23 am

Hi,
just wanted to say thank you for this solution.
I just tried it out with my new Samsung TV and it works for me very well.

P.S. In addition to the snipppet provided I had to add an extra line in the imports section:
import net.pms.dlna.DLNAMediaSubtitle;
ybby
 
Posts: 1
Joined: Fri Dec 09, 2011 7:13 am

Re: Subtitles for Samsung devices

Postby StreamHD » Sat Dec 31, 2011 11:51 am

Thanks, this works well with an LA32D550 and I haven't noticed any interference with Xbox or PS3.
PMS 1.50.1-Snapshot (latest commit); 400MB buffer;
Samsung LCD D550 Series with custom conf; Sony PS3; Xbox 360;
Win7 x64; JDK-7u2-x64; Intel i7 930 + X58 chipset; 3 x 2GB DDR3 1333Mhz; Gigabit backbone;
StreamHD
 
Posts: 63
Joined: Tue Dec 20, 2011 3:26 am

Re: Subtitles for Samsung devices

Postby Raptor399 » Sat Dec 31, 2011 2:28 pm

Addition committed, albeit slightly altered.
Thanks, SamiMakinen!
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Subtitles for Samsung devices

Postby StreamHD » Sun Jan 01, 2012 12:01 pm

Great news Raptor399! This is going to make a lot of Sammy owners who can't FF/FR during transcoding very happy!

I've been looking at this from DLNAResource.java:
Code: Select all
// Force transcoding if
                  // 1- MediaInfo support detected the file was not matched with supported codec configs and no SkipTranscode extension forced by user
                  // or 2- ForceTranscode extension forced by user
                  // or 3- FFmpeg support and the file is not ps3 compatible (need to remove this ?) and no SkipTranscode extension forced by user
                  // or 4- There's some sub files or embedded subs to deal with and no SkipTranscode extension forced by user (TODO: need to include arguments for custom subtitle headers?)
                  if (forceTranscode || !isSkipTranscode() && (forceTranscodeV2 || (!parserV2 && !child.getExt().ps3compatible()) || (PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs)) {
                     child.setPlayer(pl);
                     LOGGER.trace("Switching " + child.getName() + " to player: " + pl.toString());
                  }


As a result, to stream both video and subs requires the use of SkipTranscode. i.e. using "MediaInfo=" in a conf becomes obsolete when using custom subtitle headers. Perhaps we need to include checks for the custom headers?

Somewhat off-topic but relavant to the discussion.

Edit: Made seperate topic for another related DLNAResource.java problem
PMS 1.50.1-Snapshot (latest commit); 400MB buffer;
Samsung LCD D550 Series with custom conf; Sony PS3; Xbox 360;
Win7 x64; JDK-7u2-x64; Intel i7 930 + X58 chipset; 3 x 2GB DDR3 1333Mhz; Gigabit backbone;
StreamHD
 
Posts: 63
Joined: Tue Dec 20, 2011 3:26 am

Re: Subtitles for Samsung devices

Postby klam » Sun Jan 08, 2012 1:07 pm

first post. no developer. I apologize upfront.
I've installed ps3ms onto my lptp (win7). I'd like to make those subtitles to work, but I just cannot find the requestV2.java file anywhere.
-Is it somewhere in the jar file?
-Do I need to get the source code?

TV I have is UA46D6000. It finds the server, plays some formats, but anything that has subtitles fails to load with "Invalid file format" or something similar. MKV will not play at all, only if I go to #transcode# and use the tsmuxer one. Also, the movie starts, but it starts at the position around 3-4 minutes .. hm.

Thanks for all your help and patience with me.
Regards,
M
klam
 
Posts: 1
Joined: Sun Jan 08, 2012 12:59 pm

Re: Subtitles for Samsung devices

Postby Raptor399 » Sun Jan 08, 2012 2:08 pm

klam wrote:first post. no developer. I apologize upfront.
I've installed ps3ms onto my lptp (win7). I'd like to make those subtitles to work, but I just cannot find the requestV2.java file anywhere.
-Is it somewhere in the jar file?
-Do I need to get the source code?

The file RequestV2.java is part of the source code.

So yes, if you want to change it, you will have to download the PMS source code and build it yourself.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Subtitles for Samsung devices

Postby jhalttu78 » Sat Jan 14, 2012 12:38 pm

Coud someone please give us NOOBs builded version... ? I want Thumbnails and Subtitles to my Sammy =)
I currently have 1.50. Subjunk B58
jhalttu78
 
Posts: 10
Joined: Thu Jan 12, 2012 8:24 pm


Return to Developers

Who is online

Users browsing this forum: No registered users and 2 guests