Wednesday, December 29, 2010

PS3 Media Server streaming & transcoding to XBMC for Xbox

PS3 Media Server is an interesting alternative to VLC streaming, as it allows you better control over the media being played, it does allow you to choose what to play and even to navigate the stream, although it won’t allow you to navigate transcoded streams.

Again, this guide is meant to be more of a playground test showing how to get it working with XBMC, this must be the second time I tried it and I know it can be frustrating due to the number of options you need to change to make it work for XBMC for Xbox.
This is what I’ve used:

PS3 Media Server

The software comes with a configuration file to support XBMC, in which I’ve changed a few settings to better suit XBMC for Xbox. Edit “%ProgramFiles%\PS3 Media Server\renderers\xbmc.conf” (or %ProgramFiles(x86)% if you have an x64 OS) and change the following options:
  • MaxVideoWidth=720 
  • MaxVideoHeight=576
  • TranscodeExtensions=mp4
  • StreamExtensions=mkv,hdmov,hdm,flac,fla,dts,ogg,asf,asx,m2v,avi
MaxVideoWidth/Height allow to configure the size of the transcoded (output) video, again these values are not set in stone, change to suit your case, just like VLC streaming, go as high as XBMC4Xbox can play and probably (unlike I did) use resolutions that match your display and the source video – e.g. for a 720p display (1280x720) the screen has a 1.77 ratio, in my defence it was late and tired and copied the wrong settings from a website Smile 720x576 is the usual PAL resolution, but that’s a 1.25 ratio. Anyways, I’m not going to redo all the screenshots and everything so I’ll leave that to you as homework.

Next I chose to always transcode the .mp4 extension by adding it to the TranscodeExtensions (that will make the video appear in the list on XBMC side ready to be played transcoded, rather than go into the #TRANSCODE# menu, thought I show case it in here). I’v also added the avi extensions to the StreamExtensions that way you can play it (and navigate the stream) from XBMC. As I mentioned earlier you cannot navigate an MEncoder transcoded stream (I believe PS3 Media Server has a note on that somewhere).

Now you can proceed at starting PS3 Media Server and start the configuration in the GUI interface. You can change a few more settings that I will mention, but I will keep it at minimum for brevity sake.
Add your media folders into the Navigation/Share Settings tab. If you don’t it will share all disks on your machine – I just added one folder for this test where I have the test video.

In Transcoding tab, I’ve changed a few things like the maximum buffer size (reduced it from 400 MB to 100 MB, might be a default of 10% percentage of the total memory), as I found when transcoding it will try to transcode as much as possible, you will notice the CPU usage of mencoder.exe while it fills the buffer at first and when the buffer starts to get empty – reducing the overall size allows to brake down the workload in smaller and regular chunks; it’s your choice really if you leave it with the default buffer.

The number of cores is defaulted in there, I didn’t change it (in my case two cores), you get to use both of them in the next screen.

Video quality section is a drop down and you get to choose the best setting for your system – obviously better quality comes with more processing power required and larger amounts of data to be transferred to the client, play with those to find your best settings.

Move to the next entry on the left, MEncoder and make some more configurations, mainly to uncheck the “Switch to txMuxer when H264 video is PS3 compatible” – since I’m streaming a H264 video this setting is appropriate for PS3 as it streams the video as it is obviously for better quality, but in our case here the video data / resolution is too much for Xbox so we’ll need to uncheck it.

I left the “Enhanced multicore support for H264 HD content…” unchecked although I do have two cores I noticed that one handles the transcoding just fine and didn’t want to overwork the laptop. Feel free to use if you want, seems to work just fine.

Now configuration completed you can restart PS3 Media Server (I’ve no idea whether pushing the Restart HTTP server button at the top is enough, personally I’ve restarted the software by closing it using the green play button in the icon tray area and restart it. I actually had to do that a few times and even logoff / restart XBMC4Xbox a few times to get the two seeing each other while making the configuration trial changes.

Useful tips:

I will mention here a few things that might come in handy. If you find that MEncoder.exe will crash while transcoding the video, you might notice that you can still navigate the uPnP shares from XBMC as they might be cached, but you might need to restart PS3 Media Server to get it accessible again. Since it’s a java application I’ve noticed that sometimes when quitting the app it still leaves the java.exe (1 or even 2 at times) behind. You should either wait for those to clear or kill them before starting the application again. If you don’t do that you will not be able to see the PS3 Media Server in XBMC although from your point everything seem to be up and running.

Use Process Explorer to look for the the java.exe process or kill it (make sure you check the startup directory so you don’t kill some other java apps you might have running on your PC), see screenshot below. Once cleared start PS3 Media Server again.

XBMC configuration

PS3 Media Server is a uPnP server so you will need to add a uPnP source. Go to Videos > Files and use the context menu to Add a source.

Now with the new source configured you can navigate it just like any other local or SMB source. You will notice though that besides the video files you will have additional folder entries where you can change settings on the server side (didn’t do much of those) or choose to play the original video or the transcoded version.

Notice that since I’ve added the MP4 extension to the TranscodedExtensions list in XBMC.conf it won’t display the original MP4 video (which although would play on XBMC will play very slowly), but the transcoded version of it. Otherwise you would have to enter the #—TRANSCODE--# folder and play from there.

Before moving to the play screenshots I will mention that when you start navigating the PS3 Media Server contents it will show the XBMC client is connected:

and when playing the transcoded contents the buffer starts to fill and the CPU usage will go up when mencoder.exe starts doing the business. As I mentioned earlier the CPU usage will go down when the buffer gets filled and then it will go up again at times to keep the buffer full.

Here are some XBMC screenshots while playing the transcoded stream – some shots are in 640x360 and some in 720x576 as I was playing with things, notice the video info in the top area as well as the CPU and memory usage (debug mode).

VLC streaming & transcoding to XBMC for Xbox

Some people have asked for a quick guide on how to stream / transcode from VLC (Windows) to XBMC for Xbox so here it is – this is not meant to be the guide, but more of a playground test from where anyone can take off.

This is what I’ve used:
  • XBMC4Xbox 3.0 beta2 r30758 running in 720p;
  • VLC Windows v1.1.5;
  • Home (2009) documentary – video H264 MPEG4-AVC, 1280x720, 24fps (avc1); audio MPEG AAC (mp4a), stereo, 44.1 KHz (as reported by VLC);
  • Dell Vostro 1520 running Windows 7 Professional x64.

VLC setup / configuration

VLC > Media > Streaming… > File (tab>)

I went for HTTP streaming cause it’s easier – select HTTP and click the Add button. That will allow you to configure the port and the URL – those will go into a .strm file that you will be playing in XBMC.

In my case the contents will be accessible from http://vostro:8080/stream (as you’ve guessed already Vostro is the name of my laptop); the port 8080 is offered by default and you can use it provided that you don’t have another application using it, in which case you will have to change it; the stream part is my choice.

In the lower section tick Activate Transcoding and you can choose one of the predefined profiles and customize it, or you can create a new one using the “Create new profile” button (3rd button). I chose to create my own profile and went to use WMV. Some profiles will require additional codecs that will be used for encoding the new stream, but I didn’t go into playing with those too much, I’ll leave that to you; I went for WMV cause it was the easy choice.

“Keep original video track” is unchecked cause otherwise it will stream the original contents. You can configure the bitrate and the frames per second – think of bitrate as the amount of data used to draw the picture, the more data the better the picture, but in the same time the more to transfer over the network (think of wireless here) and more data to decode on the client (more CPU required), so don’t go too high or too low, play with it to find a compromise between picture quality, network and CPU performance. It is in kb/sec which is common in communications but most people think in KB/sec so divide that by 8 to get some real sense of the amount of data.

The scale / sizing part controls the size of the output – in my case, the input is a 1280x720 video so scaling the output at 0.6 will result in a 768x432 video stream.

On the audio tab I went for WMA although you can probably also keep the original audio stream untouched (not transcoded), your choice.

I didn't play with subtitles, so go ahead and save the profile. Now back to streaming dialogs, tick the box to Activate Transcoding and select your new profile (or whatever profile you chose to go with) and click Next.

The final screen shows you the options you just configured earlier, where you can customize them or even paste them if you already have them prepared – it’s the same options you can find in the VLC wiki pages.

That’s it, press Stream to start streaming / transcoding. You will be controlling the stream from your PC, pausing, navigating, sound level etc.

XBMC side

You will now create a .strm file to point to the machine that we just configured and ran VLC – in my case this is http://vostro:8080/stream, where vostro is the name of the PC and the port and the stream part configured earlier. Transfer the .strm file to your Xbox and play it.

As mentioned earlier you won’t be able to navigate the stream from your XBMC because the video is one continuous stream that’s served from your PC; navigation is done on the VLC “server” side.

Here are some screenshots from the XBMC playing the stream, one with the settings above and one with a slightly larger size with the debug enabled to see how it handles it (notice the top side details).

Tuesday, December 7, 2010

How to find your Windows installation date

To find my Windows installation date I usually looked at C:\WINDOWS creation date, but right now that seems a bit older than I remember...

A more reliable way is to ask Windows about it and that is through System Info tool, filtering for "install date".

Start a command line (cmd.exe) and type:

systeminfo | find /i "install date"