XBOX 360 5.1 Support

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

XBOX 360 5.1 Support

Postby whitefrt » Sun Feb 21, 2010 4:01 pm

Hey all,

Currently the X360 renderer is forcing transcoding audio to WMA2 (with WMV video) which does not support multi-channel audio and therefore everything being transcoded will be stereo only. WMA-PRO which is supported by the X360 supports multi-channel audio and has recently been reversed-engineered (can be decoded using ffmpeg since sep09) but unfortunately ffmpeg does not yet support encoding WMA-PRO (and I'm guessing it's a low priority) so until this is supported I thought about trying other formats.

Recently the DivX labs extension to Windows Media Center (Windows 7 only) added support for MKV + AC3 (no DTS) which can also be played on the X360 without full transcoding (blazing fast, it is hardware accelerated - CPU is at 1% while playing 720p MKV) I'm not sure what they are doing there but apparently if you convert your MKVs from DTS to AC3 you can play MKVs with 5.1 audio on the X360, the video quality seems to be lower which makes me believe they might be converting to MPEG-4 + AC3 and thus the lower video bitrate.

According to http://blogs.msdn.com/xboxteam/default.aspx the only valid combination (except WMA-PRO) for using multi-channel audio on the X360 is AVI: MPEG-4 Part 2 + AC3 (dolby), the bitrate is lower and the movies will have to be scaled down but it should work.

I changed MEncoderVideo.java to use vcodec="MPEG4" and the acodec to be AC3 which is supposed to be a valid combination for the X360, I then had the mime type be sent as "video/avi" but no matter what the X360 reports that the file type is not supported, forcing the channels to 2 does not work either.
Trying to use AviSynth/FFMPEG which is encoding using "mpeg2video" and AC3 also doesn't work so I figured I'll ask here.

Does anyone know what other combinations can be used on the X360 except WMV+WMA2? The X360 seems to refuse all other combinations and does not seem to care what is the mime type as long as the video is WMV encoded.

I also might be missing something so if anyone can tell me what else needs to be changed in ps3mediaplayer to have it transcode to MPEG-4 and AC3 (with muti-channel) it would be very helpful.. so far looking at the command line ps3mediaserver uses to call mencoder it seems like what I did should work but it doesn't :)

Thanks!
whitefrt
 
Posts: 18
Joined: Wed Jul 29, 2009 7:22 am

Re: XBOX 360 5.1 Support

Postby shagrath » Sun Feb 21, 2010 4:15 pm

To my knowledge, AVI is not a streamable container. But if they managed to successfully transcode to mpeg4/ac3 in real time, maybe there's a trick I don't know.
Could be interesting to sniff the actual network conversation between the xbox and windows media center 7 :)
shagrath
Project Lead
 
Posts: 2668
Joined: Wed Jan 14, 2009 1:39 pm

Re: XBOX 360 5.1 Support

Postby pup99 » Tue Feb 23, 2010 8:01 pm

on a related note shagrath and other 360 users will be very interested in this perhaps.

roozhou just updated his patched ffmpeg tool to allow ref frame changing through a simple and quick copy the datastream to another container and changing/modify several SPS in H264 bitstream flags in the process.

perhaps you happen to have an HD1080P.avc.MP4 or .mkv encoded with several out of spec , some might say crazy ;) greater than level4.1 ref=3 10Mbit/s AVC content that your device cant play , simply Because of these oddly chosen settings.

then roozhou's patched ffmpeg will allow you to simply copy the original file and change these bad original settings to something far more reasonable for your device to at least stand a chance of playing it , such as the 360 not playing better than 10Mbit/s ref=3 AVC MP4 files smoothly for instance.

ffmpeg -i infile -vcodec copy -acodec copy -vbsf h264_changesps=ref=3 outfile.mp4 should probably work for instance,and far,far better and quicker than a full time consuming video encode like you needed to do before this.

perhaps you can make use of it and even include it into the psm and add some more options to do stacked pre-encoding from a new internal web page for anything that doesnt fit right now too...

on the fly re-transcoding is good if you have the PC speed for realtime , but re-encoding a selection of known content from something your (360) device wont directly stream for those that dont care for speed, and just want to stack them up a few hours before or overnight to play later, could love such a simple select them and set it off pre-encoding.mp4 or whatever feature too.

http://forum.doom9.org/showthread.php?t=152419
"New tool to change SAR in H264 bitstream

--------------------------------------------------------------------------------

I write a bitstream filter for ffmpeg. It can modify sps in H264 bitstream. So far it can change sar, fps, crop information, level, ref frames and cfr/vfr flag. Since the length of bitstream may be changed, I cannot make an in-place modifier.

ffmpeg svn21997
Download from sf (win32 only, source code included)
http://sourceforge.net/projects/direct2 ... z/download

Note this is a demuxer/muxer only ffmpeg build.

cmdline:

ffmpeg -i infile -vcodec copy -acodec copy -vbsf h264_changesps=arg1[/arg2[/arg3]] outfile

args can be:
sar=x:y ---- set sar to x:y, 0:0 will remove sar info
fps=x:y ---- set fps to x/y in cfr mode or set timebase to y/x in vfr mode
level=x ---- set level to x. (e.g. 30 for L3.0, 41 for L4.1)
crop=x:y ---- crop x pixels from right and y pixels from bottom (e.g. 1920x1080 should use crop=0:8)
ref=x ---- set number of reference frames to x
cfr ---- set fps mode to cfr
vfr ---- set fps mode to vfr

multiple args should be separated by /

Output format is determined by extension.
Supported input container: mp4, mkv, flv
Supported output container: mp4, mkv, flv, raw(with -vbsf h264_mp4toannexb)
raw -> raw is also supported

--------------------------------------------------------------------------------
Last edited by roozhou; Today at 16:14. "
Last edited by pup99 on Tue Feb 23, 2010 8:54 pm, edited 3 times in total.
pup99
 
Posts: 40
Joined: Sat Jul 18, 2009 9:21 pm

Re: XBOX 360 5.1 Support

Postby pup99 » Tue Feb 23, 2010 8:32 pm

shagrath wrote:To my knowledge, AVI is not a streamable container. But if they managed to successfully transcode to mpeg4/ac3 in real time, maybe there's a trick I don't know.
Could be interesting to sniff the actual network conversation between the xbox and windows media center 7 :)


er yes it is for the 360, you get loads of mpeg4 part2 (aka divx/xvid)
Audio
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
avi for 360 to play directly without transcoding or other processing with ps3ms,infact thats the one CONTAINER format other than 1080HDAVC.MP4 the 360 plays good streamed over ps3ms.
Last edited by pup99 on Tue Feb 23, 2010 8:35 pm, edited 1 time in total.
pup99
 
Posts: 40
Joined: Sat Jul 18, 2009 9:21 pm

Re: XBOX 360 5.1 Support

Postby shagrath » Tue Feb 23, 2010 8:34 pm

streamable aka playable without knowing the end. I don't think that's the case with AVI files (metadata are stored at the end of the file)
shagrath
Project Lead
 
Posts: 2668
Joined: Wed Jan 14, 2009 1:39 pm

Re: XBOX 360 5.1 Support

Postby shagrath » Tue Feb 23, 2010 8:35 pm

tweak the AnnexB header is a good idea but I'm not sure changing ref frames number will work. This gives me an idea about a totally other issue though, thanks for the link :p
shagrath
Project Lead
 
Posts: 2668
Joined: Wed Jan 14, 2009 1:39 pm

Re: XBOX 360 5.1 Support

Postby pup99 » Tue Feb 23, 2010 8:37 pm

ohh you mean avi realtime transcoded, just like mp4 cant be transcoded over the multicast pipe...

as in you can stream them but ONLY after you have the full file on disk somewere.
Last edited by pup99 on Tue Feb 23, 2010 8:40 pm, edited 1 time in total.
pup99
 
Posts: 40
Joined: Sat Jul 18, 2009 9:21 pm

Re: XBOX 360 5.1 Support

Postby shagrath » Tue Feb 23, 2010 8:40 pm

pup99 wrote:ohh you mean avi realtime transcoded, just like mp4 cant be transcoded over the multicast pipe...


exactly. To my knowledge, wmv is the only "streamable/transcodable" format compatible on the xbox
shagrath
Project Lead
 
Posts: 2668
Joined: Wed Jan 14, 2009 1:39 pm

Re: XBOX 360 5.1 Support

Postby pup99 » Tue Feb 23, 2010 9:12 pm

shagrath wrote:tweak the AnnexB header is a good idea but I'm not sure changing ref frames number will work. This gives me an idea about a totally other issue though, thanks for the link :p


your thinking it might solve that that boring Bravia firmware bug to con it and force it's internal demuxer etc to a real 16:9 aspect ratio :geek:
,or something far more interesting :D

with a quick look i cant find anything interesting on the 360 http://labs.divx.com/forum/290 threads about how they do their successfully transcode to mpeg4-part2/ac3 in real time trick yet.

but if it can be done for avi, perhaps it can be also done for mp4 too :)

im wondering if it might be related to http://multimedia.cx/eggs/improving-qt-faststart/ and his qt-faststart trick for moving the data to the begining of the file for mp4 containers, but again im no so advanced in programming that i can see how you'd get the reqired data to add to the transcoded start data packets from the original file in the first place, perhaps you can work something out ?

ohh OT perhaps but how might i make ps3ms parse these web streams and select and push any stream to ps3,s's input... http://www.veetle.com/frameworked/index ... lar/grid/0

they stream a lot of good stuff and use VLC as their engine, well werth a visit and some time to watch pot luck in good quality usually.

you dont like VLC i know ;) but apparently its in feature freeze right now, and getting some needed bug fixes attention, like changing the crazy long standing default level 5.1 :roll: setting for TS streams etc to something far better and more device generic like L4.1, or even better finally using the auto level and other good features directly from libx264 for selecting the right level etc for a given input file sometime soon....
pup99
 
Posts: 40
Joined: Sat Jul 18, 2009 9:21 pm

Re: XBOX 360 5.1 Support

Postby whitefrt » Wed Feb 24, 2010 9:23 am

I sniffed out the conversation between MediaCenter7 and the X360, they are using the RTP protocol which is more flexible in terms of mix and matching formats - the actual data being sent is mpeg4-AVC (x264) / wma-pro so no big surprises there, the raw data even contains:

"#..x264 - core 68 r1183M f21daff - H.264/MPEG-4 AVC codec - Copyleft 2003-2009 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:-3:-3 analyse=0x3:0x113 me=umh subme=9 psy_rd=0.9:0.8 mixed_ref=1 me_range=32 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 chroma_qp_offset=-4 threads=6 nr=0 decimate=1 mbaff=0 bframes=3 b_pyramid=1 b_adapt=1 b_bias=0 direct=3 wpredb=1 keyint=250 keyint_min=25 scenecut=40 rc=2pass bitrate=6551 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 cplxblur=20.0 qblur=0.5 vbv_maxrate=50000 vbv_bufsize=50000 ip_ratio=1.40 pb_ratio=1.30 aq=1:1.00"

The exact involvement of VLC is yet unknown to me (perhaps the DivX AVC implementation is using the opensource videolan x264 encoder) which is odd as I have verified that the DivX encoder indeed passes data to a second hardware accelerated encoder when applicable.

Actual response from MC7 to RTP's SETUP command packet requested by the X360 is:
audio:
m=audio 0 RTP/AVPF 96
b=AS:129
a=rtpmap:96 wma/1000/2
a=fmtp:96 version=STD;profile=2;samplesize=16;samplerate=48000;blocksize=2731;bitrate=128016;preroll=1000;config=008800000f0000000000
a=predecbufsize.dlna.org:16002
a=rtcp-fb:96 nack
a=trans-rate-adapt.dlna.org:1
a=lang:en-us
a=mid:1
a=control:audio

video:
m=video 0 RTP/AVPF 97
b=AS:7957
a=rtpmap:97 x-wmf-pf/1000
a=fmtp:97 video/vnd.avi;codec="H264";config=73646976-0000-0010-8000-00AA00389B71/0/1/2764800/F72A76A0-EB0A-11D0-ACE4-0000C0CC16BA/00000000000000000000000000000000000000000000000000000000000000009969790000000000a45d0600000000000000000000000000100000000900000000000000000000002800000000050000d0020000010000004832363400302a0000000000000000000000000000000000;extsys=C6BD9450-867F-4907-83A3-C77921B733AD/2
a=predecbufsize.dlna.org:2983833
a=rtcp-fb:97 nack
a=trans-rate-adapt.dlna.org:1
a=lang:en-us
a=mid:2
a=control:video

Again same as above, the good news however is that I think I have a solution and hopefully my implementation will work, it's going to be a C++ external DLL (or an executable that will send PMS data via pipes) as java is not suitable for handling media foundation interface objects natively (and I'm a C++ coder, not a big java fan..) - hopefully integration with PMS won't be too painful. Will hopefully have something soon as free time permits :)
whitefrt
 
Posts: 18
Joined: Wed Jul 29, 2009 7:22 am

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 1 guest