Sunday, May 5, 2013

Setting up Ubuntu as a Media Server for Xbox and Android Devices

Recently we cut the cord with cable, relying solely on the internet for our entertainment. The reasons were many but not going deeper in the financial hole each month was a strong motivator. Also, our Wii system broke so we needed a replacement media console for Netflix and Hulu. My son wanted an Xbox we decided to go down that path.

The Xbox is a beefier gaming console and now that Zack is older, he wants to play more of the shoot-em-up games which the Wii doesn't support well. The Wii also does poorly with flight simulators, which Zack loves, so I decided to bite the bullet and spend the $300 for a new system.

I was pleasantly surprised to find a pretty sweet deal on new Xboxs. You can get one with 256 GB of memory for $99 if you sign up for 2 years of Xbox live. Since I was going to need the live account anyway, it seemed like a pretty cheap entry point.

What we had:
AT&T cable with a 12 MB internet pipe and phone, Netflix, Hulu, Amazon ~ $200/month

What we have now
25 MB internet pipe, phone, Netflix, Hulu, Xbox Live ~ $80/month

So we're saving around $120 a month. Over a year that adds up.

Before I start on the technical details I have to add a caveat: the wife isn't happy with the number of steps it takes to watch her shows. Some of them I have to find on either Amazon, Hulu, or Neflix. Others I find them on YouTube or other media sources. Still, we only watch a few shows each week so I don't consider this a burden. I think my wife feels differently.

Also, if you aren't going to use your PC as a media server that plays content you've stored there, then you really don't need to read much of this article. Everything I've listed above is well documented and pretty easy to set up. If, however, you want to use your computer as a way to serve up music, photos, and videos then read on.

Also, this is one area where windows is probably a better solution than Ubuntu. I have Ubuntu doing well but the Xbox is a Microsoft product and thus integrates with Microsoft windows really well. I've read more than one post stating people basically gave up and bought a cheap computer to sit next to their gaming console.

So, for you Ubuntu and Mac users, read on.

Recommendations:
  • This assumes you already have a broadband internet connection. Most plans these days will do but the ideal size of your internet pipe depends on how many machines you're going to connect. 12 MB download speed should be sufficient for anything. 
  • For the best experience, I suggest an HDTV using an HDMI cable for connection between the Xbox and the TV. 
Details
  1. Go to the $99 Xbox page - you'll have to sign up for an Xbox Live account for $15 a month then take the coupon to one of the participating stores (Microsoft, Best Buy, GameStop, Toys R Us, or Walmart) to redeem the coupon. You'll have a choice between a larger disk drive and a Kinex system. I recommend more drive space since the 4GB that comes with the Kinex isn't enough to store much.
  2. Purchase your system and install it at home. I would leave it outside of any cabinet, this system runs a hot.
  3. Set up your Amazon, Hulu, and Netflix accounts - its fairly simple. ( you can stop here if you aren't setting up your PC as a media server)
  4. Go to the PS3 Media Server Download page. You'll find links for Windows, Mac, and Linux. 
  5. For Linux, you'll see a pms-generic-linux-unix*.tgz file. Download this and extract the contents to a directory of your choosing.
  6. You have a choice of running the server by hand or setting it up as some sort of service. I still run it by hand but created a script on my desktop to run it. To run it the first time open a terminal window, cd to your extract director and run ./PMS.sh. You should see the window below. 
  7. You'll need to go to the Navigation/Share Settings tab and tell the PS3 Media Server what directories it can access.
  8. Add your Video, Picture, and Music directories here.
  9. I've found the transcoding video media streams doesn't seem to work well from PMS. My devices time out before my POC computer can serve the first of the stream. My advice is to only stream videos your device (Xbox or Android) that they can consume natively. Therefore, go to the transcoding tab and add mp4 and mpv to the 'skip transcode' box. 
  10. I'm not sure if this is needed but I would Quit the PMS and then start it back up again. 
  11. Now go to your Xbox and access the System Media Player under TV and Video. You should see your PMS server available. Now navigate to your content and enjoy!
Diving Deeper

Now for some of the fiddly bits. The MKV format is popular for downloadable internet content but Xbox doesn't support it and, if I read the Xbox support site correctly, they have no intention of supporting it.  A product called HandBrake solves the problem.

With HandBrake I can convert the mkv files into mp4 format which the Xbox reads well. To install on Ubuntu run the following commands in a terminal window
sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get update
sudo apt-get install handbrake-gtk
This link talks about handbrake no longer supporting xbox and ps3 but other say it does
I installed it and created a m4v format ( basically an mp4 with apple compatibility crap) and it worked fine.

Other media streamers I've experimented with are MediaTomb and minidlna. Both are available from the Ubuntu store (for free) and both work well on my Android device. Xbox won't even see MediaTomb, however and minidlna sort of works for music.

For minidlna, you'll want to follow the config instructions at https://help.ubuntu.com/community/MiniDLNA
On extra thing I needed to do was manually create the /var/cache/minidlna directory then grant global permissions to is since it's used by everyone. The commands are
mkdir /var/cache/minidlna
chmod a+rw /var/cache/minidlna
Android

So this is one of those happy finds. I wanted a way to stream my PS3 Media Server to my phone. I found a package called Skifta available from the Google Play and Amazon store. Not only does it let me watch files served from any of the media servers I've listed in the article, it also share my phones media to anyone on my local network. So now I can watch movies on my phone on my Xbox. I use it on both my Kindle and Samsung.

I'm still experimenting with mkv formats on android. The best option so far seems to be creating either an mp4 or avi out of the mkv. A product called avidemux solves the problem. Just select the file type of either avi or mp4 when saving. It takes a while. After that you have video content your android can read.

I'm not happy that avidemux can't create mp4s or avis that xbox can read. I'm sure with a little more digging I could find the proper settings but this will do for now.

Good luck and happy viewing. 

Links

PS3 Media Server - http://www.ps3mediaserver.org/


No comments: