PS3 GameOS

From MythTV Official Wiki
Jump to: navigation, search

Ps3.png This page describes my efforts to get my Playstation 3 console to work with mythtv, using the GameOS.

This Document Is Now Out Of Date

With the release of Mythtv 0.20.2 on the 24th of August, Mythtv's built in uPNP server will now work flawlessly with the PS3's built in GameOS. I'm using the packages provided by Ubuntu for the Gusty Gibbon (7.10) release. I don't know if there any any specific patches that Ubuntu has added to make this work. Without any configuration, I was able to kill the uShare program, boot up the PS3, and everything was 'just there'.

The PS3 seemed happy to play every TV show I had recorded at the time, so I'm not sure if MythTV is cleaning up the stream for it. It will also pick up all your music, and even organises everything for you in a much better way than described below.

I'd strongly suggest that anyone wanting to do this should upgrade to version 0.20.2. This will result in a much cleaner and easier set-up. The instructions below will remain for anything who is interested in using them.

Status

What works

  • Anything you can do with MythWeb (Scheduling recordings etc)
  • Watching recorded shows
  • Music
  • Photos
  • Watching videos

What does not work (yet)

  • Watching LiveTV
  • Commercial skipping
  • Subtitles
  • Using plugins which require the mythfrontend (such as mytharchive, mythgame etc.)

What's a pain

  • Initial setup.
  • You have to re-connect to your uShare to get an updated file list. I think this is an issue with uShare, and not the PS3.

Background on how this works

From firmware version 1.80 onwards, the PS3 has the ability to connect to 'media servers' on your LAN. The PS3 can then pull off any supported files (such as photos, music, or video) and view/play them. You can use this ability to make the PS3 connect to your mythtv backend machine, and pull off the files which mythtv records.

The PS3 also has a web browser. You can use this to connect to your mythtv backend machine, which has mythweb installed, and schedule recordings etc.

The upside of this is that you don't have to install Linux on the PS3 to view your mythtv recordings. The PS3 cripples access to the graphics system, so Linux within it is pretty useless from a mythtv point of view, especially for HD content. If you're viewing everything from the GameOS, this isn't a problem. You also don't have to go through the hassle of starting Linux every time you want to watch a TV show on impulse.

The downside is that the functionality is fairly limited. You cannot go in to the deeper functions of mythtv, and you cannot (yet) view 'live' tv reliability (it's possible to do, probably, but not worth the huge effort). And you are forced to use the web browser if you want to set up shows to record.

For most people, this isn't too much of an issue. They will probably have a computer somewhere which can be used for these functions, and can use the good looking PS3 to view recorded programs in the living room, using the nice PS3 remote.

Right now, you have to re-connect to your mythtv box from the PS3 every time you want an updated file list. I think this is a problem with uShare, but I cannot be certain. This is the biggest annoyance, other than the initial set-up process. I am hoping this will be fixed in the future.

UPnP in MythTV

Sadly, it's not currently possible to use MythTV's UPnP implementation. The PS3 requires DNLA to be present. Any UPnP implementation which does not have DNLA will not work with the PS3 yet. Source: http://www.mythtv.org/wiki/index.php/UPnP#UPnP-clients_server.2Fhardware_that_are_not_.28yet.29_compatible_with_MythTV:

Even with this working, you would still need to clean up the source video files.

Set-up

Setting this up is an involved process. It's not for a complete Linux 'noob', but you don't have to be a hardcore Linux hacker to get this working either. It just takes a while. I've been using Linux for a few years, but I cannot program beyond very basic bash scripts. So if I can set this up, it's within the reach of the majority of Linux users.

What you'll need

  • uShare v1.0 or higher ( http://ushare.geexbox.org/ )
  • A PS3 with firmware version 1.80 or above. Tested with 1.90. The PS3 needs to already be connected to your LAN and able to connect to your mythtv backend machine.
  • This guide assumes you have a backend already set up and running.

Setting up uShare

It's possible for you to use any DLNA server at this point. My choice is uShare, which specifically has support for the PS3. It's important that you use a DLNA server, and not just a regular uPNP server, as this will only allow the PS3 to see the files, and not play them.

Getting uShare to work was a big hurdle for myself, as it required manually compiling on my Feisty Fawn Ubuntu box, along with fetching a dependency and copying the libs it made into the right place. Getting that set up is beyond the scope of this document. But if you're on #mythtv-users and need help, my nickname is Ribs.

Side note: On Fedora 7 (as root) you can do "yum install ushare" to install it. Then do "chkconfig --level 35 ushare on" to make the service run automatically. You should edit "/etc/ushare.conf" as desired. To get going straight away do "service ushare start". It logs using syslog, so do "tail -f /var/log/messages" to see what it's up to.

Once uShare is installed, you need to run it with specific switches. For example:

ushare --dlna -c /var/lib/mythtv/recordings/

Now, with your PS3, run a search for media servers, and ushare should be detected. Voila! All your mythtv recordings are magically found.

That was easy, huh? But what's this? All the file names are cryptic, you cannot tell which show is what. Try playing a couple of them. You may find that some of them don't play at all. Some may play without sound, some may play perfectly fine. If everything plays fine for you, then continue to "Fixing the file names".

Why doesn't everything play properly? For some set-ups, MythTV will just dump the stream it gets into a file, including any crap it gets. If the stream is not 'just right', the PS3 will barf on the data. MythTV's playback system is very robust, a feature not shared by many other players. DVB users will feel the pain the most. If MythTV has to encode everything itself (for analogue signals), then you'll probably be okay. If all your files seem to work, skip down to 'Fixing the file names' section.

So, we need to fix the odd file names, and the get the file into something the PS3 is guaranteed to understand.

Cleaning the recording

You will need to install ffmpeg on your machine before going any further. Some mythtv plugins will require this anyway.

We are going to use ffmpeg to re-encode our file to clean out any nasty bits which may confuse the PS3 and cause it not to play. Find a file which you know does not play on your PS3, but does play on your regular MythTV frontend. Now run this command on it:

ffmpeg -i FILE -acodec copy -vcodec copy FILE.FIXED.mpg

Obviously replace "FILE" with the actual filename. You may see ffmpeg complain about corruption and problems with the original file. This is normal and is a good sign that there is something to be fixed.

Once complete, Ctrl+C on your shell running uShare, and run the uShare command again. On your PS3, select "Search for Media Servers" again. Your server will be found again. Find your broken recording, this time play the one you have "fixed" (FILE.FIXED.mpg). The PS3 should now play the file without issues.

We will want MythTV to do this for us automatically after every recording. Create this script and save it somewhere:

#!/bin/bash
echo $1
ffmpeg -i $1 -acodec copy -vcodec copy $1.2.mpg
rm -f $1
mv $1.2.mpg $1

I called my file encodeforps3.sh, but you can call it whatever you like.

Shut down your backend, and then start mythtv-setup. Go into "General". Keep pressing Next until you get to the "Job Queue (Host specific)" screen. make sure "Allow 'User Job #1' jobs" is ticked. Press Next twice more, and you can fill in the script details here as User Job #1. Call description whatever you like, and then User Job #1 command as "/bin/bash /path/to/script.sh %%DIR%%/%%FILE%%" (change the path to wherever the script is). Then Finish, escape, okay.

Start your backend'. Then start your front end. Go to "Utilities / Setup" then "Setup" then "TV Settings" then "General", press "Next" until you're at the "General (Jobs)" screen. Make sure "Run User Job #1 On New Recordings" is ticked. Then "Next", "Finish".

This should automate the process for you. If you have existing recordings which need to be cleaned up, then you can run the job manually. To do this, select the recording, don't start watching it, press the right arrow key, then "Job Options", then select whatever you called your job.

Depending on your setup, MythTV might take a minute or so to actually start the jobs. You can see the status of any jobs by going into the information center.

Fixing the file names

Fixing the file names is fairly easy. There is a script that comes with mythtv which can find the 'real' names of any recorded programs. We can modify this script to create symlinks for us. If we make symlinks to all of our recordings, we can have the PS3 use the symlinks (and therefore, give us decent filenames) and let MythTV go about it's business unaware.

Here is a patch I used to hack mythname.pl to give us symlink lines:

--- /home/ribs/Desktop/mythname.pl      2007-07-25 13:09:54.000000000 +0100
+++ mythname.pl 2007-07-25 13:11:54.000000000 +0100
@@ -191,7 +191,9 @@
        }
 
        if ($print) {
+               print "ln -s "; 
                print "$file " if $printfile;
+               print "/var/lib/mythtv/TV\\ Shows/";
                print "mpeg$codec " if $printcodec;
                print $title unless $quiet;
                print ":$subtitle" if $sub && $subtitle;

Make sure you change the /var/lib/mythtv... part to a path where you want your files to be symlinked to. Also make sure your backend's user can access this path and create/delete files.

I then scripted something to create the symlinks from this new output:

#!/bin/bash
echo -n "Removing old links ..."
rm /var/lib/mythtv/TV\ Shows/*.mpg
echo " done."
echo -n "Creating new links ... "
/home/ribs/ps3/mythname.pl --replace "_" --file --legal --extension mpg --subtitle /var/lib/mythtv/recordings/*.mpg > /tmp/makelinks.sh
/bin/bash /tmp/makelinks.sh
rm /tmp/makelinks.sh
echo " done."

Obviously, remember to change paths in here to match your system.

You can now use this script to create symlinks for the PS3 to pick up on. Then you'll have human readable file names to play when you want to watch something.

I set this up to be user job #2, and then set this job to be run automatically on new recordings. See above if you're not too sure how to do this. So every time a new recording is made, all the symlinks get removed and re-created again.

Refreshing uShare

uShare will not see any new recordings until you tell it to refresh. Doing this is simple, uShare has a small web server within it which can allow you to remove shares, or refresh the server for new files. We can use wget to do this from the command line. I set this up to be job #3:

/bin/wget http://localhost:49152/web/ushare.cgi?action=refresh -o /dev/null -P /dev/null

There is a bug, either in the PS3 or uShare, which causes the PS3 not to see the new files. To get around this, you will have to tell the PS3 to search for Media Servers again.

Screenshots

These images should help you a little with configuration, and show the PS3 playing one of my recordings: Ps3-1.jpg Ps3-2.jpg PS3-mythtv-jobs.jpg

Security

Just a quick note to point out that anyone else with a UPnP frontend can also see all your content without any authentication. This is probably most relevant to those folks using WiFi connections.