Additional SUBs info in TRANSCODE folder+forced SUBs support

General discussion about PS3 Media Server (no support or requests)

Re: r365 bugs and request-working patch for forced subs support

Postby ExSport » Sat Nov 14, 2009 9:13 pm

Which version you have installed?
This one? viewtopic.php?f=2&t=3217
Quite strange that you don't see this folder also in official r366 posted above. ;)
ExSport
 
Posts: 2168
Joined: Mon Jan 19, 2009 5:40 pm

Re: r365 bugs and request-working patch for forced subs support

Postby Stonga » Sat Nov 14, 2009 9:21 pm

ExSport wrote:Which version you have installed?
This one? viewtopic.php?f=2&t=3217
Quite strange that you don't see this folder also in official r366 posted above. ;)


Yup. That's the one.

I find it very strange as well. When I open the transcode folder on my xbox, the first thing is see is a folder(s) named exactly the same as the file(s) I'm trying to play. When I go inside that folder(s) again I get several transcode options. Like avisynth (never worked for me) and a couple of mencoder options. Tsmuxer is not even showing so I've never used it. Always been using mencoder.

Anyways, that's all I can see.
Stonga
 
Posts: 22
Joined: Sun Oct 25, 2009 5:10 pm

Re: r365 bugs and request-working patch for forced subs support

Postby ExSport » Mon Dec 21, 2009 2:13 am

New ffmpeg version from Sherpya [12/20/2009] - [ LINK ] supports Metadata/Description defined for subtitle streams so new format is:
Duration: 01:56:40.64, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: h264, yuv420p, 1920x800, PAR 1:1 DAR 12:5, 47.62 fps, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 6 channels, s16
Metadata:
description : EN AC3 5.1 640 Kbps
Stream #0.2(eng): Subtitle: 0x0000
Metadata:
description : EN Forced
Stream #0.3(eng): Subtitle: 0x0000
Metadata:
description : EN
Stream #0.4(cze): Audio: ac3, 48000 Hz, 6 channels, s16
Metadata:
description : CZ AC3 5.1 640 Kbps
Stream #0.5(cze): Subtitle: 0x0000
Metadata:
description : CZ Forced
Stream #0.6(cze): Subtitle: 0x0000
Metadata:
description : CZ
At least one output file must be specified

I made a dirty patch which will add this info to TRANSCODE folder at the end of subtitles description.
Also I modified loading of forced subtitles so now if description includes "forced" text ==> subtitles are always loaded for preferred language (when [mencoder] used).
How to make it work?
Replace old ffmpeg with new version and add pre-compiled update.jar[http://www.mediafire.com/?dk2nmn2mmnm] next to PMS.exe and restart it or compile whole PMS including this patch by own ;)
Code: Select all
Index: net/pms/dlna/DLNAMediaInfo.java
===================================================================
--- net/pms/dlna/DLNAMediaInfo.java   (revision 369)
+++ net/pms/dlna/DLNAMediaInfo.java   (working copy)
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.ListIterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.StringTokenizer;
@@ -356,7 +357,9 @@
                ArrayList<String> lines = (ArrayList<String>) pw.getResults();
                int langId = 0;
                int subId = 0;
+               ListIterator<String> FFmpegMetaData = lines.listIterator();
                for(String line:lines) {
+                  FFmpegMetaData.next();
                   line = line.trim();
                   if (line.startsWith("Output"))
                      matchs = false;
@@ -486,7 +489,18 @@
                         } else
                            lang.lang = DLNAMediaLang.UND;
                         lang.id = subId++;
-                        subtitlesCodes.add(lang);
+//                        subtitlesCodes.add(lang);
+                        int FFmpegMetaDataNr = FFmpegMetaData.nextIndex();
+                        if (FFmpegMetaDataNr > -1) line = lines.get(FFmpegMetaDataNr);
+                        if (line.indexOf("Metadata:") > -1) {
+                           line = lines.get(FFmpegMetaData.nextIndex()+1);
+                           int aa = line.indexOf(": ");
+                           int bb = line.length();
+                           if (aa > -1 && bb > aa) {
+                              lang.flavor = line.substring(aa+2, bb);
+                           }   
+                        }
+                         subtitlesCodes.add(lang);
                      }
                   }
                }
Index: net/pms/encoders/Player.java
===================================================================
--- net/pms/encoders/Player.java   (revision 369)
+++ net/pms/encoders/Player.java   (working copy)
@@ -155,7 +155,7 @@
       if (matchedSub != null && params.sid == null) {
          if (matchedSub.lang != null && matchedSub.lang.equals("off")) {
             PMS.debug(" Disabled the subtitles: " + matchedSub);
-            return;
+            //return;
          } else
             params.sid = matchedSub;
       }
@@ -170,14 +170,30 @@
          if (configuration.getUseSubtitles()) {
             // priority to external subtitles
             for(DLNAMediaSubtitle sub:media.subtitlesCodes) {
-               PMS.debug("Found subtitles track : " + sub);
-               if (sub.file != null) {
-                  PMS.debug("Found external file : " + sub.file.getAbsolutePath());
-                  params.sid = sub;
-                  break;
+               if (matchedSub.lang !=null && matchedSub.lang.equals("off")) {
+                  if (sub.flavor != null && sub.flavor.toLowerCase().indexOf("forced") > -1) {
+                     if (Iso639.isCodesMatching(sub.lang,configuration.getMencoderSubLanguages())) {
+                        PMS.debug("Forcing prefered subtitles : " + sub.getLang() + "/" + sub.flavor);
+                        PMS.debug("Forced subtitles track : " + sub);
+                        if (sub.file != null) {
+                           PMS.debug("Found external forced file : " + sub.file.getAbsolutePath());
+                        }
+                     params.sid = sub;
+                     break;
+                     }
+                  }
+                  continue;
+               } else {
+                  PMS.debug("Found subtitles track : " + sub);
+                  if (sub.file != null) {
+                     PMS.debug("Found external file : " + sub.file.getAbsolutePath());
+                     params.sid = sub;
+                     break;
+                  }
                }
             }
          }
+         if (matchedSub.lang !=null && matchedSub.lang.equals("off")) return;
          
          //
          if (params.sid == null) {

If you will test it, please post feedback here. Thanks ;)
ExSport
 
Posts: 2168
Joined: Mon Jan 19, 2009 5:40 pm

Re: r365 bugs and request-working patch for forced subs support

Postby ExSport » Thu Dec 24, 2009 2:38 pm

OK - one problem [fixed] :mrgreen:
It is not working when library is enabled.
It seems that favor parameter is not saved to library and when new info for file is retrieved by FFMPEG, it is not saved there so not read from there = not displayed on renderer :?
Shagrath, please can you help me with this?
I will try to learn something new when digging the code how to fix it because I suppose Shagrath will not read it in few days and will not help immediately so I am on turn now... 8-)
Forgot to say: Merry Christmas!!!
ExSport
 
Posts: 2168
Joined: Mon Jan 19, 2009 5:40 pm

Re: r365 bugs and request-working patch for forced subs support

Postby ExSport » Fri Dec 25, 2009 10:45 am

So I fixed problem with media library, now it works also with library enabled :mrgreen:
But now I am trying to force transcoding also for [tsMuxeR] videos outside #TRANSCODE# folder when prefered forced subtitles detected.
Now MKV files are streamed only but AVI etc. are transcoded when external forced subtitles found so I am trying same behavior also for embedded subtitles-quite hard for me... 8-)
I will update code then...when I will find working code...
ExSport
 
Posts: 2168
Joined: Mon Jan 19, 2009 5:40 pm

Re: r365 bugs and request-working patch for forced subs support

Postby ExSport » Sat Dec 26, 2009 2:42 am

I stopped fighting now with coding. I didn't found working code :(
So now code update but without automatic load of forced subtitles for MKV files and its embedded forced subs :(
This code change will display more info about subtitle tracks as an example shows:
[MEncoder] {Audio: DTS/English} {Sub: Embedded/English (forced)}
[MEncoder] {Audio: DTS/English} {Sub: Embedded/English (Singing parts only)}
[MEncoder] {Audio: DTS/English} {Sub: Embedded/English (Non-English speaking parts)}

Code: Select all
Index: net/pms/dlna/DLNAMediaDatabase.java
===================================================================
--- net/pms/dlna/DLNAMediaDatabase.java   (revision 369)
+++ net/pms/dlna/DLNAMediaDatabase.java   (working copy)
@@ -178,6 +178,7 @@
             sb.append("  FILEID            INT              NOT NULL"); //$NON-NLS-1$
             sb.append(", ID                INT              NOT NULL"); //$NON-NLS-1$
             sb.append(", LANG              VARCHAR2(3)"); //$NON-NLS-1$
+            sb.append(", FLAVOR            VARCHAR2(64)"); //$NON-NLS-1$
             sb.append(", TYPE              INT"); //$NON-NLS-1$
             sb.append(", constraint PKSUB primary key (FILEID, ID))"); //$NON-NLS-1$
             
@@ -309,6 +310,7 @@
                DLNAMediaSubtitle sub = new DLNAMediaSubtitle();
                sub.id = subrs.getInt("ID"); //$NON-NLS-1$
                sub.lang = subrs.getString("LANG"); //$NON-NLS-1$
+               sub.flavor = subrs.getString("FLAVOR"); //$NON-NLS-1$
                sub.type = subrs.getInt("TYPE"); //$NON-NLS-1$
                media.subtitlesCodes.add(sub);
             }
@@ -407,14 +409,15 @@
             }
             
             if (media.subtitlesCodes.size() > 0)
-               insert = conn.prepareStatement("INSERT INTO SUBTRACKS VALUES (?, ?, ?, ?)"); //$NON-NLS-1$
+               insert = conn.prepareStatement("INSERT INTO SUBTRACKS VALUES (?, ?, ?, ?, ?)"); //$NON-NLS-1$
             for(DLNAMediaSubtitle sub:media.subtitlesCodes) {
                if (sub.file == null) { // no save of external subtitles
                   insert.clearParameters();
                   insert.setInt(1, id);
                   insert.setInt(2, sub.id);
                   insert.setString(3, sub.lang);
-                  insert.setInt(4, sub.type);
+                  insert.setString(4, sub.flavor);
+                  insert.setInt(5, sub.type);
                   insert.executeUpdate();
                }
             }
Index: net/pms/dlna/DLNAMediaInfo.java
===================================================================
--- net/pms/dlna/DLNAMediaInfo.java   (revision 369)
+++ net/pms/dlna/DLNAMediaInfo.java   (working copy)
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.ListIterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.StringTokenizer;
@@ -356,7 +357,9 @@
                ArrayList<String> lines = (ArrayList<String>) pw.getResults();
                int langId = 0;
                int subId = 0;
+               ListIterator<String> FFmpegMetaData = lines.listIterator();
                for(String line:lines) {
+                  FFmpegMetaData.next();
                   line = line.trim();
                   if (line.startsWith("Output"))
                      matchs = false;
@@ -486,7 +489,18 @@
                         } else
                            lang.lang = DLNAMediaLang.UND;
                         lang.id = subId++;
-                        subtitlesCodes.add(lang);
+//                        subtitlesCodes.add(lang);
+                        int FFmpegMetaDataNr = FFmpegMetaData.nextIndex();
+                        if (FFmpegMetaDataNr > -1) line = lines.get(FFmpegMetaDataNr);
+                        if (line.indexOf("Metadata:") > -1) {
+                           line = lines.get(FFmpegMetaData.nextIndex()+1);
+                           int aa = line.indexOf(": ");
+                           int bb = line.length();
+                           if (aa > -1 && bb > aa) {
+                              lang.flavor = line.substring(aa+2, bb);
+                           }   
+                        }
+                         subtitlesCodes.add(lang);
                      }
                   }
                }
@@ -879,7 +893,7 @@
          s += "\n\taudio: id=" + audio.id + " / lang: " + audio.lang + " / codec: " + audio.codecA + " / sf:" + audio.sampleFrequency;
       }
       for(DLNAMediaSubtitle sub:subtitlesCodes) {
-         s += "\n\tsub: id=" + sub.id + " / lang: " + sub.lang + " / type: " + sub.type;
+         s += "\n\tsub: id=" + sub.id + " / lang: " + sub.lang + " / flavor: " + sub.flavor + " / type: " + sub.type;
       }
       return s;
    }
Index: net/pms/dlna/DLNAMediaSubtitle.java
===================================================================
--- net/pms/dlna/DLNAMediaSubtitle.java   (revision 369)
+++ net/pms/dlna/DLNAMediaSubtitle.java   (working copy)
@@ -49,7 +49,7 @@
    }
 
    public String toString() {
-      return "Sub: " + getSubType() + " / lang: " + lang + " / ID: " + id + " / FILE: " + (file!=null?file.getAbsolutePath():"-");
+      return "Sub: " + getSubType() + " / lang: " + lang + " / flavor: " + flavor + " / ID: " + id + " / FILE: " + (file!=null?file.getAbsolutePath():"-");
    }
    
    public void checkUnicode() {
Index: net/pms/dlna/DLNAResource.java
===================================================================
--- net/pms/dlna/DLNAResource.java   (revision 369)
+++ net/pms/dlna/DLNAResource.java   (working copy)
@@ -475,7 +475,7 @@
          name = (player!=null?("[" + player.name() + "]"):"") + " {Audio: " + media_audio.getAudioCodec() + "/" + media_audio.getLang() + "}";
       
       if (media_subtitle != null && media_subtitle.id != -1)
-         name += " {Sub: " + media_subtitle.getSubType() + "/" + media_subtitle.getLang() + (media_subtitle.flavor!=null?("/"+media_subtitle.flavor):"") +  "}";
+         name += " {Sub: " + media_subtitle.getSubType() + "/" + media_subtitle.getLang() + (media_subtitle.flavor!=null?(" ("+media_subtitle.flavor+")"):"") + "}";
       
       if (avisynth)
          name = (player!=null?("[" + player.name()):"") + " + AviSynth]";
Index: net/pms/encoders/Player.java
===================================================================
--- net/pms/encoders/Player.java   (revision 369)
+++ net/pms/encoders/Player.java   (working copy)
@@ -155,7 +155,7 @@
       if (matchedSub != null && params.sid == null) {
          if (matchedSub.lang != null && matchedSub.lang.equals("off")) {
             PMS.debug(" Disabled the subtitles: " + matchedSub);
-            return;
+            //return;
          } else
             params.sid = matchedSub;
       }
@@ -170,14 +170,30 @@
          if (configuration.getUseSubtitles()) {
             // priority to external subtitles
             for(DLNAMediaSubtitle sub:media.subtitlesCodes) {
-               PMS.debug("Found subtitles track : " + sub);
-               if (sub.file != null) {
-                  PMS.debug("Found external file : " + sub.file.getAbsolutePath());
-                  params.sid = sub;
-                  break;
+               if (matchedSub.lang !=null && matchedSub.lang.equals("off")) {
+                  if (sub.flavor != null && sub.flavor.toLowerCase().indexOf("forced") > -1) {
+                     if (Iso639.isCodesMatching(sub.lang,configuration.getMencoderSubLanguages())) {
+                        PMS.debug("Forcing prefered subtitles : " + sub.getLang() + "/" + sub.flavor);
+                        PMS.debug("Forced subtitles track : " + sub);
+                        if (sub.file != null) {
+                           PMS.debug("Found external forced file : " + sub.file.getAbsolutePath());
+                        }
+                     params.sid = sub;
+                     break;
+                     }
+                  }
+                  continue;
+               } else {
+                  PMS.debug("Found subtitles track : " + sub);
+                  if (sub.file != null) {
+                     PMS.debug("Found external file : " + sub.file.getAbsolutePath());
+                     params.sid = sub;
+                     break;
+                  }
                }
             }
          }
+         if (matchedSub.lang !=null && matchedSub.lang.equals("off")) return;
          
          //
          if (params.sid == null) {

Link and code posted here updated!!! - Sorry I forgot to compile changes in Player.java so link updated 8-)
Pre-compiled update.jar file here (based on r369): http://www.mediafire.com/?jtljmj4ejnr
Shagrath, can you help me with loading forced subs automatically for MKV files outside transoce folder with tsMuxeR engine at first place in priority list? Many thanks 8-)
EDIT:
Forgot to say that you need to reset your media library so new info will be retrieved(with help of new FFmpeg) ;)
ExSport
 
Posts: 2168
Joined: Mon Jan 19, 2009 5:40 pm

Re: Additional SUBs info in TRANSCODE folder+forced SUBs support

Postby ExSport » Wed Feb 03, 2010 10:16 pm

Changes made by ExSport on r385 build:
    - forced subs support (for both external and embedded subs)
    - additional info about subtitle track in transcode folder (for embedded subtitles with additional tag defined, e.g. "forced")
    - !!-- Fix 23.976/25fps A/V Mismatch --!! directly in #-TRANSCODE-# folder instead of in #-VIDEO SETTINGS-# only (fixes bad A/V synchro)
    - Added -mc 0.005 instead of -mc 0 -noskip which enables possibility to count with audio delay and realtime A/V synchronization
How to use it:
1. Install latest r381 or newer
2. copy update.jar next to pms.exe/pms.sh and pms.jar file(in installed directory)
3. restart PMS and reset Media Library if used (old database doesn't include new additional info about subtitles)

Prerequisites for "forced" subs support & displaying additional subtitles info:
You need latest FFmpeg version which supports Metadata (already included in latest Windows r381 build, don't know about other OS)

How to configure subtitles:
To define audio tag in external subtitle file use this example: moviename.en.srt or moviename.en-forced.srt
Image

Link: http://www.mediafire.com/ExSport
ExSport
 
Posts: 2168
Joined: Mon Jan 19, 2009 5:40 pm

Previous

Return to General Discussion

Who is online

Users browsing this forum: meskibob and 8 guests