Page 1 of 2

[SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Aug 02, 2015 10:53 am
by momchil
SOLUTION >>>


Hi Serviio Team,

I have problem with subtitles from Serviio. My TOSHIBA 48L5445DG see SRT files but my TV see all SRT files with same name -> SUBTITLE.srt(see screenshot)
I have many movies with subtitles and my TV see all SRT files with same name -> SUBTITLE.srt

The names of the subtitles is same with names of the movie files in my hard drive.

The firmware of the TV is updated and TV is factory reset.
Serviio 1.5.2

In Profile "TOSHIBA REGZA 2012-" I put thеsе lines:
  Code:
<Transcoding>
         <Video targetContainer="mpegts" targetACodec="aac" forceInheritance="true">
            <Matches container="matroska" />
            <Matches container="mp4" />
            <Matches container="avi" />
            <Matches container="flv" />
         </Video>
      </Transcoding>
      <Subtitles>
         <SoftSubs mime-type="text/srt" />
      </Subtitles>


Burning subtitles is solution but I wish controlled subs directly from my TV(I wish big size and low CPU usage of the server).

P.S.: Sorry for my english.

Re: My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Aug 02, 2015 4:49 pm
by momchil
This is maybe Serviio bug.

In attached log I find there lines:

  Code:
2015-08-02 18:41:08,161 DEBUG [ServiioHttpService] Incoming request from /192.168.1.110:46626: GET /resource/4500/SUBTITLE.srt HTTP/1.1, headers = [Range: bytes=173535-,Host: 192.168.1.120:8895,Accept: */*]]
2015-08-02 18:41:08,161 DEBUG [RendererDAOImpl] Reading a Renderer with ip address 192.168.1.110
2015-08-02 18:41:08,162 DEBUG [RendererDAOImpl] Reading a Renderer with ip address 192.168.1.110
2015-08-02 18:41:08,163 DEBUG [ResourceDeliveryProcessor] Resource request accepted. Using client 'Identifier=192.168.1.110, Profile=Toshiba REGZA 2012-'
2015-08-02 18:41:08,163 DEBUG [ResourceDeliveryProcessor] Request for resource 4500 and type 'SUBTITLE' received
2015-08-02 18:41:08,163 DEBUG [VideoDAOImpl] Reading a Video (id = 4500)
2015-08-02 18:41:08,163 DEBUG [MediaItemDAOImpl] Getting file of media item 4500
2015-08-02 18:41:08,165 DEBUG [SubtitlesService] Found external subtitle file: T:\Download-TS\Gemma.Bovery.2014.1080p.BluRay.x264-CiNEFiLE.srt
2015-08-02 18:41:08,165 DEBUG [SubtitlesRetrievalStrategy] Retrieving info of Subtitles for media item with id 4500
2015-08-02 18:41:08,165 DEBUG [DLNAProtocolHandler] Unsupported range request, sending back 416


Please, investigate this bug. Thank you!

Re: My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Wed Aug 05, 2015 6:43 pm
by zip
That's how subtitles are sent to the TV. The TV should not show them for browsing really.

Re: My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Thu Aug 06, 2015 11:00 pm
by momchil
I changed something of the profil for TOSHIBA REGZA 2012-

Added lines:

For PAUSE/FWD/RWD problem:
  Code:
<ProtocolInfo>simple</ProtocolInfo>


For DTS/DTS-HD problem and MKV+AC3 problem:

  Code:
<Transcoding>
   <Video targetContainer="mpegts" targetACodec="aac">
      <Matches container="*" aCodec="dca" />
      <Matches container="*" aCodec="dts-hd" />
   </Video>
   <Video targetContainer="mpegts">
      <Matches container="*" aCodec="ac3" />
   </Video
</Transcoding>


For subtitle:

  Code:
<Subtitles>
   <SoftSubs mime-type="text/srt" />
</Subtitles>


But my TV still find same subtitles > SUBTITLE.srt and I can't watch my movies with subtitles. :( Hardsubs is not a solution because I have problems with 3D movies.
Any chance for subtitles with their real names?
If I can change something for the subtitles please, write me!

Re: My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Wed Aug 12, 2015 4:40 pm
by momchil
I changed source code and now I have different subtitle names.

org.serviio.upnp.protocol.http.transport.RequestedResourceDescriptor

From:
  Code:
private static final Pattern URL_EXTENSION_REMOVAL_PATTERN = Pattern.compile("(\\.srt|\\.m3u8)");

To:
  Code:
private static final Pattern URL_EXTENSION_REMOVAL_PATTERN = Pattern.compile("(-[0-9]{1,6}\\.srt|\\.m3u8)");



org.serviio.delivery.DefaultResourceURLGenerator

From:
  Code:
if (Resource.ResourceType.SUBTITLE == resourceType) {
   file.append(".srt");

To:
  Code:
if (Resource.ResourceType.SUBTITLE == resourceType) {
   file.append("-").append(resourceId.toString());
   file.append(".srt");


zip, I need help from you for real subtitle name.

Re: My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Thu Aug 13, 2015 2:09 am
by momchil
The problem is fixed. :)

org.serviio.upnp.protocol.http.transport.RequestedResourceDescriptor

From:

  Code:
    public RequestedResourceDescriptor(String requestUri) throws InvalidResourceRequestException {
        try {
            String[] requestFields = AbstractRequestHandler.getRequestPathFields(requestUri, "/resource", URL_EXTENSION_REMOVAL_PATTERN);


To:

  Code:
    public RequestedResourceDescriptor(String requestUri) throws InvalidResourceRequestException {
        try {
           if(requestUri.indexOf(".srt") > -1) { [color=#40FF00]//if you have ".srt" in the URL[/color]
              String[] tempUri = requestUri.split("/"); [color=#40FF00]//split with "/"[/color]
              requestUri = "/" + tempUri[1] + "/" + tempUri[2] + "/SUBTITLE.srt"; [color=#40FF00]//change URL to this path + /SUBTITLE.srt[/color]
           }
            String[] requestFields = AbstractRequestHandler.getRequestPathFields(requestUri, "/resource", URL_EXTENSION_REMOVAL_PATTERN);


And in org.serviio.delivery.DefaultResourceURLGenerator

From:

  Code:
public class DefaultResourceURLGenerator
implements ResourceURLGenerator {
    public static final String RESOURCE_SEPARATOR = "-";

    @Override
    public String getGeneratedURL(HostInfo hostInfo, Resource.ResourceType resourceType, Long resourceId, MediaFormatProfile version, Integer protocolInfoIndex, DeliveryQuality.QualityType quality) throws InvalidResourceException {
        this.validate(resourceType, resourceId, version, protocolInfoIndex, quality);
        StringBuffer file = new StringBuffer();
        file.append(resourceId.toString());
        file.append("/").append(resourceType.toString());
        if (resourceType == Resource.ResourceType.MEDIA_ITEM || resourceType == Resource.ResourceType.MANIFEST) {
            file.append("/").append(version.toString());
            file.append("-").append(protocolInfoIndex);
            file.append("/").append(quality.toString());
        }
        if (Resource.ResourceType.SUBTITLE == resourceType) {
            file.append(".srt");


To:

  Code:
import org.serviio.db.dao.DAOFactory; [color=#40FF00]//attached DAOFactory class[/color]
import java.util.regex.Pattern; [color=#40FF00]//attached Regex Pattern class[/color]

public class DefaultResourceURLGenerator
implements ResourceURLGenerator {
    public static final String RESOURCE_SEPARATOR = "-";

    @Override
    public String getGeneratedURL(HostInfo hostInfo, Resource.ResourceType resourceType, Long resourceId, MediaFormatProfile version, Integer protocolInfoIndex, DeliveryQuality.QualityType quality) throws InvalidResourceException {
        this.validate(resourceType, resourceId, version, protocolInfoIndex, quality);
        StringBuffer file = new StringBuffer();
        file.append(resourceId.toString());
        file.append("/"); [color=#40FF00]//resourceType is removed[/color]
        if (Resource.ResourceType.SUBTITLE != resourceType) { [color=#40FF00]//if not a subtitle[/color]
           file.append(resourceType.toString()); [color=#40FF00]//attached resourceType[/color]
        }
        if (resourceType == Resource.ResourceType.MEDIA_ITEM || resourceType == Resource.ResourceType.MANIFEST) {
           file.append("/").append(version.toString());
            file.append("-").append(protocolInfoIndex);
            file.append("/").append(quality.toString());
        }
        if (Resource.ResourceType.SUBTITLE == resourceType) {
           String subsName = DAOFactory.getMediaItemDAO().getFile(resourceId).getName(); [color=#40FF00]//get video file name[/color]
           subsName = Pattern.compile("(\\.[A-Za-z0-9]{3}$)").matcher((CharSequence)subsName).replaceAll(""); [color=#40FF00]//this remove video file extention[/color]
           subsName = Pattern.compile("( )").matcher((CharSequence)subsName).replaceAll(".");[color=#40FF00] //replace intervals(spaces) with dots[/color]
            file.append(subsName).append(".srt"); [color=#40FF00]//append .srt extention to subs file[/color]


Work great! :D

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Fri Sep 04, 2015 10:29 pm
by momchil
This is my solution of the problem with subtitles for Toshiba TV's.

Tested on 48L5445DG(model 2014).

You need replace spaces(intervals) in file names with dots or whatever. If you have spaces(intervals) in the name of the subtitles will be replaced with dots!

The archive is too large for the forum.
I uploaded it in Google Drive. Modded files for Serviio 1.5.2 : https://drive.google.com/file/d/0B6o39p ... sp=sharing

Sorry for my english!


@zip, if you can, please, add these changes in official release.

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Tue Apr 26, 2016 2:26 am
by momchil
New version for 1.6.1 - Modded files for Serviio 1.6.1.zip

Unzip in Serviio root directory and set the profil to "TOSHIBA REGZA 2012-". Restart the service of Serviio or reboot computer!


Before: Subtitle name is 1234_SUBTITLE.srt or 7590_SUBTITLE.srt or four numbers and _SUBTITLE.srt
After this mod: Subtitle name is Name.of.the.film.srt ;)


@zip, please insert this code in Serviio. This is only 10 lines summary.

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Mon Sep 12, 2016 11:32 pm
by momchil
My new modification for Serviio 1.7: Modded files for Serviio 1.7.zip

In org.serviio.upnp.protocol.http.transport.RequestedResourceDescriptor
  Code:
public RequestedResourceDescriptor(String requestUri) throws InvalidResourceRequestException {
        try {
/* add START */
           if(requestUri.indexOf(".srt") > -1) {
              String[] tempUri = requestUri.split("/");
              requestUri = "/" + tempUri[1] + "/" + tempUri[2] + "/SUBTITLE.srt";
           }
/* add END */


In org.serviio.delivery.DefaultResourceURLGenerator
  Code:
/* add START */
import org.serviio.db.dao.DAOFactory;
import java.util.regex.Pattern;
/* add END */

public class DefaultResourceURLGenerator
implements ResourceURLGenerator {
    public static final String RESOURCE_SEPARATOR = "-";

    @Override
    public String getGeneratedURL(HostInfo hostInfo, Resource.ResourceType resourceType, Long resourceId, MediaFormatProfile version, Integer protocolInfoIndex, DeliveryQuality.QualityType quality) throws InvalidResourceException {
        this.validate(resourceType, resourceId, version, protocolInfoIndex, quality);
        StringBuffer file = new StringBuffer();
        file.append(resourceId.toString());
        file.append("/");
/* remove one IF((Resource.ResourceType.SUBTITLE == resourceType)) and one line(file.append(resourceType.toString());) after! */      
        if (resourceType == Resource.ResourceType.MEDIA_ITEM || resourceType == Resource.ResourceType.MANIFEST) {
/* add START */
           file.append(resourceType.toString());
/* add END */
            file.append("/").append(version.toString());
            file.append("-").append(protocolInfoIndex);
            file.append("/").append(quality.toString());
        }
        if (Resource.ResourceType.SUBTITLE == resourceType) {
/* add START */
           String subsName = DAOFactory.getMediaItemDAO().getFile(resourceId).getName();
           subsName = Pattern.compile("(\\.[A-Za-z0-9]{3}$)").matcher((CharSequence)subsName).replaceAll("");
           subsName = Pattern.compile("( )").matcher((CharSequence)subsName).replaceAll(".");
            file.append(subsName);
/* add END */
            file.append(".srt");
        } else if (Resource.ResourceType.MANIFEST == resourceType || version != null && version.isManifestFormat()) {
/* add  START *
           file.append(resourceType.toString());
/* add END */
           file.append(".m3u8");
        }
        return this.generateUrl(hostInfo, this.generatePath(hostInfo, file.toString()));
    }


@zip, please insert this code in Serviio.

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Thu Sep 29, 2016 2:53 am
by QuiGon
Guys, has anyone encountered some problems with new version of Serviio. I made this work perfectly on last version but after updating it, it got broken. I saved profile entry and copied it to new profile file, but it's broken somehow. Even with entry i still have problem listing files as text.srt. I again see 5012_SUBTITLE; instead of s01e01.srt.

How can i fix it?

also there has been another problem. now while watching movies, my subs have wierd display at some characters..it should be ć č đ ž š; but it's showing some other symbols. Strange thing is both of my subtitles have è for č, as it should be so program would display it correcty. but on one sub it shows like it should, on other not. Anyone knows what triggers this?

Re: My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Tue Oct 18, 2016 11:07 pm
by QuiGon
zip wrote:That's how subtitles are sent to the TV. The TV should not show them for browsing really.


I have to disagree. TV shows them anyway, but wrongly..They're not automatically loaded, even if on computer they're called the same as video file, so that makes this reason useless. And above all if i have 10+ video files with subtitles not loaded automatically and not named properly, i have to throw a bean before i figure what subtitle to load.

Changing this option like in momchil's mod, not only it displays them correctly, it even loads them automaticlly. Why discard this then, when it's only positive stuff it brings.

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Thu Oct 20, 2016 5:25 pm
by QuiGon
hey momchil, if use moded files from 1.7 on 1.7.1 will they work with all updates from 1.7.1? or if i use this file i will also loose updates and use version 1.7 intruth?

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Thu Oct 20, 2016 5:27 pm
by momchil
May be no. Only with 1.7.
What is your TV?

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Mon Oct 24, 2016 12:26 am
by QuiGon
TELEFUNKEN. tell you all other mods were great from you. will you do mod for 1.7.1?

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Mon Oct 24, 2016 5:45 pm
by momchil
My new modification for Serviio 1.7.1.1: Modded files for Serviio 1.7.1.1.zip

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Dec 11, 2016 11:06 pm
by Melih
momchil wrote:My new modification for Serviio 1.7.1.1: Modded files for Serviio 1.7.1.1.zip


Hello Momchil, are you planning to make modifications for the new version? That subtitle file name issue is annoying. I treid to edit them myself but i couldn't unfortunately :(

It would be awsome if you make it for 1.8

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Dec 11, 2016 11:09 pm
by momchil
Melih wrote:I treid to edit them myself but i couldn't unfortunately :(

It would be awsome if you make it for 1.8


Maybe the code is changed. I don't know. I will check this the next week.

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Dec 11, 2016 11:16 pm
by Melih
I coundn't because i don't know how to edit it.
Cheers, i will be waiting for the good news ;)

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Dec 11, 2016 11:17 pm
by momchil
After Friday you can remind me here. ;)

Re: [SOLVED] My TOSHIBA 48L5445DG and bad subtitle names

PostPosted: Sun Dec 18, 2016 12:19 am
by momchil
My new modification for Serviio 1.8: Modded files for Serviio 1.8.zip