Search This Blog

2010-09-19

Streaming to PS3 Using MediaTomb + Transcoding

When configuring MediaTomb to stream to the PS3 using UPnP there were/are a few problems you may run into that may end up being extremely frustrating. I will go through the install/configuration process and give an idea how to troubleshoot some problems.

Basic Installation (Ubuntu 10.04 Server)

Step 1: Installation
Installing the packages required for mediatomb.
sudo apt-get update
sudo apt-get install mediatomb

Step 2: Configuration
The next step is to configure mediatomb for PS3 playback. There are just a few lines that need to be uncommented or changed to allow for playback on PS3 and divx support.
https://help.ubuntu.com/community/MediaTomb

sudo nano /etc/mediatomb/config.xml

<!-- Uncomment the line below for PS3 divx support -->
<map from="avi" to="video/divx"/>

Step 3: Binding interfaces
I found when installing mediatomb that it assumed I was using the default interface eth0.
I was not but decided I should change my eth1 back to eth0 anyways as somehow it got changed. Changing an Ethernet name is simple by using the following steps:

1. In the below file change eth1 to eth0 or whichever you would like to name it.
sudo nano /etc/udev/rules.d/70-persistent-net.rules

2.Change the ethX to whichever you would like (Or add it if it doesn't exist)
sudo nano /etc/network/interfaces
auto eth0
iface eth0 inet dhcp

Once this is done it's probably a good idea to specify the interface to bind to under: /etc/mediatomb/config.xml
<interface>eth0</interface>

Also, Make sure to look in the /var/log/mediatomb and check which IP and which interface mediatomb is actually using
http://samiux.wordpress.com/2009/08/06/howto-add-or-rename-network-interface-on-debian-5-0/

Step 4: Removing Duplicate Entries in Windows Media Player
On the PS3 you will not see more than 1 entry for files hosted on mediatomb. But on Windows Media Player you will see 2-3 entries. I have found out how to get rid of one using the following command but am unsure how to remove the other.

<pc-directory upnp-hide="yes"/>
</server>

Step 5: Restarting MediaTomb Service
This is easily done by:
sudo /etc/init.d/mediatomb restart

Step 6: Making Sure You Have the Right File Permissions
It seems simple enough but do a ls -l to make sure your files have the correct file permissions 666 or higher to be safe.

This is because you are accessing the files from a different user from what the mediatomb server is using. You can add users in the config file if you want but making everything work without open file permissions can be difficult/annoying.

Changing default Samba Permissions for Proper Playback.
You're likely dumping files on your mediatomb server using smb so go ahead and change the /etc/samba/smb.conf file so that you share has the following default permissions for when you copy files to it.

[share]
comment = Shared Data Storage
path = /share
writeable = yes
create mode = 0777
directory mode = 0777
locking = yes

Transcoding Files on the Fly:
Transcoding media is a very CPU intensive process but to play unsupported files on the ps3 it is necessary to convert one filetype to another to allow for playback.

This is done by creating a script that can be referenced in the config.xml for mediatomb.

To allow for mkv transcoding I used the following script under /usr/local/bin/mkv2mpeg

#!/bin/bash
FFMPEG_PATH="/usr/bin/ffmpeg"
INPUT="$1"
OUTPUT="$2"
VIDEO_CODEC="mpeg2video"
VIDEO_BITRATE="4096k"
VIDEO_FRAMERATE="25"
AUDIO_CODEC="copy"
FORMAT="mpegts"
exec "${FFMPEG_PATH}" -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b ${VIDEO_BITRATE} \
-r ${VIDEO_FRAMERATE} -acodec ${AUDIO_CODEC} -f ${FORMAT} - > "${OUTPUT}"

The above was taken from: http://soowei.com/2008/11/27/streaming-mkv-in-mediatomb-to-ps3/

The next step is to add a reference for this script into the config.xml file I will just include my entire transcoding section tag for reference.

<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="video/x-matroska" using="ffmpeg"/>
<transcode mimetype="video/x-flv" using="vlcmpeg"/>
<transcode mimetype="application/ogg" using="vlcmpeg"/>
<transcode mimetype="application/ogg" using="oggflac2raw"/>
<transcode mimetype="audio/x-flac" using="oggflac2raw"/>
</mimetype-profile-mappings>
<profiles>
<profile name="oggflac2raw" enabled="no" type="external">
<mimetype>audio/L16</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>no</accept-ogg-theora>
<agent command="ogg123" arguments="-d raw -o byteorder:big -f %out %in"/>
<buffer size="1048576" chunk-size="131072" fill-size="262144"/>
</profile>
<profile name="vlcmpeg" enabled="no" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4$
<buffer size="14400000" chunk-size="512000" fill-size="120000"/>
</profile>
<profile name="ffmpeg" enabled="yes" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<agent command="/usr/local/bin/mkv2mpeg" arguments="%in %out"/>
<buffer size="14400000" chunk-size="512000" fill-size="120000"/>
</profile>
</profiles>
</transcoding>

There are further resources for transcoding scripts for PS3 at: http://mediatomb.cc/dokuwiki/transcoding:transcoding
http://blogs.gnome.org/jamesh/2008/10/30/upnp-ps3/
http://www.avsforum.com/avs-vb/showthread.php?t=955857

Transcoding can also be done with VLC according to others:
http://blog.sorenmunk.dk/2008/09/ps3-media-center-finally-working-with.html

Troubleshooting:
I thought I would just include some locations of files in order to help troubleshoot some issues

Logging: /var/log/mediatomb.log

Startup Behavior: /etc/init.d/mediatomb

Config:
/etc/mediatomb/config.xml
/etc/default/mediatomb
/etc/samba/smb.conf

No comments:

Post a Comment