Bug Fix: Stream/Transcode decision logic

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

Bug Fix: Stream/Transcode decision logic

Postby StreamHD » Mon Jan 02, 2012 4:10 pm

Hi

I've been having problems getting videos with subs to stream. Checking "Definitely disable subs" does what it says but the video will still transcode unnecessarily. There are currently 2 problematic ways to get around this:
1) Use "StreamExtension=" in the renderers configuration file. This interferes with "Supported=" lines thus reducing the benefits of using "MediaInfo=True". This would need to be done for each renderer on the network which supports the video format.
2) Use the "Skip Transcode" option in the PS3MS configuration. This is a global setting and can interfere when using several different renderers simultaneously.

Proposed solution:
1) If "Definitely disable subs" is checked: Modify DLNAResource.getChild() method so that, when deciding if media should be streamed or transcoded, it should skip/fail the subtitle tests. See "Solution Part 1".
2) If "Definitely disable subs" is not checked: Perform the original subtitle test and give an option to stream supported videos from the #Transcode# folder. This option only appears properly on the PS3 (Edit: correction). We would also need to deal with the case when default subtitle = "Off". I might look into this part of the solution but it is not a priority for me... I prefer to disable subs.

Solution Part 1:
Notice that the proposed solution is consistent with statement 4 (line 549 below). "Definitely disable subs" is checked implies that we don't intend to deal with subs.

Original DLNAResource.java, lines 545 - 553:
Code: Select all
545   // Force transcoding if
546   // 1- MediaInfo support detected the file was not matched with supported codec configs and no SkipTranscode extension forced by user
547   // or 2- ForceTranscode extension forced by user
548   // or 3- FFmpeg support and the file is not ps3 compatible (need to remove this ?) and no SkipTranscode extension forced by user
549   // or 4- There's some sub files or embedded subs to deal with and no SkipTranscode extension forced by user
550   if (forceTranscode || !isSkipTranscode() && (forceTranscodeV2 || (!parserV2 && !child.getExt().ps3compatible()) || (PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs)) {
551      child.setPlayer(pl);
552      LOGGER.trace("Switching " + child.getName() + " to player: " + pl.toString());
553   }


Subtitles are checked by (from line 550):
Code: Select all
(PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs


"Logical AND" the subtitle check statement with !PMS.getConfiguration().isMencoderDisableSubs() to skip/fail the subtitle check when "Definitely disable subs" is checked:
Code: Select all
550   if (forceTranscode || !isSkipTranscode() && (forceTranscodeV2 || (!parserV2 && !child.getExt().ps3compatible()) || (!PMS.getConfiguration().isMencoderDisableSubs() && ((PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs)))) {


This partially fixes Stream/Transcode decision logic when dealing with subtitles, and does not affect any of the other decision logic. Part 2 of the solution could potentially complete the fix.
Last edited by StreamHD on Fri Jan 06, 2012 5:07 pm, edited 2 times in total.
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: Bug Fix: Stream/Transcode decision logic

Postby Raptor399 » Mon Jan 02, 2012 6:56 pm

Pffff... Enough conditions to make ones head spin! :|
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Bug Fix: Stream/Transcode decision logic

Postby StreamHD » Tue Jan 03, 2012 2:52 am

Raptor399 wrote:Pffff... Enough conditions to make ones head spin! :|


True, that's probably why the "PMS.getConfiguration().isMencoderDisableSubs()" condition was overlooked. I say overlooked because its inclusion makes sense when considering the description of what the logic is meant to achieve.

This is easier to read:
Code: Select all
boolean isSubsToTranscode = false;

if !PMS.getConfiguration().isMencoderDisableSubs() {
    isSubsToTranscode = (PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs;
}

if (forceTranscode || !isSkipTranscode() && (forceTranscodeV2 || (!parserV2 && !child.getExt().ps3compatible()) || isSubsToTranscode)) {
    child.setPlayer(pl);
    LOGGER.trace("Switching " + child.getName() + " to player: " + pl.toString());
}
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: Bug Fix: Stream/Transcode decision logic

Postby Raptor399 » Tue Jan 03, 2012 9:20 am

That helps a bunch, indeed. :-)

I have updated the logic; does it work as intended?
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Bug Fix: Stream/Transcode decision logic

Postby StreamHD » Wed Jan 04, 2012 1:57 pm

It works as expected, thanks!

There are problems getting mencoder to show external subtitles via the #transcode# folder when isMencoderDisableSubs() = true. This isn't "stream/transcode" decision logic though, more of a "mencoder ext. subs" decision logic. Embedded subs work fine.
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: Bug Fix: Stream/Transcode decision logic

Postby StreamHD » Sat Jan 07, 2012 4:01 pm

Raptor399, you gave "RendererConfiguration.isStreamable(Format f)" as an example to make support less ps3-specific.

Is there a reason for sticking with "Format f"? I have an "RendererConfiguration.isStreamable(DLNAMediaInfo media)" which I'm busy testing and polishing but hope you will save me the time if this is not sufficient.

My logic is that the format can be parsed and then its media-info can be used to assess specific renderer support.
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: Bug Fix: Stream/Transcode decision logic

Postby leroy » Sat Jan 07, 2012 10:56 pm

Hi StreamHD,

I accomplished to build the latest version from GitHub with your fix,
and tested it.

awesome fix! ;)

With "Definitely disable subtitles" Not! ticked,
the decision for transcoding with external / embedded subtitles on my Philips TV but also on my Philips HTS player now works perfect!

Even the "Supported" lines be used.

Great work for a student Java developer. :D
leroy
 
Posts: 141
Joined: Sat Sep 24, 2011 11:55 am
Location: Netherlands

Re: Bug Fix: Stream/Transcode decision logic

Postby StreamHD » Sat Jan 07, 2012 11:33 pm

leroy wrote:With "Definitely disable subtitles" Not! ticked,
the decision for transcoding with external / embedded subtitles on my Philips TV but also on my Philips HTS player now works perfect!


hmm wonder if there isn't another patch which helps you... this patch only has effect when "definately disable subs" IS checked :)
Anyways, glad you're getting even more out of PMS now!
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: Bug Fix: Stream/Transcode decision logic

Postby Raptor399 » Sat Jan 07, 2012 11:36 pm

StreamHD wrote:Raptor399, you gave "RendererConfiguration.isStreamable(Format f)" as an example to make support less ps3-specific.

Is there a reason for sticking with "Format f"? I have an "RendererConfiguration.isStreamable(DLNAMediaInfo media)" which I'm busy testing and polishing but hope you will save me the time if this is not sufficient.

My logic is that the format can be parsed and then its media-info can be used to assess specific renderer support.

It was just something I jotted down without giving it a lot of thought, no need to stick to the specifics. :-)
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Bug Fix: Stream/Transcode decision logic

Postby leroy » Sun Jan 08, 2012 10:30 pm

Hi all,
leroy wrote:With "Definitely disable subtitles" Not! ticked,
the decision for transcoding with external / embedded subtitles on my Philips TV but also on my Philips HTS player now works perfect!

Even the "Supported" lines be used.:D

Sorry for my previous enthusiastic but faulty conclusions. :oops:

After more testing with the 1.50.1-SNAPSHOT build, now i have these conclusions.

If "definately disable subs" is Not checked:
Behavior is the same as previous builds.
TV:
Works fine, external and embedded sups both correct transcoded.

HTS:
External sups are transcoded. (External sups are not native supported by HTS)
Unfortunately embedded sups (native supported by HTS) also transcoded.

If "definately disable subs" IS checked:
TV:
External sups are not transcoded, no subs visible.

Embedded sups are transcoded if one of the audio streams is DTS. (plays fine but subs are visible?!)
Video files with embedded sups without DTS audio are not transcoded.

HTS:
External sups are not transcoded.
Embedded sups are not transcoded, and the native supported features by the HTS can be used, like:
Search on time, chapter, REW/FF, switch between audio and subtitle tracks.
leroy
 
Posts: 141
Joined: Sat Sep 24, 2011 11:55 am
Location: Netherlands

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 4 guests