So after recently rebuilding one of the servers in my dogghouse, I realized that I hadn’t installed a uPNP/DLNA AV media server. Previously I had been using Fuppes, but the lack of active development and some other quirks made me re-think what I wanted to use. So, after comparing available packages, I decided to give the PS3 media server a try. I specifically wanted something that could run without a GUI on a headless machine as a service/daemon if necessary, that would support an XBox 360 and various Android devices.
Installation was fairly easy, however the documentation to make it work how I wanted on an RPM based distro was conflicting, spread across multiple sites, and somewhat lacking…
First, we need to add the rpmforge repo, in order to install the prerequesites with yum. Instructions for installing RPMForge can be found at the CentOS RPMForge Howto, but it basically consists of the following:
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt rpm -i http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Next, we need to install some prerequisite packages:
yum install gcc mplayer ffmpeg mencoder java-1.7.0-openjdk ImageMagick
If you wish to stream web content, you will also want to install vlc:
yum install vlc
If you are having problems installing vlc, because of version conflicts with libupnp, add the line exclude=libupnp to your /etc/yum.repos.d/epel.repo, in the main [epel] section
We will also want to install libzen and libmediainfo for some additional features. You can skip this step if you like, but not all the features will work!
You can get RPM packages for libzen and libmediainfo from the MediaInfo Download Page, just select the appropriate distro and architecture, download the package, then install like this:
wget http://mediaarea.net/download/binary/libzen0/0.4.29/libzen0-0.4.29-1.x86_64.CentOS_6.rpm rpm -Uvh libzen0-0.4.29-1.x86_64.CentOS_6.rpm wget http://mediaarea.net/download/binary/libmediainfo0/0.7.64/libmediainfo0-0.7.64-1.x86_64.CentOS_6.rpm rpm -Uvh libmediainfo0-0.7.64-1.x86_64.CentOS_6.rpm
Finally, we are ready to install ps3mediaserver! Go grab the latest ps3mediaserver package from the ps3mediaserver download page, and extract it somewhere. I like to put it in my /usr/local/share directory so that I can run it as a service in the background or as a non-privileged user.
Next, we will follow Geoff Hodder’s advice and create a symlink from /usr/local/share/pms to the current version of pms, which we can change in the future when upgrading, making the upgrade process easier!
ln -s /usr/local/share/pms-1.90.0 /usr/local/share/pms
Double check the ownership here on the pms-1.90.0 folder. I have mine owned as root:root. The default permissions should be correct. Below are what my folder permissions look like.
lrwxrwxrwx 1 root root 27 Nov 19 21:07 pms -> /usr/local/share/pms-1.90.0 drwx------ 5 root root 4.0K Jan 29 07:48 pms-1.90.0
Now go to the directory you just created with the ln command above, (/usr/local/share/pms/ in my case), and edit the file PMS.conf, changing the following settings:
minimized = true network_interface = br0 folders = /data/movies,/data/music,/data/pics
Optionally, edit the following settings to enable chapters on .mkv files, and disable forced subtitles:
chapter_support = true mencoder_disablesubs = true
If you are upgrading from a previous version of ps3mediaserver, don’t just copy your old config file. Variable names are often changed, new variables are added, and old ones may be removed. Double check your settings and apply them to the new file!
Obviously you will want to change the folders and network_interface settings to match your setup. The defaults for the rest of the settings should be fine, but take a look through the other settings if you wish.
One additional change was made to the /usr/local/share/pms/renderers/XBOX360.conf file to allow avi streaming to the XBox 360. Find the StreamExtensions= line and avi to the end, so it will look like this:
StreamExtensions=wma,asf,avi
Phew… We’re almost there!
One of the things I specifically wanted was to be able to run this as a service on boot. I also wanted to specify my config file, instead of having it use one from my home folder. In order to do this we are going to edit the /usr/local/share/pms/PMS.sh file. Comment out the DIRNAME=`dirname $CMD` line and add a line like DIRNAME="/usr/local/share/pms/" right below it. Here is what the first few lines of my PMS.sh file look like:
#!/bin/sh CMD=`readlink -f $0` #DIRNAME=`dirname $CMD` DIRNAME="/usr/local/share/pms/"
One more thing that I wanted was the ability to simply run a command from anywhere, as any user, and start the service. I just created a symbolic link in the /usr/local/bin to the PMS.sh script like so:
ln -s /usr/local/share/pms/PMS.sh /usr/local/bin/pms
We must now allow TCP traffic on port 5001 and UDP traffic on port 1900 through our firewall, along with multicast IGMP traffic, to actually let this thing work! Open the appropriate ports with some lines like this in your /etc/sysconfig/iptables file:
-A INPUT -s 10.0.0.0/24 -i br0 -p tcp -m tcp --dport 5001 -j ACCEPT -A INPUT -s 10.0.0.0/24 -i br0 -p udp -m udp --dport 1900 -j ACCEPT -A INPUT -d 224.0.0.0/4 -i br0 -p igmp -j ACCEPT
You will also need to set the default multicast address route. This can be set in the /etc/sysconfig/network-scripts/route-br0 file, looking like this:
# /etc/sysconfig/network-scripts/route-br0 224.0.0.0/4 dev br0
Make sure to change the source address mask to match your local network addresses, and the interface to match your local network interface. If you have IPv6 running, you should also open those same ports in your /etc/sysconfig/ip6tables firewall:
-A INPUT -p tcp -m tcp -s 2001:1234:5678:abcd::/64 -i br0 -j ACCEPT --dport 5001 -A INPUT -p udp -m udp -s 2001:1234:5678:abcd::/64 -i br0 -j ACCEPT --dport 1900
PLEASE NOTE!!! If you have IPv6 running, you will want to remove the -Djava.net.preferIPv4Stack=true parameter from the last line of the PMS.sh file. More details below…
Again, make sure that your source address mask and interface match your network configuration, and don’t forget to restart your firewalls to apply the new rules!
Now, before we go any further, we can attempt to run the server and make sure that everything is actually working correctly. Just type pms from a command prompt and watch it go!
If everything is working correctly, you will either have the GUI window pop up, or get a message like this:
GUI environment not available Switching to console mode
or you may get a bunch of debug messages fly by. If there are any errors, double check everything before moving on.
If you are in the console mode, press crtl-c to stop the ps3mediaserver.
Finally, the last thing I want to do is set this thing to run as a service/daemon in the background and start on boot. In order to do this we need a startup script!
Create the /etc/init.d/ps3mediaserver file and put the following in it:
#!/bin/sh # # chkconfig: - 91 50 # description: Starts and stops the ps3mediaserver # version: 0.8 # pidfile: /usr/local/share/pms/ps3mediaserver.pid # config: /usr/local/share/pms/PMS.conf # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 1 fi # Avoid using root's TMPDIR unset TMPDIR # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 1 PROG_NAME='ps3mediaserver' PROG_ROOT='/usr/local/share/pms' PROG_JAR='pms.jar' PROG_EXEC='PMS.sh' RETVAL=0 start() { KIND="$PROG_NAME" echo -n $"Starting $KIND services: " cd $PROG_ROOT daemon $PROG_ROOT/$PROG_EXEC RETVAL=$? echo [ $RETVAL -eq 0 ] && echo `ps axo pid,args | grep $PROG_JAR | grep -v grep | awk {'print $1'}` > $PROG_ROOT/$PROG_NAME.pid || \ RETVAL=1 ps axo pid,args | grep $PROG_JAR | grep -v grep | awk {'print $1'} > $PROG_ROOT/$PROG_NAME.pid return $RETVAL } stop() { KIND="$PROG_NAME" echo -n $"Shutting down $KIND services: " killproc -p $PROG_ROOT/$PROG_NAME.pid RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $PROG_ROOT/$PROG_NAME.pid return $RETVAL } restart() { stop start } rhstatus() { status -p $PROG_ROOT/$PROG_NAME.pid $PROG_NAME return $? } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) rhstatus ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 2 esac exit $?
One of the last things we need to do is make a small change to the last line of our PMS.sh script, to allow it to run in the background, and log to a file. The last line should look like this (note the difference between IPv4 and IPv6 networks!):
IPv4:
exec "$JAVA" $JAVA_OPTS -Xmx768M -Xss1024k -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djna.nosys=true -classpath "$PMS_JARS" net.pms.PMS "$@" >> /var/log/ps3mediaserver.log 2>> /var/log/ps3mediaserver.log &
IPv6:
exec "$JAVA" $JAVA_OPTS -Xmx768M -Xss1024k -Dfile.encoding=UTF-8 -Djna.nosys=true -classpath "$PMS_JARS" net.pms.PMS "$@" >> /var/log/ps3mediaserver.log 2>> /var/log/ps3mediaserver.log &
I have not been able to get the IPv6 configuration for PS3 Media Server to work reliably on all my devices… If you have any suggestions please let me know!
Finally, install the startup script and set it to run on boot!
cd /etc/init.d chmod +x ps3mediaserver chkconfig --add ps3mediaserver chkconfig --level 345 ps3mediaserver on
Now, we can start the ps3mediaserver and be done!
service ps3mediaserver start Starting ps3mediaserver services: [ OK ]
Now that we are done, go ahead and get yourself a dogg treat!
Thanks to Geoff Hodder for some good tips left in the comments below. Go check out his page at PHReeK.oRG
Also, thanks to the following webpages for giving me some of the information necessary to get this thing working:
http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&t=4374
https://help.ubuntu.com/community/Ps3MediaServer
http://otmanix.de/english/2009/05/17/java-ps3-media-server-for-dummies-chapter-3-installation-and-basic-configuration/
Your instructions were pretty much perfect except to get my Xbox 360 to stream I needed to change the IPTables UDP port to 1900 using PMS 1.50.1.
Thanks Geoff, you are absolutely correct about port 1900; I’ve added the appropriate rules to the original article. Not sure how I missed it the first time!
When I run “netstat -anp|grep java” there’s nothing listening on UDP/5001. It’s just TCP/5001 and UDP/1900.
Hi, Thanks for this. It was quite helpful for Mandriva 2010.2 also as Centos is much closer than Ubuntu – which all the other info I could find seemed to be on.
One small thing I added was to this line:
daemon $PROG_ROOT/$PROG_EXEC
I changed it to:
daemon --user $USERNAME $PROG_ROOT/$PROG_EXEC
This forced it to run as specified user and therefore I was able to logout from my shell without stopping ps3mediaserver.
I just updated to 1.53.0 and have a couple of extra notes.
Instead of hard-coding the full (real) path in the various files, I symlinked /usr/local/share/pms to my current version (i.e. /usr/local/share/pms-1.53.0) and used the symlink path where necessary. Next time I upgrade, I should just need to make the changes to PMS.sh and PMS.conf and renderers/XBOX360.conf and restart the service and I’m upgraded.
Also, when editing PMS.conf, instead of renaming/deleting the default and creating a brand new file, I just updated those few lines as mentioned and kept the rest of the defaults. I now have a working transcoder on XBOX 360 which didn’t work when I made the file look exactly as you specified.
Thanks Geoff!
Next chance I have I will upgrade my installation of PS3 Media Server and add in your additional instructions.
Much appreciated!
Geez, that’s unbebievalle. Kudos and such.
Amazing, thank you so much! Just swapped to CentOS from Ubuntu, rather new at CentOS and this really helped me, thanks!
Amazing tutorial!
Anyway I faced an issue with tsMuxeR, pms can not find it when it tries to use it:
ERROR 2012-07-10 00:26:08.448 [tsMuxeR-24] Fatal error in process initialization:
java.io.IOException: Cannot run program “tsMuxeR”: java.io.IOException: error=2, No such file or directory
Something wrong with the paths? Any idea?
John,
Walk through the instructions again, and make sure you didn’t miss anything.
Double check that you have the correct path’s specified, and that the permissions for txMuxeR are correct. txMuxeR should be located within the linux sub-directory inside the pms directory. Mine is located here: /usr/local/share/pms-1.53.0/linux/tsMuxer, with permissions of 0755.
Hope that helps.
Thanks, looks like setting the correct permissions made the trick.
Another small thing, when I reboot the whole machine, the pms is started correctly (im able to use it from ps3) but if I check the status using “service ps3mediaserver status” it returns “ps3mediaserver dead but pid file exists”. Also start/stop does not work as the pid file is there.
I’ve had that happen on a few circumstances myself, and haven’t yet found a “good” solution (although I haven’t looked very hard). I did write up a quick script to check for this scenario and restart the ps3mediaserver; basically if status returns the word “dead” it will find the pid running pms.jar, kill it, and restart the ps3mediaserver. It was a quick hack I threw together, but will do the trick if run in a cron. Hopefully it will help you out. If you manage to find out why this happens please let me know!
#!/bin/bash
if /sbin/service ps3mediaserver status | /bin/grep dead > /dev/null 2>&1; then
pid=`ps aux | grep -v grep | grep pms.jar | awk '{ print $2 }'`
kill -9 $pid > /dev/null 2>&1
/sbin/service ps3mediaserver restart > /dev/null 2>&1
fi
Okey, for me this is not big issue as the machine (and pms) is running all the time
I noticed that the tsMuxeR issue still reproduces, but it does not happen with all video files. Maybe something to do with used codecs? My pms debug log: http://pastebin.com/VZj3Smjf
service ps3mediaserver stop was failing because it didn’t have permission to remove the ps3mediaserver.pid file. I changed the file permission on pms-1.6.0 to match the symbolic link and now appears to be stopping.
Problem I am now having is some of my changes to PMS.conf are not showing up on the Xbox360 or Ps3 (like hiding file extensions etc..). When I run pms it gernerals a new PMS.conf in my personel profile. Defaults are also missing the changes I made to /usr/local/share/pms/PMS.conf
Outside of that everything is working except music on Xbox360, great job on the tutorial.
Hi,
Thanks for sharing your knowledge!
Everything is working very well but 1 feature.
I have a weird issue with the Media Locations “Folders =” in PMS.conf, but first let me explain my LAN setup.
I have 3 CIFS mounted shared folders located: /mnt/Movies,/mnt/Musique,/mnt/Series,/mnt/Photos
I included the CIFS mount process in the ps3mediaserver service script to make sure those folders are mounted before PMS loads the PMs.confg.
When I browse the shared folders, it works like a charm. I can see all the files into it.
Here are 2 different syntaxes I tried in my PMS.conf:
folders = /mnt/Movies,/mnt/Musique,/mnt/Series,/mnt/Photos
&
folders =\/mnt\/Movies,\/mnt\/Musique,\/mnt\/Series,\/mnt\/Photos .
However, when I browse the Media Server on my PS3, I end up seeing the File System directory instead.
I’d appreciate your help !
Thanks.
Alex
Double check that the folders you have specified have the correct permissions. You could also try using a single non-cifs folder, check if that works, then try one cifs folder by itself, test, then move back to your multiple cifs folder setup.
If I have a chance I will try to replicate your setup with a cifs mounted folder and let you know how it goes.
Good luck!
I had this same problem, that and none of my settings were changing in the PMS.conf. Follow Rich Blades edit listed above and it should fix the problem.
Make a user account then declare it in the ps3mediaserver script. Should look something like this:
PROG_EXEC='PMS.sh'
USERNAME='pmsuser'
RETVAL=0
start() {
KIND="$PROG_NAME"
echo -n $"Starting $KIND services: "
cd $PROG_ROOT
daemon --user $USERNAME $PROG_ROOT/$PROG_EXEC
Thanks for your support.
I have found that after doing all your procedure up there, PMS still look for the PMS.conf at /root/.config/PMS/ rather than /usr/local/share/ for some reasons… I will probably just do a fresh install and try again. Long life to virtual machines!
Alex
Just a note to say thanks for the write-up, came in very handy.
Hi, Seem to be having problems with this. I’m running CentOS 6.3 and did step by step but when I run pms to test I get errors. The first error was a permssion problem after I fixed that I get this:
[root@localhost ~]# pms
/usr/local/bin/pms: line 30: cd: /user/local/share/pms/: No such file or directory
Exception in thread “main” java.lang.NoClassDefFoundError: net/pms/PMS
Caused by: java.lang.ClassNotFoundException: net.pms.PMS
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: net.pms.PMS. Program will exit.
Did you create the soft link to the appropriate directory?
You will need to run a command like this:
Double check that the /usr/local/share/pms symlink exists, and that it is pointing to the correct directory where you extracted the PMS files.
Hi, I got that working. I had user instead of usr.
I have 1 other problem and can’t seem to find an answer online. When I start up my PS3 and go to My Media server and click on it I have a long path of clicking to get to the media.
Example: X is the button on the remote.
Media Server > X > / X > usr X > local X > share X > media.
Is there a way I can shorten that up? I can browse all the directories. I just want to go straight into Media.
Thanks
Rick
BTW. Excellent Job on the instructions! Worked like a charm except for my mistakes.
In your PMS.conf file you should have a line like this:
folders = /data/movies,/data/music,/data/pics
Change the folder path to represent your directory structure. From what you have in your comment, something like this may work for you:
folders = /usr/local/share/media
If that line does not exist in your PMS.conf, add it! Restart the ps3mediaserver afterwards, and you should be good to go.
And thanks for the kind words! I’m glad you’ve gotten this working!
Ok Tried that no luck :(
folders = /usr/local/share/media/
not sure what else to do.
Interesting…
Looking at another comment, someone had a similar issue, and their PMS service was reading the configuration file from the /root/.config/PMS folder instead of the one specified in the /usr/local/share/pms folder. Double check that location? Also, perhaps try starting with a different directory and see if you can manipulate the folder starting location. There may be a permissions issue preventing PMS from starting in the folder you specified? Make a test directory at something like /media and throw a few files in there to test, and if that works try creating subfolders and testing again.
Hope that helps.
WOW I went to the /root/.config/PMS/pms.conf file and added the folders = /usr/local/share/media and it worked!!!
I’ve read above and don’t understand what I need to do to fix this. (Sorry new to Linux)
Also I added a new MP3 and my PS3 say’s “The data type is not supported” but the rest of my music is MP3’s.. Could this be because it’s looking at the wrong conf file? The rest play just the new ones I’ve added.
Specifying the location of the configuration folder is at the beginning of the PMS.conf file:
Unfortunately I’m not sure about the recently added mp3 file. Maybe it is not really an mp3 format, even though the extension says mp3? Try adding some others, there should be no problem adding new music.
I have that in my PMS.sh file in the /usr/local/share/pms/PMS.sh folder I didn’t find what you were talking about in the pms.conf file. I copied and pasted below mine.
#!/bin/sh
CMD=`readlink -f $0`
#DIRNAME=`dirname “$CMD”`
DIRNAME=”/usr/local/share/pms/”
This is very fascinating, You’re an overly professional blogger. I’ve joined your feed and look ahead to searching for more of your
great post. Additionally, I’ve shared your website in my social networks
Hi there Sophiedogg
Please would you kindly update your tutorial for the latest ps3mediaserver and java version.
I have just updated to 1.9.0 to see if it will fix my lack of engines on my CentOS 6.4 64bit. i can only seem to use mencoder or no encoding when going through the transcode option whereas my windows pc will have ffmpeg and tsmuxer etc.
I would greatly appreciate it
Best regards
Danny
Sure! I am going to work on updating my CentOS 6.4 x64 ps3mediaserver setup tonight.
Great tutorial thanks!
For the people having issues with the PMS.conf file located in
/root/.config/PMS directory, I was able to resolve this by adding another line in the /usr/local/share/pms/PMS.sh
#!/bin/sh
CMD=`readlink -f $0`
#DIRNAME=`dirname $CMD`
DIRNAME="/usr/local/share/pms/"
export PMS_PROFILE=$DIRNAME
Great tutorial!. i have an issue where i always have to go into the transcode folder and select mencoder to play mp4’s even though mencoder is set as my default engine. any ideas?
It sounds like you missed the step to add StreamExtensions=wma,asf,avi to the appropriate renderers file. Double check that setting.
i have two words for you. You Rock!
Brilliant blog article, very helpful. For those who are still having issues with the PMS.sh being accessed from /root/.config/PMS, try this after backing up the PMS.conf file already there.
cp /root/.config/PMS/PMS.conf /root/.config/PMS/PMS.conf_bak
ln -s /usr/local/share/pms/PMS.conf /root/.config/PMS/PMS.conf
It is a bit hacky I know, but it works for me.
Look at Owen’s post above, that worked for me.
Great Blog so far.
I hope you use PMS on CentOS 7 ;-)
If I run into problems with my installation, I will share them here.
Great, thanks! I have not had a chance to do much with CentOS 7 yet…