Homemade NAS Box Part 3

Bittorrent Server

DISCLAIMER: Do not use file sharing to download copyrighted material.

Not much to say here. I installed μTorrent so that I would have a way to download media off bittorrent. Transmission was also a great choice for bittorrent client.

UPnP Server

The coolest thing I’ve did with this project was setup a UPnP media server. The concept was simple: music, pictures, and videos are stored on the server and shared over the UPnP network protocol. Devices, such as a PS3, can see the content on the server and play it without having to download and save locally. There are several commercial products available that allows you create a UPnP server including MediaLink, EyeConnect, and Twonky. Being the person who liked to take the hard route sometimes I decided to skip all of those and go straight to MediaTomb, the open source alternative.

  1. Install the XCode Development tools from Apple
  2. Download and install MacPorts
  3. Open a Terminal window and run all of the following commands as either “su” or “sudo”
  4. port selfupdate
  5. port install mediatomb
  6. Wait for MediaTomb and all of its dependencies to finish compiling
  7. Once compiling is complete you can start MediaTomb by running the command “mediatomb” (no su/sudo required)
  8. The output from the command will give you the web address to MediaTomb’s web interface. Using Safari or your browser of choice you can select what content you share with your media devices

For my setup I wanted to stream content to my PS3. To do that there was a change I had to make to MediaTomb’s config file that was located in ~/.mediatomb. All I had to do was uncomment the line that said <protocolInfo extend="yes"/>. I also decided to disable the ability of my PS3 to see every folder on the server. That required changing <pc-directory upnp-hide="no"/> to <pc-directory upnp-hide="yes"/>.

With MediaTomb I could also enable the use of on-the-fly media transcoding. In the event I had a file the PS3 could not play, a rule could be setup in the config file that would automatically convert the media to a more compatible format. Using this feature required a lot of testing to work out settings the PowerMac could handle. Also, because the media files are being transcoded in real time I lost the ability to pause, fast forward, and rewind on the PS3. In the end I decided to take a different approach and setup folder actions to convert only files I wanted.

MediaTomb Transcoding

I mentioned earlier that I had developed an alternative to MediaTomb’s built in transcoding feature for media files that didn’t play on the PS3. I stole the idea from Vuze, another bittorent client, which added its own UPnP server. In the event Vuze downloaded a file that wasn’t compatible with the PS3 it would re-encode the file completely and then share the new version instead of the non-compatible version.

I was able to accomplish almost the same functionality using FFMPEG, folder actions, and MediaTomb’s built-in directory scan feature. If I had a file that did not work then I moved it to a folder called “convert”. Attached to that folder was an Applescript action that would tell FFMPEG to covert the file to a new format and save it in another folder called “compatible”. I then configured MediaTomb to scan the “compatible” folder every hour for new files and make them available to the PS3. For everything to work I had to rebuild FFMPEG to include codecs for aac, mp3, x264, and xvid. Below is the commands for MacPortsid

port deactivate ffmpeg
port install -f ffmpeg +nonfree

Below are the applescripts I wrote for the folder actions. When a file dropped into a folder the action would initiate the script and start processing the file through FFMPEG. Based on testing I had done some video files only needed the audio re-encoded for the PS3. Others required a complete re-encode. I’ll admit the PowerMac didn’t have the power to re-encode at realtime speeds, but I normally let it take care of files during the night or while I was at work.

Re-encoding only audio of a video file example:

on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set {name:Nm} to (info for i)
set Nm to quoted form of Nm as string
set vFolder to quoted form of POSIX path of this_folder as string
set vSource to quoted form of POSIX path of i as string
try
do shell script "/opt/local/bin/ffmpeg -y -i " & vSource & " -vn -f mp3 -ab 192k -ac 2 -ar 44100 " & vFolder & "converted/" & Nm & ".mp3"
on error
display dialog "There was an error when re-encoding " & Nm
end try
end repeat
end adding folder items to

Re-encoding Audio and video example:

on adding folder items to this_folder after receiving these_items
repeat with i in these_items
set {name:Nm} to (info for i)
set Nm to quoted form of Nm as string
set vFolder to quoted form of POSIX path of this_folder as string
set vSource to quoted form of POSIX path of i as string
try
do shell script "/opt/local/bin/ffmpeg -y -i " & vSource & " -vcodec libxvid -vb 1000k -acodec libmp3lame -ar 44100 -ab 128k -ac 2 " & vFolder & "converted/" & Nm & ".avi"
on error
display dialog "There was an error when re-encoding " & Nm
end try
end repeat
end adding folder items to

Starting Meidatomb during startup:

  1. Created a plain text file with the command /opt/local/bin/mediatomb -d
  2. Save the file as mediatomb.command
  3. Open a terminal window
  4. Run the command chmod +x _folder_location_/mediatomb.command
  5. Open System Preferences and go to Accounts
  6. Select the account that auto logs in and select Login Items
  7. Add mediatomb.command

With enough time and patience I could create a start lauch daemon to take care of starting MediaTomb up as a service, but I took the lazy man’s approach.

Next time: Other odds and things

Mario and the PS3 Collide

I knew it was only a matter of time and now I am proud to say that SNES gaming works on the PS3, again. One coder by the name of eiz compiled the Snes9x emulator for the PS3. Another coder, squarepusher2, has taken the source code and worked to improve it. As of writing, Squarepusher2’s 4.2.1 build plays most games with no issues. Both NTSC and PAL roms are supported. Things such as a GUI still need to be address and loading freezestates hasn’t been implemented, but those are not the highest priority. Even with only two people working on this project the progress has been phenomenal. I can’t to see what comes out next.

Eiz’s source code: http://github.com/eiz/ps3_snes9x

Squarepusher2’s build and source: http://www.ps3news.com/forums/ps3-hacks/snes9x-super-nintendo-emulator-ps3-port-arrives-112925-19.html#post311837

PlayStation 3 Jailbreaking is Here

The PS3 flew the coup

A lot can be said for the security features built into the PlayStation 3. It took almost four years for enthusiasts to find a way to run unapproved code on the PlayStation without the use of the “Other OS” feature. Sony quickly removed Other OS after hackers used it to gain low-level access to the system. Now there is a way new way to “jailbreak” the PS3 and run applications. All that is involved is a programmable USB device and source code. Other people have taken the code and ported it to devices so you can use your android phone or Linux PIM. Someone even managed to port the code to the TI-84 calculator. If working with DIY components and code isn’t your sort of thing, complete USB packages can be purchased from resellers online. Eventually all of this could lead to a homebrew community as large as the PSP with lots apps and mods. Personally, I’m waiting for the emulators to be ported over so I can get some SNES action.

Steps for jailbreaking a PS3 using a calculator after the break.
Continue reading “PlayStation 3 Jailbreaking is Here”