Fix for FLAC 24 bit 96 Khz

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

Fix for FLAC 24 bit 96 Khz

Postby rooneyp1976 » Wed Mar 06, 2013 6:20 pm

Hi there,
I got a new amp and wanted to stream 24 bit 96 Khz FLAC's to it using a PS3.
I read that PMS had this behaviour at one time through the 'Audio High Fidelity' engine, but that it has been broken for a while.

How I understood the engine worked was:
1) browse the FLAC files from the PS3 using the Video section (not music)
2) PMS uses TsMuxerAudio as the player.
3) TsMuxerAudio + its parent TSMuxerVideo then:
a) creates a dummy video file using fake.jpg
b) use ffmpeg to extract a WAV/PCM file from the .flac OR use flac.exe if the sample rate is divisible by 48000
c) use tsmuxer to combine the above two files into a .ts stream containing MPEG4/ISO/AVC video and LPCM audio

I had a look at the latest code found there were 2 problems in the code. (https://github.com/ps3mediaserver/ps3mediaserver/)
1) TSMuxerVideo.launchTranscode(...) had the sample rate params in the wrong order ("-ar",rate,)
2) TsMuxerAudio.isCompatible(...) was failing as it was expecting Format.AUDIO instead of Format.VIDEO

I've testing this on windows 7 by running 'mvn clean package', then installing the produced PMS-setup.exe
I can successfully stream 24 bit 96 Khz FLAC files from my PS3 (and also .avi videos from the same directory).
Bringing up info on the steam on the PS3 shows: [Linear PCM 2Ch. 96Khz 4.6 Mbps AVC 5kbps ]

The patch for this is here http://pastebin.com/eRAzeUwR
I'm not sure on how you accept patches???

On a side note, for those interested... I found that the 'Audio High Fidelity' engine does not work for 24bit 88.2 Khz files.
The final step of using tsmuxer.exe fails with "Sample rate 88200 is not supported for LPCM format. Allowed values: 48000, 96000, 192000".
I have no solution for this and am puzzled as the PS3 in its 'Audio Output Settings' allows 88.2 linear PCM...
Controversially :) I got a 24bit 88.2 Khz FLAC file to stream using the Whitebear Media Server & Logitech Media Server. This was using the 'Music' option of XMB on PS3. My amp showed it was receiving 88.2 Khz.

Cheers, Paul
rooneyp1976
 
Posts: 7
Joined: Wed Mar 06, 2013 5:42 pm

Re: Fix for FLAC 24 bit 96 Khz

Postby Raptor399 » Wed Mar 06, 2013 10:38 pm

Thank you for diving into this and submitting a patch!

I don't understand the patch entirely.
Changing the order of the "-ar" parameter seems harmless enough.

But I don't understand why TSMuxerAudio should be converted into a covert substitute for TSMuxerVideo. I would rather have audio work as audio and video as video, if you catch my drift.
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Fix for FLAC 24 bit 96 Khz

Postby rooneyp1976 » Wed Mar 06, 2013 11:42 pm

hey,

My understanding of this is that TSMuxerAudio was designed to exploit a 'feature' of the PS3.
The PS3 seems unwilling to play high bit/sample rate audio files from the Music section of the XMB. This appears to be the case when reading from USB, local disk or DLNA streaming. (Though somehow Whitebear media server has solved it...)

But the PS3 will play very high bit/sample rate audio files if they are present within a Video file/stream accessible through the Video section on the XMB.

On to the code...

TSMuxerAudio and TSMuxerVideo are 2 separately registered players. They are chosen to handle a file based on their return value from a method called isCompatible(DLNAFileToServe)
I believe I have reinstated the original behaviour of TSMuxerAudio, by now accepting a file Format.Type of VIDEO. (There is an additional subsequent check where the Format.Identifier must also match AUDIO_AS_VIDEO )

It inherits the transcoding method of TSMuxerVideo, but this method has an instanceof check to see if it is being run as TSMuxerVideo or TSMuxerAudio object instance. (This really should use polymorphism)

Normally when TSMuxerVideo object instance is handing a Video file, during the transcoding method-call will it performs some ffmpeg operation to manipulate the video track already present in the requested file.
But when the TSMuxerAudio instance is handling a file, the inherited transcode method detects it is being ran from TSMuxerAudio instance, and then creates a dummy video file/track by using ffmpeg and a fake.jpg.

Thus you get a TS stream delivered to the PS3 containing a black/blank video track and a 'High Fidelity Audio' LPCM track.

IMHO it was a 'creative' hack by the original author :)
rooneyp1976
 
Posts: 7
Joined: Wed Mar 06, 2013 5:42 pm

Re: Fix for FLAC 24 bit 96 Khz

Postby Raptor399 » Thu Mar 07, 2013 8:09 pm

Thanks for the explanation, I wasn't aware of this! :-D
Raptor399
Project Member
 
Posts: 1916
Joined: Thu Mar 10, 2011 12:06 am

Re: Fix for FLAC 24 bit 96 Khz

Postby speedxl » Sun Mar 10, 2013 6:59 am

Hi rooneyp1976, can you share your build with the fix please? I want to stream Hd flac files, and I got them working once but they are not working anymore, do you think it will be possible to stream flac files with a Sample rate of 88200, maybe with a new tsmuxer that removes that restriction? thank you in advance.
speedxl
 
Posts: 11
Joined: Thu Sep 03, 2009 4:48 am

Re: Fix for FLAC 24 bit 96 Khz

Postby ExSport » Sun Mar 10, 2013 1:32 pm

tsMuxeR development was closed many years ago and source code is not available so don't wait for any update for it.
ExSport
 
Posts: 2161
Joined: Mon Jan 19, 2009 5:40 pm

Re: Fix for FLAC 24 bit 96 Khz

Postby rooneyp1976 » Sun Mar 10, 2013 3:09 pm

Hi speedxl,

I guess I could upload the windows installer I built to some file hosting service. (I hope this is ok with Raptor399 and co?) If no objections, I'll upload later today.

If you want to get 88.2 files working in a bit perfect way, A good place to start could be finding an alternative to tsMuxer.
To test it out, you can run the commands manually that PMS runs. Here they are:

C:\Dev\Code\ps3mediaserver_git\target\bin\win32\ffmpeg.exe -t 307.0 -loop 1 -i C:\Users\paul\AppData\Local\Temp\ps3mediaserver/fake.jpg -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -me_range 4 -f h264 -vcodec libx264 -an -y c:\Foo\fakevideo.bin

C:\Dev\Code\ps3mediaserver_git\target\bin\win32\ffmpeg.exe -i "C:\Music\some_music_file.flac" -ar 88200 -f wav -acodec pcm_s24le -y c:\Foo\mlpaudio.wav

C:\Dev\Code\ps3mediaserver_git\target\bin\win32\tsMuxeR.exe c:\Foo\pms-tsmuxer.meta c:\Foo\tsmuxerout.ts

pms-tsmuxer.meta contains:
MUXOPT --no-pcr-on-video-pid --new-audio-pes --no-asyncio --vbr --vbv-len=500
V_MPEG4/ISO/AVC, "c:\Foo\fakevideo.bin", track=224
A_LPCM, "c:\Foo\mlpaudio.wav", track=2

Notes:
* When tsmuxer is ran above I get the error: "Sample rate 88200 is not supported for LPCM format. Allowed values: 48000, 96000, 192000".
* fake.jpg can be gotten from https://github.com/ps3mediaserver/ps3me ... s/fake.jpg
* ffmpeg.exe and tsmuxer.exe can be gotten from http://ps3mediaserver.googlecode.com/sv ... ver/win32/
* if you get a .ts file created somehow, vlc should be able to open it and also display media information from it
Last edited by rooneyp1976 on Sun Mar 10, 2013 11:21 pm, edited 1 time in total.
rooneyp1976
 
Posts: 7
Joined: Wed Mar 06, 2013 5:42 pm

Re: Fix for FLAC 24 bit 96 Khz

Postby rooneyp1976 » Sun Mar 10, 2013 6:39 pm

I uploaded an installer based on my build to http://www.fileswap.com/dl/3eQpddPoYY/
This was from head of https://github.com/ps3mediaserver/ps3mediaserver/ (b0ff6b2b2d5c880e4738a97a1fa02ad139a3bab7) from ‎06 ‎March ‎2013
with patch applied is http://pastebin.com/eRAzeUwR
rooneyp1976
 
Posts: 7
Joined: Wed Mar 06, 2013 5:42 pm

Re: Fix for FLAC 24 bit 96 Khz

Postby speedxl » Fri Mar 15, 2013 2:02 am

Thank you so much rooneyp, :)

I hope hd audio playback streaming, via video tab of PS3, gets developed further.
Well maybe someday.
speedxl
 
Posts: 11
Joined: Thu Sep 03, 2009 4:48 am

Re: Fix for FLAC 24 bit 96 Khz

Postby speedxl » Fri Mar 15, 2013 3:13 am

Sadly, I have an error using the fixed build when I try to playback an Hd Flac file, here is my log. http://pastebin.com/0qWXm644y
Could it be java related?
speedxl
 
Posts: 11
Joined: Thu Sep 03, 2009 4:48 am

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 4 guests