Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Enabling MEncoder ASS subtitle support for embedded subtitles. #60

Closed
XenoPhex opened this issue Jul 2, 2012 · 67 comments
Closed

Enabling MEncoder ASS subtitle support for embedded subtitles. #60

XenoPhex opened this issue Jul 2, 2012 · 67 comments

Comments

@XenoPhex
Copy link

XenoPhex commented Jul 2, 2012

MPlayer/MEncoder has had support for this for a while now and I'm wondering why it's been blocked. To show the difference during playback I ran this under MPlayer (the only difference between the runs was the '-ass' flag):

http://s14.postimage.org/nfojh6v69/Non_ASS_Subtitles.png
http://s16.postimage.org/bcwjfb7ad/ASS_Subtitles.png

Most Anime (usually in MKV containers) or other subtitled shows tend to contain embedded subtitles that display in the maner shown in the first screenshot and make it very difficult to watch. I've made the following change (I guess I should have made this a pull request?) that makes the subtitles render as they do in the second screenshot:

https://github.com/XenoPhex/ps3mediaserver/commit/538f87bc960042ecb58cc1cf1ef72ee841122dda

I know I've had to make this change on a few of my friend's copies of PMS and I think it's worth looking at if you guys have the time.

@Raptor399
Copy link
Member

I have tried your patch, but I don't notice a difference on any of my test streams.
I'm using PMS 1.55.0-SNAPSHOT on Mac OSX here.

Can you supply a movie sample where we can see the difference?

@ikarsokolov
Copy link
Member

SSA subtitles works perfectly (embedded fonts, animations, asian characters etc) on Linux + mencoder r34587 (SB22) with these settings:

subtitle's settings

Test them out.

@Raptor399
Copy link
Member

I did some more testing with various combinations of old and new mencoder builds (SB22, SB32, SB35 and r35007), several movies with external and embedded subtitles, with and without the proposed patch, with the default settings and the ones that Happy-Neko presented.

I can now confirm that the patch indeed fixes the rendering of some of the movies with SSA embedded subs. Without the patch, subs do not render correctly as in the screenshots presented in this issue, not even with different settings in PMS or by using mencoder-SB22.

At the same time the patch left other movies and subtitles intact.

Since the patch appears to be correct, I have outcommented the lines in commit 503eb25.

Closing this issue accordingly.
Thanks, @XenoPhex !

@ikarsokolov ikarsokolov reopened this Jul 3, 2012
@ikarsokolov
Copy link
Member

I think we shouldn’t hurry.
I recall the story now. This workaround was added here b9b8c05 for Hebrew subtitles. We need proper testing if this issues is indeed fixed.

Also this code snippet affects only SRT subtitles in container. My impression was that @XenoPhex was talking about SSA/ASS.

@Raptor399
Copy link
Member

I don't have more files to test with; as written above I tested it with all combinations I could come up with and in all combinations the patch worked as expected.

You're welcome to run more tests as I only have a very limited set of test files.

Also this code snippet affects only SRT subtitles in container. My impression was that @XenoPhex was talking about SSA/ASS.

The code snippet affects UTF-8 embedded and non-embedded subtitles.
Is SRT the only format that can be embedded?

Note that inside the if-statement is the only place where the sb.append("-ass "); can happen.
As the original poster claims, that particular flag is indeed what makes or breaks my test movie with embedded subtitles. With "-ass", the movie displays the correct subs, without it, it breaks. The patch seems to make it kick in at the right time.

As for Hebrew, that is indeed an issue, but it is a different issue, I think.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 3, 2012

While I don't have a short/small test video, I can present the following to you as a test: http://www.nyaa.eu/?page=torrentinfo&tid=324868

This is the video that I took the screenshots from, the issue presents itself within the first minute or so.

Note that inside the if-statement is the only place where the sb.append("-ass "); can happen.
As the original poster claims, that particular flag is indeed what makes or breaks my test movie with embedded subtitles. With "-ass", the movie displays the correct subs, without it, it breaks. The patch seems to make it kick in at the right time.

This is completely correct, I was a little unsure as to why it was picking out both the 'embedded' and UTF-8 values as exclusion criteria. I vaguely remember a little over a year ago that mplayer/mencoder didn't handle these properly all the time, but I'm pretty sure that's no longer an issue (at least from what I've seen since 1.20 of PMS).

SSA subtitles works perfectly (embedded fonts, animations, asian characters etc) on Linux + mencoder r34587 (SB22) with these settings

The problem is, as shown in the screenshot, if there are complex subtitles on the screen they tend to format in that weird fashion which makes them very difficult to read. I've tried every combination of checking and unchecking those boxes and also leave 'UTF-8' as my standard subtitle format and have had no success with displaying subtitles correctly on any of my anime MKVs that use ASS formatting. The modification is the only way I've been able to make things display properly.

I'm curious as to why this breaks with Hebrew as I've seen Chinese and Japanese subtitles render properly. Do you guys have a test file as well, I'd like to do my own research as well if you guys don't mind.

@ikarsokolov
Copy link
Member

Is SRT the only format that can be embedded?

DLNAMediaSubtitle.EMBEDDED most likely is assigned to embedded SRTs only https://github.com/ps3mediaserver/ps3mediaserver/blob/master/src/main/java/net/pms/dlna/MediaInfoParser.java#L361

All my mkvs report Codec ID: S_TEXT/UTF8 for embedded SRTs and S_TEXT/ASS for SSA/ASS. In any case we need to rename the constants to better represent real logic behind code.

As the original poster claims, that particular flag is indeed what makes or breaks my test movie with embedded subtitles. With "-ass", the movie displays the correct subs, without it, it breaks.

Can you share your mkv+ssa sample affected by this patch?

SSA do work, but ASS do not.

I am not sure there are any real differences between them,

I've tried every combination of checking and unchecking those boxes and also leave 'UTF-8' as my standard subtitle format and have had no success with displaying subtitles correctly on any of my anime MKVs that use ASS formatting.

I don't have many animation videos but few test samples displays exactly like they do on PC. On somehow related note from my experience most of their releasers compete in crazy "make most incompatible file ever" game: flac tracks, crazy reference frame counts, 10bit x264, segmented mkvs etc. I don't really know what theses people are thinking.

I can present the following to you as a test

I give it a try.

@ikarsokolov
Copy link
Member

Well, that was fast :)

Test file displays exactly like on this picture:

video with subtitles

@XenoPhex
Copy link
Author

XenoPhex commented Jul 3, 2012

SSA do work, but ASS do not.

I am not sure there are any real differences between them,

Yeah, I removed that from my comment a few minutes later because I realized how stupid that sentence was! But from what I understand of ASS, it's a subset of SSA/newer standard of SSA. So a lot of older applications don't always support both (and I'm not sure how compatible the new version is with the older versions).

Well, that was fast :)

People love seeding them Animes!

Test file displays exactly like on this picture:

Was that with the '-ass' flag or without?

@ikarsokolov
Copy link
Member

Was that with the '-ass' flag or without?

With -ass:

Starting /usr/lib/ps3mediaserver/linux/mencoder -ss 542.0 -quiet /media/[gg]_EUREKA_SEVEN_AO_-_10_[480E519B].mkv -quiet -quiet -nosound -nosound -of rawvideo -quiet -quiet -mpegopts format=mpeg2:muxrate=500000:vbuf_size=1194:abuf_size=64 -ovc lavc -channels 2 -lavdopts debug=0:threads=2 -lavcopts autoaspect=1:vcodec=mpeg2video:acodec=ac3:abitrate=448:threads=2:keyint=2:vqscale=1:vqmin=2 -ass -noflip-hebrew -fontconfig -subcp utf-8 -quiet -quiet -sid 0 -quiet -quiet -ofps 24000/1001 -quiet -quiet -lavdopts fast -mc 0 -noskip -o /tmp/ps3mediaserver-user/1341356824707ffmpegvideo

So either muxed SSA subtitles are not DLNAMediaSubtitle.EMBEDDED or sid.isFileUtf8() is broken on non-linux systems.

Mediainfo for this file

General
Unique ID                                : 209680351829389166059316266958446570706 (0x9DBEF7826B487CC69C09F1F41D32ACD2)
Complete name                            : [gg]_EUREKA_SEVEN_AO_-_10_[480E519B].mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 433 MiB
Duration                                 : 24mn 26s
Overall bit rate                         : 2 477 Kbps
Movie name                               : [gg] Eureka Seven AO 10
Encoded date                             : UTC 2012-06-22 07:03:26
Writing application                      : mkvmerge v5.0.1 ('Es ist Sommer') built on Oct  9 2011 11:55:43
Writing library                          : libebml v1.2.2 + libmatroska v1.3.0
Attachment                               : Yes / Yes / Yes / Yes / Yes

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High 10@L5.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 16 frames
Muxing mode                              : Header stripping
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 24mn 26s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 23.976 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Scan type                                : Progressive
Title                                    : 720p H.264
Writing library                          : x264 core 122 r2184 5c85e0a
Encoding settings                        : cabac=1 / ref=16 / deblock=1:1:1 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=0.40:0.00 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=10 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=15.0 / qcomp=0.60 / qpmin=0 / qpmax=81 / qpstep=4 / ip_ratio=1.40 / aq=1:0.60
Language                                 : Japanese
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : A_AAC
Duration                                 : 24mn 26s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Title                                    : 2.0 AAC
Language                                 : Japanese
Default                                  : Yes
Forced                                   : No

Text
ID                                       : 3
Format                                   : ASS
Codec ID                                 : S_TEXT/ASS
Codec ID/Info                            : Advanced Sub Station Alpha
Compression mode                         : Lossless
Title                                    : ass
Language                                 : English
Default                                  : Yes
Forced                                   : No

Menu
00:00:00.000                             : en:a
00:01:30.007                             : en:b
00:09:54.111                             : en:c
00:22:28.097                             : en:d
00:23:59.001                             : en:e

@XenoPhex
Copy link
Author

XenoPhex commented Jul 3, 2012

I have a strong feeling it might be the UTF-8 check because I think that's what was causing the inter-boolean statement to fail of the removed code.

I guess I was fixing a symtom and not the actual problem, especially since I just stumbled across this which indicates that all subtitles are converted to UTF-8:
http://matroska.org/technical/specs/subtitles/ssa.html

@ikarsokolov
Copy link
Member

UTF8 code looks like total disaster.

There are only two places where it can be set to true:

  1. https://github.com/ps3mediaserver/ps3mediaserver/blob/master/src/main/java/net/pms/dlna/MediaInfoParser.java#L361
    As you see embedded SSA subs always are DLNAMediaSubtitle.ASS and isUTF8 == false.
    embedded SRT subs always are DLNAMediaSubtitle.EMBEDDED and isUTF8 == true.
  2. DLNAMediaSubtitle.checkUnicode works for external subtitles only and does not affect this bug.

So it looks like commented snippet https://github.com/XenoPhex/ps3mediaserver/commit/538f87bc960042ecb58cc1cf1ef72ee841122dda should never be triggered in the first place. We need to properly fix this mess instead of sticking with workarounds.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 4, 2012

I agree, I submitted the patch under the assumption that the encoding was not UTF8, but I can see now that it is not the case. Should I close this out and let you guys handle the rest? Or should I at least create a separate issue?

@Raptor399
Copy link
Member

We need to properly fix this mess instead of sticking with workarounds.

Definitely. It sounds wrong that SSA subs could only be non-UTF-8.

@ikarsokolov
Copy link
Member

I suggest to drop all UTF8 checks for embedded subs. They are pointless.

@Raptor399
Copy link
Member

Looks like the method DLNAMediaSubtitle.isFileUtf8() is unreliable and pretty useless, since the code linked above is the only place where setFileUtf8() is called.

I suggest we relabel DLNAMediaSubtitle.EMBEDDED to DLNAMediaSubtitle.SRT, and deprecate DLNAMediaSubtitle.isFileUtf8() and DLNAMediaSubtitle.setFileUtf8() and place all four calls to them (1, 2, 3, 4) by params.sid.getType() == DLNAMediaSubtitle.SRT.

Incidentally, the suggested replacement immediately demonstrates why the patch is indeed correct.

It would transform that particular bit of code into:

    (
        (
            params.sid.getType() == DLNAMediaSubtitle.SRT &&
            params.sid.getType() == DLNAMediaSubtitle.SRT
        ) ||
        params.sid.getType() != DLNAMediaSubtitle.SRT
    ) &&
    ...

This expression is always true; that is why outcommenting makes no difference whatsoever to the rest of the if-statement.

@ikarsokolov
Copy link
Member

I completed first iteration of DLNAMediaSubtitle refactoring.
@XenoPhex and @Raptor399 please test if HEAD works for you.

Before testing do not forget to:

  • reset media DB
  • add RendererUniqueID = ps3 to PS3.conf

In the future I plan to remove SubtitleType.EMBEDDED because "embedded" is not valid track type. Right now it actually indicates "generic subtitle track". We should use DLNAMediaSubtitle.isEmbedded instead and assign proper type with libmediainfo parser or file extension matching.

@Raptor399
Copy link
Member

Looks like you had a good time refactoring the whole lot.
The code changes look comprehensible and good to me, they certainly make the code more understandable. Good job!
I'll see if the tests come up with something.

@Raptor399
Copy link
Member

There were NullPointerExceptions, I fixed those in 0a7a4d3.
But after fixing those, all my test files play exactly as before the changes.

@ikarsokolov
Copy link
Member

Great!
I have done refactoring, Code is more readable now. Later we can apply same approach to audio and video tracks parsing.

@Raptor399
Copy link
Member

Awesome work, Happy-Neko! :-D

@ikarsokolov
Copy link
Member

Thanks!

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

Oh wow, lots'a things just changed! Let me run this against a couple different set files and let me get back to you.

I think I noticed some funky behavior last night with MP4 subs, after your first set of changes. Let me confirm if that's still true. But everything else looked like it was working!

I'll try and post my results in an hour or so.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

Here's a fun one, I'm getting the following error every time I go into a #--TRANSCODE--/*.ogm. I get the following error:

INFO  2012-07-07 10:56:32.906 [pool-241-thread-3] Exception in thread "pool-241-thread-3" java.lang.NullPointerException
INFO  2012-07-07 10:56:32.907 [pool-241-thread-3]   at net.pms.dlna.DLNAResource.getDisplayName(DLNAResource.java:907)
INFO  2012-07-07 10:56:32.907 [pool-241-thread-3]   at net.pms.dlna.DLNAResource.getDisplayName(DLNAResource.java:859)
INFO  2012-07-07 10:56:32.907 [pool-241-thread-3]   at net.pms.dlna.FileTranscodeVirtualFolder.addChapterFile(FileTranscodeVirtualFolder.java:130)
INFO  2012-07-07 10:56:32.907 [pool-241-thread-3]   at net.pms.dlna.FileTranscodeVirtualFolder.resolve(FileTranscodeVirtualFolder.java:85)
INFO  2012-07-07 10:56:32.907 [pool-241-thread-3]   at net.pms.dlna.DLNAResource.run(DLNAResource.java:754)
INFO  2012-07-07 10:56:32.908 [pool-241-thread-3]   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
INFO  2012-07-07 10:56:32.908 [pool-241-thread-3]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
INFO  2012-07-07 10:56:32.908 [pool-241-thread-3]   at java.lang.Thread.run(Thread.java:680)

@ikarsokolov
Copy link
Member

Please attach mediainfo for this file.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

In the process, apparently you have to F****** pay for MediaInfo on OS X now, so I'm just trying to track down an older version.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

Screw it, I'll just pay the 99 cents. Worth it, right?
I'll try and find you a copy of it in in a minute, I need a decently fast enough place to upload it to.

General
Complete name : /Volumes/Earth/Anime/FLCL/FLCL - 01 - Fooly Cooly.ogm
Format : OGG
File size : 352 MiB
Duration : 24mn 38s
Overall bit rate mode : Variable
Overall bit rate : 1 996 Kbps
Movie name : FLCL - Episode 1 - Fooly Cooly
Performer : Ripped by SpaceBall-1, Zhentarim DivX
Description : If you like this anime, please support the publisher by buying it!
Copyright : Synch-Point

Video
ID : 0 (0x0)
Format : MPEG-4 Visual
Format settings, BVOP : 1
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Muxing mode : Packed bitstream
Codec ID : DX50
Codec ID/Hint : DivX 5
Duration : 24mn 38s
Bit rate : 1 564 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.212
Stream size : 276 MiB (78%)
Writing library : DivX 5.1.0 (UTC 2003-09-02)
Language : fl ( EPISODE 1 )

Audio #1
ID : 1 (0x1)
Format : Vorbis
Format settings, Floor : 1
Duration : 24mn 38s
Bit rate mode : Variable
Bit rate : 112 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 19.7 MiB (6%)
Writing library : libVorbis 1.0 (UTC 2002-07-17)
Language : English

Audio #2
ID : 2 (0x2)
Format : Vorbis
Format settings, Floor : 1
Duration : 24mn 38s
Bit rate mode : Variable
Bit rate : 112 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 19.7 MiB (6%)
Writing library : libVorbis 1.0 (UTC 2002-07-17)
Language : Japanese

Audio #3
ID : 3 (0x3)
Format : Vorbis
Format settings, Floor : 1
Duration : 24mn 38s
Bit rate mode : Variable
Bit rate : 112 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 19.7 MiB (6%)
Writing library : libVorbis 1.0 (UTC 2002-07-17)
Language, more info : Director's Comments

Text #1
ID : 4 (0x4)
Format : Subrip
Language : English

Text #2
ID : 5 (0x5)
Format : Subrip
Language, more info : Director's Comments

Menu
00:00:00.000 : FLCL 01: Fooly Cooly
00:21:51.000 : Credits
00:24:13.000 : Preview

@ikarsokolov
Copy link
Member

Interesting, mediainfo does not report Codec ID for SRTs in ogm.

And one more thing: check if your ps3ms have libmediainfo successfully loaded (trace tab).

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

I had to break it into two parts (Winrar) since the file was too big:
Part 1: http://www.mediafire.com/?93z65mtutawko9k
Part 2: http://www.mediafire.com/?e3mfs29xvm543b5

I'll keep these up until the end of the week, just in case the rest of your team wants a copy, after that i'll drop them.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

Seems that subtitles inside an MP4 container aren't working. My test video (sorry for the large size): http://www.nyaa.eu/?page=torrentinfo&tid=260321
Full MediaInfo is in the torrent description if you scroll down a bit. The torrent itself says it has about 90 seeders, so it shouldn't be too terrible to download if you're willing.

The weirder thing is that not only does it not matter what audio or subtitle you select it, it only seems to play English Audio (aid 1) with no subtitles selected. The audio issue is probably a separate bug, but I'll try and track that down once I figure out what's bugging out with the subtitles.

What confuses me is that the following command does work as intended:

mplayer \[TV-J\]\ Kidou\ Senshi\ Gundam\ UC\ Unicorn\ -\ episode.04\ \[BD\ 1920x1080\ h264+AAC\(5.1ch\ JP,EN\)\ Sub\(JP,EN,FR,SP,CH\)\].mp4 -sid 1 -ss 180

Debug Log:

DEBUG 2012-07-07 13:08:36.383 [mencoder-51] Starting "/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder" -ss 180.0 -quiet "/Gundam Unicorn/[TV-J] Kidou Senshi Gundam UC Unicorn - episode.04 [BD 1920x1080 h264+AAC(5.1ch JP,EN) Sub(JP,EN,FR,SP,CH)].mp4" -quiet -quiet -nosound -nosound -of rawvideo -quiet -quiet -mpegopts format=mpeg2:muxrate=500000:vbuf_size=1194:abuf_size=64 -ovc lavc -channels 6 -lavdopts debug=0:threads=6 -lavcopts autoaspect=1:vcodec=mpeg2video:acodec=ac3:abitrate=640:threads=6:keyint=5:vqscale=1:vqmin=2:vrc_maxrate=50000:vrc_buf_size=7000 -ass -fontconfig -subcp UTF-8 -quiet -quiet -sid 1 -quiet -quiet -ofps 24000/1001 -quiet -quiet -lavdopts fast -mc 0.1 -mc 0 -noskip -endpos 3590.0 -o /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916231ffmpegvideo
DEBUG 2012-07-07 13:08:36.400 [mkfifo-55] Starting mkfifo -m 777 /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916231tsmuxerout.ts
DEBUG 2012-07-07 13:08:36.433 [mencoder-51] Attaching thread: mencoder-51
DEBUG 2012-07-07 13:08:36.437 [mencoder-51] Unix process ID (/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder): 37908
DEBUG 2012-07-07 13:08:36.437 [mkfifo-55] Unix process ID (mkfifo): 37909
DEBUG 2012-07-07 13:08:36.452 [mkfifo-56] Starting mkfifo -m 777 /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916383ffmpegaudio01
DEBUG 2012-07-07 13:08:36.452 [mkfifo-57] Starting mkfifo -m 777 /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916383audioout
DEBUG 2012-07-07 13:08:36.484 [mkfifo-57] Unix process ID (mkfifo): 37911
DEBUG 2012-07-07 13:08:36.484 [mkfifo-56] Unix process ID (mkfifo): 37910
DEBUG 2012-07-07 13:08:36.513 [Thread-140] Unsupported PixelFormat 61
DEBUG 2012-07-07 13:08:36.513 [Thread-140] Unsupported PixelFormat 53
DEBUG 2012-07-07 13:08:36.513 [Thread-140] Unsupported PixelFormat 81
DEBUG 2012-07-07 13:08:36.654 [mencoder-54] Starting "/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder" -ss 180.0 "/Gundam Unicorn/[TV-J] Kidou Senshi Gundam UC Unicorn - episode.04 [BD 1920x1080 h264+AAC(5.1ch JP,EN) Sub(JP,EN,FR,SP,CH)].mp4" -really-quiet -msglevel statusline=2 -channels 6 -ovc copy -of rawaudio -mc 0 -noskip -aid 1 -oac pcm -af channels=6:6:0:0:1:1:2:5:3:2:4:4:5:3 -srate 48000 -o /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916383ffmpegaudio01
DEBUG 2012-07-07 13:08:36.654 [tsMuxeR-50] Starting "/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/tsMuxeR" /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/pms-tsmuxer.meta /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916231tsmuxerout.ts
DEBUG 2012-07-07 13:08:36.706 [tsMuxeR-50] Reading pipe: /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341680916231tsmuxerout.ts
DEBUG 2012-07-07 13:08:36.706 [mencoder-54] Attaching thread: mencoder-54
DEBUG 2012-07-07 13:08:36.707 [mencoder-54] Unix process ID (/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder): 37914
DEBUG 2012-07-07 13:08:36.987 [tsMuxeR-50] Attaching thread: tsMuxeR-50
DEBUG 2012-07-07 13:08:36.989 [Thread-157] SmartLabs tsMuxeR.  Version 1.10.6  http://www.smlabs.net
DEBUG 2012-07-07 13:08:36.989 [tsMuxeR-50] Unix process ID (/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/tsMuxeR): 37915
DEBUG 2012-07-07 13:08:36.989 [Thread-157] MPEG-2 stream does not contain fps field. Muxing fps=23.976
DEBUG 2012-07-07 13:08:36.989 [Thread-157] Decoding MPEG2 stream (track 1): Profile: Main@4. Resolution: 1920:1080p. Frame rate: 23.976
DEBUG 2012-07-07 13:08:36.989 [Thread-157] 100.0% complete
DEBUG 2012-07-07 13:08:36.989 [Thread-157] Decoding LPCM stream (track 2): Bitrate: 4608Kbps  Sample Rate: 48KHz  Channels: 5.1  Bits per sample: 16bit

@XenoPhex
Copy link
Author

XenoPhex commented Jul 7, 2012

I've traced the previous problem to the '-ass' being added into the mencoder string. If it's removed, it works properly.

I'll file a separate issue for the Audio problem since that looks like an off by 1 error.

@ikarsokolov
Copy link
Member

Both .ogm and .mp4 samples work now. Though I noticed some VobSub flickering with mencoder SB22.
Can you test with more fresh mencoder versions?

@XenoPhex
Copy link
Author

XenoPhex commented Jul 8, 2012

Lots of changes! So I'll go at them in points:

  1. Looks like subtitles are now working in all my test cases (MKVs, OGMs, MP4s, AVIs, etc.) be them SRT, SSA/ASS, or MP4S. Great work!

  2. As for the flashing subtitles, I've been noticing that for a while and the weird thing is I'm pretty sure MEncoder is outputting it properly. To test this out, I used the exact command that PMS is using to render the video except I modify the output file to send it to my Desktop. I then open the file in VLC (which crashes about 1/3 of the time when trying to open it, so you have to try it a few times). I noticed in VLC's case it doesn't blink every time the subtitles change. But this issue only seems to appear in MP4s from what I can tell.

  3. I actually wrote a script to replace the MEncoder/MPlayer instance side the app with my system one after every rebuild. And unless there's a problem with it, I usually use whatever the latest SVN build of MEncoder/MPlayer is at the time. I normally recompile it once a month or so, but I gave it a try today and it didn't seem to make a difference with the flickering issue.

  4. I also noticed you fixed the language selection problem with MP4s, thanks! I spent an hour or so yesterday trying to track that down but I couldn't really figure out where the parameters were being set in the TRANSCODE folders.

  5. Unfortunately while testing add solaris specific ping command to fix issue #1277 #4, I found a file where the sound isn't being outputted during one of my MKV tests. It seems that for this particular set of files, the first two audio streams don't work, but third one does, which kind of confuses me.

I see this in the log when I first enter the folder:

INFO  2012-07-08 14:59:59.266 [New I/O server worker #1-23] Unknown number of audio channels detected. Using 6.

And then I see this from the debug log:
Debug Log - Trying to play the first audio stream:

DEBUG 2012-07-08 14:43:49.369 [mencoder-231] Starting "/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder" -ss 3.837 "/Gundam 08th MS Team [OZC]/Mobile Suit Gundam - The 08th MS Team Remastered E02 'Gundams in the Jungle'.mkv" -really-quiet -msglevel statusline=2 -channels 6 -ovc copy -of rawaudio -mc 0 -noskip -aid 1 -oac pcm -af channels=6:6:0:0:1:1:2:5:3:2:4:4:5:3 -srate 48000 -o /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341773029102ffmpegaudio01
DEBUG 2012-07-08 14:43:49.369 [tsMuxeR-227] Starting "/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/tsMuxeR" /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/pms-tsmuxer.meta /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341773028950tsmuxerout.ts
DEBUG 2012-07-08 14:43:49.415 [tsMuxeR-227] Reading pipe: /var/folders/34/dp7qgnr16pg8gpjqj1cp1xqh0000gn/T/ps3mediaserver/1341773028950tsmuxerout.ts
DEBUG 2012-07-08 14:43:49.417 [mencoder-231] Attaching thread: mencoder-231
DEBUG 2012-07-08 14:43:49.419 [mencoder-231] Unix process ID (/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder): 89109
INFO  2012-07-08 14:43:49.441 [mencoder-231] Process /Applications/PS3 Media Server.app/Contents/Resources/Java/osx/mencoder has a return code of 1! Maybe an error occurred... check the log file
DEBUG 2012-07-08 14:43:49.503 [tsMuxeR-227] Attaching thread: tsMuxeR-227
DEBUG 2012-07-08 14:43:49.505 [Thread-621] SmartLabs tsMuxeR.  Version 1.10.6  http://www.smlabs.net
DEBUG 2012-07-08 14:43:49.505 [tsMuxeR-227] Unix process ID (/Applications/PS3 Media Server.app/Contents/Resources/Java/osx/tsMuxeR): 89110
DEBUG 2012-07-08 14:43:49.505 [Thread-621] MPEG-2 stream does not contain fps field. Muxing fps=23.976
DEBUG 2012-07-08 14:43:49.505 [Thread-621] Decoding MPEG2 stream (track 1): Profile: Main@8. Resolution: 720:480p. Frame rate: 23.976
DEBUG 2012-07-08 14:43:49.505 [Thread-621] 100.0% complete
DEBUG 2012-07-08 14:43:49.691 [Thread-621] �M100.0% complete

MediaInfo for file:

General
Unique ID : 240753026726973586820822196982758733571 (0xB51F58A9939D747DB8A8A74BD84B7703)
Complete name : /Gundam 08th MS Team [OZC]/Mobile Suit Gundam - The 08th MS Team Remastered E02 'Gundams in the Jungle'.mkv
Format : Matroska
Format version : Version 2
File size : 300 MiB
Duration : 24mn 47s
Overall bit rate : 1 691 Kbps
Encoded date : UTC 2010-01-26 08:48:32
Writing application : mkvmerge v3.0.0 ('Hang up your Hang-Ups') built on Dec 12 2009 15:20:35
Writing library : libebml v0.7.9 + libmatroska v0.8.1
Attachment : Yes / Yes / Yes / Yes / Yes / Yes / Yes / Yes

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 10 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 24mn 47s
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Original display aspect ratio : 3:2
Frame rate : 23.976 fps
Standard : NTSC
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Title : Episode 2 - Gundams in the Jungle
Writing library : x264 core 84 r1400kGIT 20fa784
Encoding settings : cabac=1 / ref=10 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 / psy_rd=0.8:0.2 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=0 / threads=6 / sliced_threads=0 / nr=0 / decimate=1 / mbaff=0 / constrained_intra=0 / bframes=6 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=1 / wpredb=1 / wpredp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=72 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.40 / pulldown=0 / nal_hrd=0
Language : Japanese
Default : Yes
Forced : No

Audio #1
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AACv2 / HE-AAC / LC
Codec ID : A_AAC
Duration : 24mn 47s
Channel(s) : 2 channels / 1 channel / 1 channel
Channel positions : Front: L R / Front: C / Front: C
Sampling rate : 44.1 KHz / 44.1 KHz / 22.05 KHz
Compression mode : Lossy
Title : English Stereo 2ch AAC
Language : English
Default : Yes
Forced : No

Audio #2
ID : 3
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AACv2 / HE-AAC / LC
Codec ID : A_AAC
Duration : 24mn 47s
Channel(s) : 2 channels / 1 channel / 1 channel
Channel positions : Front: L R / Front: C / Front: C
Sampling rate : 44.1 KHz / 44.1 KHz / 22.05 KHz
Compression mode : Lossy
Title : Japanese Stereo 2ch AAC (1995 Sound Mix)
Language : Japanese
Default : No
Forced : No

Audio #3
ID : 4
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Codec ID : A_AAC
Duration : 24mn 47s
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz / 24.0 KHz
Compression mode : Lossy
Title : Japanese Dolby Surround 5.1ch AAC (2006 Sound Mix)
Language : Japanese
Default : No
Forced : No

Text #1
ID : 5
Format : ASS
Codec ID : S_TEXT/ASS
Codec ID/Info : Advanced Sub Station Alpha
Compression mode : Lossless
Title : English Credits/Karaoke/Signs
Language : English
Default : Yes
Forced : No

Text #2
ID : 6
Format : ASS
Codec ID : S_TEXT/ASS
Codec ID/Info : Advanced Sub Station Alpha
Compression mode : Lossless
Title : English Subtitles
Language : English
Default : No
Forced : No

Text #3
ID : 7
Format : ASS
Codec ID : S_TEXT/ASS
Codec ID/Info : Advanced Sub Station Alpha
Compression mode : Lossless
Title : English Credits/Signs
Language : English
Default : No
Forced : No

Menu
00:00:00.000 : :Opening Credits
00:01:31.138 : :Part 1
00:11:23.358 : :Part 2
00:22:44.563 : :Ending Credits
00:24:15.666 : :Next Episode Preview

My Audio Settings:
Audio Settings

Some notes on this issue:

  • I reset my DB and cleared my PMS.conf before each of these tests.
  • I tried this with both the SB32 and my personally compiled MEncoder and they both presented the same problem.
  • It looks like a problem with the channel mapping as this is the error that I get from MEncoder when I run it by hand:
[target/bin/osx]$ ./mencoder -ss 0 "/Gundam/Gundam 08th MS Team [OZC]/Mobile Suit Gundam - The 08th MS Team Remastered E01 'War for Two' [v2].mkv" -msglevel statusline=2 -channels 6 -ovc copy -of rawaudio -mc 0 -noskip -aid 1 -oac pcm -af channels=6:6:0:0:1:1:2:5:3:2:4:4:5:3 -srate 48000 -o ~/Desktop/test
MEncoder SB32 (C) 2000-2012 MPlayer Team
Custom build by SubJunk, http://www.spirton.com

success: format: 0  data: 0x0 - 0x13dbdf51
libavformat version 54.3.100 (internal)
libavformat file format detected.
[lavf] stream 0: video (h264), -vid 0, Episode 1 - War for Two
[lavf] stream 1: audio (aac), -aid 0, -alang eng, English Stereo 2ch AAC
[lavf] stream 2: audio (aac), -aid 1, -alang jpn, Japanese Stereo 2ch AAC (1995 Sound Mix)
[lavf] stream 3: audio (aac), -aid 2, -alang jpn, Japanese Dolby Surround 5.1ch AAC (2006 Sound Mix)
[lavf] stream 4: subtitle (ass), -sid 0, -slang eng, English Credits/Karaoke/Signs
[lavf] stream 5: subtitle (ass), -sid 1, -slang eng, English Subtitles
[lavf] stream 6: subtitle (ass), -sid 2, -slang eng, English Credits/Signs
VIDEO:  [H264]  720x480  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:44  fourcc:0x34363248  size:720x480  fps:23.976  ftime:=0.0417
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 54.14.100 (internal)
AUDIO: 44100 Hz, 2 ch, s16le, 0.0 kbit/0.00% (ratio: 0->176400)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
Ignoring video stream!
videocodec: framecopy (720x480 0bpp fourcc=34363248)
[channels] Invalid routing in pair nr. 2.
[libaf] Reinitialization did not work, audio filter 'channels' returned error code -2
Error at audio filter chain pre-init!

Exiting...

@Raptor399
Copy link
Member

Because of all the fixes, I suddenly got strange (yet correct) audio and subs combos (e.g. English audio with English subs).

I have modernized the priority defaults in commit 6f6f281 to compensate for this.

@XenoPhex
Copy link
Author

XenoPhex commented Jul 9, 2012

I've updated to 6f6f281 and most things work properly when I run with the following setup (after I killed by DB & conf file):
Starting Audio Setup:
Audio Settings

However, I've encountered three separate issues so far:

  1. I'm still getting those "Unknown number of audio channels" Info messages.
  2. While trying to play an MKV file with 5.1 DTS, I noticed the following:
  • When running with the setting from above, I get LPCM 2.0.
  • When LPCM is checked and DTS is checked, it comes out as LPCM 2.0 (according to PS3) and my Receiver is saying it's getting DTS
  • When LPCM is checked AND DTS is unchecked, it comes out as LPCM 5.1
General
Unique ID : 252508532120654055138373739122812680735 (0xBDF75FD3987C7C4E8BD1E61EA4327A1F)
Complete name : /Patlabar/Patlabor the Movie (1987) [1080p,BluRay,x264,DTS] - THORA.mkv
Format : Matroska
Format version : Version 1
File size : 7.95 GiB
Duration : 1h 39mn
Overall bit rate : 11.5 Mbps
Movie name : Patlabor the Movie (1987)
Encoded date : UTC 2008-09-03 04:31:07
Writing application : mkvmerge v2.2.0 ('Turn It On Again') built on Mar  4 2008 12:58:26
Writing library : libebml v0.7.7 + libmatroska v0.8.1
Attachment : Yes / Yes

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 16 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 1h 39mn
Bit rate : 9 971 Kbps
Width : 1 920 pixels
Height : 1 040 pixels
Display aspect ratio : 1.85:1
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.208
Stream size : 6.74 GiB (85%)
Writing library : x264 core 61 r951M 445d87e
Encoding settings : cabac=1 / ref=16 / deblock=1:-3:-3 / analyse=0x3:0x133 / me=umh / subme=7 / psy_rd=1.0:0.0 / brdo=1 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=2 / deadzone=21,11 / chroma_qp_offset=-2 / threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=16 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=3 / wpredb=1 / bime=1 / keyint=250 / keyint_min=25 / scenecut=40(pre) / rc=2pass / bitrate=9971 / ratetol=1.0 / rceq='blurCplx^(1-qComp)' / qcomp=1.00 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30 / aq=2:0.70
Language : Japanese
Default : Yes
Forced : No

Audio
ID : 2
Format : DTS
Format/Info : Digital Theater Systems
Codec ID : A_DTS
Duration : 1h 39mn
Bit rate mode : Constant
Bit rate : 1 510 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 24 bits
Compression mode : Lossy
Stream size : 1.04 GiB (13%)
Language : Japanese
Default : Yes
Forced : No

Text
ID : 3
Format : ASS
Codec ID : S_TEXT/ASS
Codec ID/Info : Advanced Sub Station Alpha
Compression mode : Lossless
Language : English
Default : Yes
Forced : No
  1. I don't really know how to describe this problem other then it looks like the folder layout keeps getting confused. What I mean by this is, when I open a folder with this sort of structure:
- Folder A
  - Folder AA
  - Folder BB
    - Folder CCC
      - File 1
      - File 2
      - File 3
    - Folder DDD
      - File 4
      - File 5
      - File 6
  - Folder EE

I can make it looks something like this:

- Folder A
  - Folder AA
  - Folder BB
    - Folder CCC
      - File 1
      - File 2
      - File 3
    - Folder DDD
      - File 4
      - File 5
      - File 6
  - Folder EE
  - Folder CCC
  - File 1
  - File 2
  - File 4
  - File 5

or even like this:

- Folder A
  - Folder AA
  - Folder BB
    - Folder CCC
      - Folder DDD
    - Folder DDD
      - File 4
      - File 5
      - File 6
  - Folder EE
- Folder AA
- Folder CCC
- Folder DDD
- Folder EE

I've even seen cases of multiple #TRANSCODE folders in the same directory. I've also seen it lists files for (according to the example above) from DDD in CCC and then after a few seconds refreshes and show the correct files.
Note: My directory structure is about 5 to 6 folders deep in some cases but I can consistantly get this to happen when browsing one or two folders in.

@ikarsokolov
Copy link
Member

When running with the setting from above, I get LPCM 2.0.
When LPCM is checked and DTS is checked, it comes out as LPCM 2.0 (according to PS3) and my Receiver is saying it's getting DTS
When LPCM is checked AND DTS is unchecked, it comes out as LPCM 5.1

This is expected behaviour. See example PMS.conf for explanations:

# ---< Audio settings >-------------------------------------------------------
# PS3 Media Server decides what to do with the audio track by checking options in the following order:
# 1. (AC3 and DTS tracks) Keep DTS track / Keep AC3 track => remuxes track as-is
# 2. (all tracks) Use LPCM transcoding => transcodes track with LPCM transport (lossless)
# 3. (all tracks) Use AC3 transcoding => transcodes track with AC3 transport (lossy)
  1. I'm still getting those "Unknown number of audio channels" Info messages.

I have identified the bug but the "proper" fix requires significant refactoring similar to subtitles' one. Please provide mediainfo's Channel(s) : line for problematic files.

@Raptor399
Copy link
Member

I encountered a problem.

When I play a specific testmovie with "Transcoding Settings > MEncoder > Audio/subtitles language priority" set to "en,off;,", PMS decides to use both MEncoder and tsMuxeR and the PS3 shows a black screen, resulting in an error "Media Server Error: An HTTP error (-2147284704) has occurred.".

When I do the same with "en,en;," as setting, the movie plays correctly with English audio and English subs.

(For reference: in PMS 1.54.0 this movie plays with Japanese audio and no subs, no matter what the setting.)

This is what FFmpeg says in the debug.log:

Seems stream 0 codec frame rate differs from container frame rate: 47.95 (5994/125) -> 23.98 (24000/1001)

Seems stream 1 codec frame rate differs from container frame rate: 47.95 (5994/125) -> 23.98 (24000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/patricka/Movies/test/Zero1-MP4-Feature-Test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2005-11-03 01:29:40
  Duration: 00:00:59.76, start: 0.000000, bitrate: 3142 kb/s
    Chapter #0.0: start 0.000000, end 15.000000
    Metadata:
      title           : Zero1's MP4 Feature Test ~Mobile Suit Gundam - Char's Counter Attack~
    Chapter #0.1: start 15.000000, end 30.000000
    Metadata:
      title           : 15 Seconds
    Chapter #0.2: start 30.000000, end 45.000000
    Metadata:
      title           : 30 Seconds
    Chapter #0.3: start 45.000000, end 59.685000
    Metadata:
      title           : 45 Seconds
    Chapter #0.4: start 59.685000, end 59.768042
    Metadata:
      title           : End of file
    Stream #0:0(jpn): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x480 [SAR 32:27 DAR 704:405], 1256 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Video Handler
    Stream #0:1(jpn): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x480 [SAR 32:27 DAR 704:405], 1241 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Video Handler
    Stream #0:2(eng): Audio: aac (mp4a / 0x6134706D), 32000 Hz, stereo, s16, 96 kb/s
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Audio Handler
    Stream #0:3(jpn): Audio: aac (mp4a / 0x6134706D), 32000 Hz, stereo, s16, 96 kb/s
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Audio Handler
    Stream #0:4(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 5.1, s16, 224 kb/s
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Audio Handler
    Stream #0:5(jpn): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 5.1, s16, 224 kb/s
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Audio Handler
    Stream #0:6(eng): Subtitle: mov_text (tx3g / 0x67337874)
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC Streaming Text Handler
    Stream #0:7(eng): Subtitle: mov_text (tx3g / 0x67337874)
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC Streaming Text Handler
Output #0, h264, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2005-11-03 01:29:40
    encoder         : Lavf53.24.2
    Chapter #0.0: start 0.000000, end 15.000000
    Metadata:
      title           : Zero1's MP4 Feature Test ~Mobile Suit Gundam - Char's Counter Attack~
    Chapter #0.1: start 15.000000, end 30.000000
    Metadata:
      title           : 15 Seconds
    Chapter #0.2: start 30.000000, end 45.000000
    Metadata:
      title           : 30 Seconds
    Chapter #0.3: start 45.000000, end 59.685000
    Metadata:
      title           : 45 Seconds
    Chapter #0.4: start 59.685000, end 59.768042
    Metadata:
      title           : End of file
    Stream #0:0(jpn): Video: h264 (avc1 / 0x31637661), yuv420p, 704x480 [SAR 32:27 DAR 704:405], q=2-31, 1256 kb/s, 23.98 fps, 90k tbn, 23.98 tbc
    Metadata:
      creation_time   : 2005-11-03 01:29:40
      handler_name    : GPAC ISO Video Handler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=    2 fps=  0 q=-1.0 Lsize=      22kB time=00:00:00.08 bitrate=2147.7kbits/s
video:22kB audio:0kB global headers:0kB muxing overhead 0.760337%

@ikarsokolov
Copy link
Member

@Raptor399, can you upload somewhere your test file?

@Raptor399
Copy link
Member

Sure:

http://min.us/m4HVCJ4ZZ

Expires in 30 days.

@ikarsokolov
Copy link
Member

@XenoPhex

Unknown number of audio channels

I hope this bug is fixed now.

@Raptor399

Zero1-MP4-Feature-Test.mp4

With Mencoder engine every combination of subs/audio works. Default [Mencoder] option with autoselected (by priority) tracks works too.
It is worth mentioning that I always keep mencoder_mux_compatible "remux videos with tsmuxer if possible" option disabled (actually we should remove it) and have TsMuxer engine set to highest priority and mencoder next.

@XenoPhex
Copy link
Author

This is expected behaviour. See example PMS.conf for explanations

I understand this, but in this case it's down-mixing a 5.1 stream into a 2.0 stream when you have everything but LPCM selected which is the real issue for me. If the intent of having 'Keep DTS track' is to keep it as it's original form without re-encode, this means it should keep a 5.1 DTS stream as a 5.1 DTS stream and not down-mix it to 2.0 DTS stream.

What I was trying to get at, and I apologize if I was a unclear, was that the only time I was able to get the 5.1 into the system was when I had LPCM checked and DTS unchecked, even though the original stream was a DTS 5.1 stream. Which is what was confusing me if it's purely remuxing and not transcoding. The only reasons, to me at least, this would make sense is if the PS3 doesn't support 2.0 DTS during streaming or if whatever is being used to remux the audio doesn't support 5.1 streams.

I have identified the bug but the "proper" fix requires significant refactoring similar to subtitles' one. Please provide mediainfo's Channel(s) : line for problematic files.

As of d1b0b04 I haven't seen an issue! So you guys must have caught the problem already. If I see it again, I'll try and get the channel information to you. I also see that you guys fixed the folder issue too. Props!

@ikarsokolov
Copy link
Member

If the intent of having 'Keep DTS track' is to keep it as it's original form without re-encode, this means it should keep a 5.1 DTS stream as a 5.1 DTS stream and not down-mix it to 2.0 DTS stream.

It is original DTS just marked as PCM stereo to fool PS3. You should see DTS logo on receiver.

@ExSport
Copy link
Contributor

ExSport commented Jul 11, 2012

@Happy-Neko:
"It is worth mentioning that I always keep mencoder_mux_compatible 'remux videos with tsmuxer if possible' option disabled (actually we should remove it) and have TsMuxer engine set to highest priority and mencoder next."
Only solution how to load forced subtitles when needed is to "enable autoload subs with the same name" and moving MEncoder engine at the top so subs can be burned if needed and when they are not needed and video is H264, file is remuxed. So I supose this "feature" is very useful
When tsMuxeR is at the top in the list, subtitles are totally ignored so if forced subs should be burned, you only see remuxed video without subs. If it is possible to use tsMuxer with the highest priority and if forced subs are detected, PMS will change the engine to MEncoder automatically, it will be best option. For now the only solution how to play forced or normal subs(automatically loaded depending on audio/video preference) without going to #TRANSCODE# folder is moving MEncoder engine to the top:-(
Thx

@ikarsokolov
Copy link
Member

Only solution how to load forced subtitles when needed is to "enable autoload subs with the same name" and moving MEncoder engine at the top so subs can be burned if needed and when they are not needed and video is H264, file is remuxed. So I supose this "feature" is very useful

ps3ms should not try to outsmart user. I'm not a complete idiot and can decide what engine I want to force from TRANSCODE folder and what subtitle/audio track to select. And I expect exactly this engine to be used. mencoder_mux_compatible is ugly and confusing workaround (both user and dev-wise), thats all.

Instead we need to implement better engines/players priority system. Player should "know" what input/output formats it can process and tell PlayerFactory if requested transcoding (or transformation) is not possible. For example tsmuxer cant process h264 with variable framerate or decrease reference frames count and should refuse to do this in favour of next registered engine (for ex. mencoder). Your requirement to force subtitles for non-native languages may be part of this system.

@ExSport
Copy link
Contributor

ExSport commented Jul 11, 2012

I agree with you. But lot of people are only "users" so #TRANSCODE# folder irritates them because they don't understand for what it is used. Also on some renderes alternatives in this folder are cut so you can't see the difference between more combinations listed there(like PanTV etc.)
I think most user friendly is possibility to play movie outside TRANSCODE folder with audio/subs depending on preferences. So file will be streamed, remuxed or transcoded if nedeed-automatically. So if no subs needed, file will be streamed or remuxed but if subs should be played, file will be transcoded(if tsMuxeR will be at top, PMS can't change it to MEncoder engine for now). So I understand that mencoder_mux_compatible is a hack but sometimes it is useful so it should not be removed totally(for now). Only my opinion?

With the second paragraph I totally agree.
My only interrest is to play file in most clever form so it is not transcoded when not needed, transcoded when not compatible or subs should be rendered etc. So changing the priority system is the right way. Hopefully someone will start with it as you started with subs and audio refactoring. Btw. great work I must say. Thanks for it!

@taconaut
Copy link
Contributor

I consider myself being a simple user for the configuration of the transcoding engines. I keep the default settings and use the transcode folder when I need a 'special' combination of encoder/audio/subtitles, as for me it is a lot easier to understand then trying to set up pms to be smart enough to always do what I want by default. I watch most english films without subs, e.g. for True Grit I need subs as I've got no chance to understand a Texan Jeff Bridges.

On the other hand I found following rather confusing (don't know if this is still all true):

  • When checking definitely disable subtitles and choosing a combo with subtitles from the transcode folder, they wont be shown (the entry should either not show up or better, apply the selected subtitles)
  • When checking the switch to TSMuxer when remuxing, it makes no difference if Mencoder or TSMuxer is being played from the transcode folder as it will always fall back to TSMuxer.

Instead we need to implement better engines/players priority system. Player should "know" what input/output formats it can process and tell PlayerFactory if requested transcoding (or transformation) is not possible.

Amen

@ikarsokolov
Copy link
Member

@ExSport

But lot of people are only "users" so #TRANSCODE# folder irritates them because they don't understand for what it is used.

I disagree. There is nothing hard to understand in "Please select audio/subtitle track from menu if you unsatisfied with what plays by default". In fact every DVD player since forever has subtitle/audio selection menus and nobody dies :)

Maybe we can rename #TRANSCODE# to something more friendly like Other languages or Select audio/subs. But manual selection system itself is rock solid and very easy to use out of the box. This is very important. Tinkering with languages priorities is something less than 5% of users will do and I think they'll be technical enough to understand logic behind Transcode folder too.

So changing the priority system is the right way. Hopefully someone will start with it as you started with subs and audio refactoring.

I already have rough idea how this can be done but it'll require significant time. I don't want to start this process until enough free time can be allocated. Also I have to finish audio refactoring first but it is hard to motivate myself when all related obvious bugs are already fixed and the work needs to be done just to avoid leaving another half-finished v2 implementation and code duplication (like parser and reques v1/v2).

@taconaut

When checking the switch to TSMuxer when remuxing, it makes no difference if Mencoder or TSMuxer is being played from the transcode folder as it will always fall back to TSMuxer.

This is true. And this is exact reason why mencoder_mux_compatible must die :)

@ExSport
Copy link
Contributor

ExSport commented Jul 11, 2012

I agree but I suppose others not:-) I everyday read complains how to choose alternative subs or audio tracks and people wrote what the hell is #TRANSCODE# folder:-) Many people are using SB builds which hides this folder so they never saw this folder on renderer. They will only set audio/video priority and voila, everything is working out of the box without browsing to #TRANSCODE# folder (visible or invisible). Only few are using PMS for DVD so choosing titles or chapters is very rare in my opinion.
About the renaming I agree, it is quite confusing folder name:-)
About the configuration of audio/subtitle preferences, I agree. Because of that I made forced subs configuration upon on language used in PMS so also in case it is not set, it uses default values("forced" keyword and language set for PMS interaction is used as native one). For many defining audio/subtitle priority is no go because they don't know the logic so they ignore it which is quite big minus for them.
Hopefully you will find time also for refactoring video engines:-))
Long time I used tsMuxeR engine at the top but with forced subs support I moved MEncoder to the top and enabled this "mencoder_mux_compatible" hack. For now it is only solution how to easily play file as is or with subs if they are required.
tsMuxeR ignores subtitles detected so you need to check TRANSCODE folder if there are some forced subs in the movie and set them from there (via default [MEncoder] or directly choosing right combo).
DivX/XviD/MPEG2 files are not remuxed via tsMuxeR so if subs are detected, PMS automatically loads MEncoder engine for them(outside TRANSCODE folder) so only problem is with MKV files. When I created patch for "forced subs" I also tried to force MEncoder engine instead of tsMuxeR when forced subs are present but failed.
Happy coding Happy-Neko;-)

@taconaut
Copy link
Contributor

When we'll merge with mlx, all folders (also the currently not working transcode folder) can be renamed in the tree

@Raptor399
Copy link
Member

@Happy-Neko

Zero1-MP4-Feature-Test.mp4

With Mencoder engine every combination of subs/audio works. Default [Mencoder] option with autoselected (by priority) tracks works too.
It is worth mentioning that I always keep mencoder_mux_compatible "remux videos with tsmuxer if possible" option disabled (actually we should remove it) and have TsMuxer engine set to highest priority and mencoder next.

Thanks for the tips.

My point was not so much that there isn't a working option combo to get the movie playing.

It was more that PMS 1.54.0 and the latest snapshot react differently in determining their choice of MEncoder vs. MEncoder + tsMuxeR, even with the exact same settings.

I'm not sure that change in behavior was intended?

As for the other discussion: I'm not an expert user at all and I would like to see PMS work great (and intelligent) out of the box with no or minimal configuration, whilst still allowing experts to make their tweaks. A better engine election system (or improved .confs) could definitely help here because we know exactly which engines are best suited for which MediaInfo.

Perhaps we should simply introduce a new getPlayer() like this:

    public static Player getPlayer(final Class<? extends Player> profileClass,
                                     final DLNAMediaInfo mediaInfo) {
             ....
        }

@XenoPhex
Copy link
Author

Maybe we can rename #TRANSCODE# to something more friendly like Other languages or Select audio/subs. But manual selection system itself is rock solid and very easy to use out of the box.

I completely agree, I know a few people that got confused the first time they used this and either stumbled upon the language selection by accident or I had to tell them where to look. So changing it would be a bit friendlier to new users.

Also, while I agree it's a good system to select langauge/subtitles/encoder, I think it could be tweaked by changing the naming scheme it displays. In my 8th MS Team example, here are the names of some of the streams:

[Mencoder] {(Audio: AAC/English (English Stereo 2ch AAC)} {Sub: [Advanced] SubStation Alpha/English (English Credits/Karaoke/Signs)}
[Mencoder] {(Audio: AAC/Japanese (Japanese Stereo 2ch AAC (1995 Sound Mix))} {Sub: [Advanced] SubStation Alpha/English (english subtitles)}
[Mencoder] {(Audio: AAC/Japanese (Japanese Dolby Surround 5.1ch AAC (2006 Sound Mix))} {Sub: [Advanced] SubStation Alpha/English (English Credits/Signs)}

Now 3 different audio streams with 4 different subtitle tracks (include no subs) means that there are at least 12 different selections for MEncoder alone. Now I understand this is an unusual case for a video, not just having this many audio/subtitle tracks, but also having extremely long title names. But it would be nice if these selections could be formatted in a way that was easier to read. Especially since the PS3 has to scroll after the first 1/3 of most of these names. In this case it takes a few seconds to read the entire name for each file and longer to figure out which selection you actually want.

Now I don't know the best way to format the name, especially since in a lot of cases where the 'Title' information (or 'Language, more info' depending on the container) is not set on the track. But if given the choice, I'd say that in most cases, if a track has title information, it's easier to have that ahead of all other information. I'd even go so far as to say that these names should only show the track properties in cases where the title is not set. So in the examples, it would be:

[Mencoder] {Audio: English Stereo 2ch AAC} {Sub: English Credits/Karaoke/Signs}
[Mencoder] {Audio: Japanese Stereo 2ch AAC (1995 Sound Mix)} {Sub: english subtitles}
[Mencoder] {Audio: Japanese Dolby Surround 5.1ch AAC (2006 Sound Mix)} {Sub: English Credits/Signs}

Now in this case, the titles are very descriptive and tell you not only the language, but the stream information as well. But in the case of the Eureka Seven Ao example, it would cause a bit of confusion as the the item to select the japanese audio with english audio would look like this:

[Mencoder] {Audio: 2.0 AAC} {Sub: ass}

So I can't really suggest this as a good idea unless you add an additional option to always show language and/or stream information when you have these selections making the Eureka Seven example look like this:

[Mencoder] {Audio: 2.0 AAC (AAC/Japanese)} {Sub: ass ([Advanced] SubStation Alpha/English)}

But again the problem arises that the name now becomes very long and difficult to read. Maybe the language should be set before the slash and '[Advanced] SubStation Alpha' should be renamed 'ASSA' to reduce some space. Also moving '[Mencoder]' to the end would make things a bit quicker to select since all the MEncoder items are always together, same with tsMuxeR.

I'm yammering at this point. But what I'm getting at is that this section, although easy to use, is a bit of a pain in the ass to read if your titles are a more then a few characters long or if you have a lot of different tracks per file.

@ExSport
Copy link
Contributor

ExSport commented Jul 12, 2012

Better to have max info possible by default. If it is too long for someone, it is possible to shorten it in renderer.conf:
https://github.com/ps3mediaserver/ps3mediaserver/blob/master/src/main/external-resources/renderers/Panasonic.conf#L47
For examlple, track description for subs are very useful but for someone additional audio description is useless. Then feel free to change it in .conf file.
I agree that sometimes the name is very long but you can be happy because PS3 scrolls the text. Other renderers can't do that so you will see 1/3 and that's all so here I will be happy when naming convention in TRANSCODE folder will be somehow changed(shortened) like example(don't remember exact display format right now)
[Mencoder] {Audio: Czech - 2.0 AAC (AAC/Japanese)} {Sub: Czech - Subrip subtitles (forced)}
shortened to:
[M] {A: Czech - 2.0 (AAC/Japanese)} {S: Czech - Subrip (forced)}
Thanks to national flags I am able to find the right one also when text is truncated but it is sometimes try-failure:-)
EDIT:
Have to say when audio/sub priority is correctly set, I miss the TRANSCODE folder in most cases because PMS will play correct one out of the box and if file doesn't work as expected, we have TRANSCODE folder for it:-)

@ikarsokolov
Copy link
Member

#--TRANSCODE--# folder renamed to #- Language and player select -#
I hope this name is more user-friendly.

@Raptor399

Perhaps we should simply introduce a new getPlayer() like this:

Yes, and also add renderer into the mix. Basically engine choice is determined by thee factors:

  • input format
  • output format (ps3ms's config and renderer's config)
  • engine's ability to transform input format into requested output format

@ExSport
Copy link
Contributor

ExSport commented Jul 12, 2012

It is hard to name it somehow to show every possibility but in short format (player, language, chapters, ...)
This one is quite good:-) Or something like "Custom Lang.,Players, Chapters" etc....
EDIT: Maybe it will be good to have possibility to translate it to other languages so it will not be hardcoded?:-)

@Raptor399
Copy link
Member

@Happy-Neko

Perhaps we should simply introduce a new getPlayer() like this:

Yes, and also add renderer into the mix.

Actually, renderers are pretty well covered. Improvement in that section can still be achieved; it means we need to start figuring out "supported" lines for all .confs instead of the lists of extensions that most .confs use.

@ikarsokolov
Copy link
Member

Issue closed because reported bug is fixed.
I have created pull request #63 to discuss transcode folder renaming.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants