Tuesday, June 10, 2008

Obscure Linux Tutorials : Red5 Ubuntu Wii FLV Server

Welcome to Obscure Linux Tutorials, a new article series I'll hopefully actually write about at a reasonable pace. I'm writing these articles because in Linux, you have a solid chance of comming across an "edge case"; a situation where you're stuck on a problem that unfortunately, most people aren't having. As such, you end up frantically looking for a solution that doesn't seem to exist, and after hours of working your fingers to the bone trying to fix your issue, you get your solution, and unfortunately, you're too tired by then to bother writing up any documentation for the next guy who come across this problem. I'm trying to break that chain as best I can.

In this edition of OLT, I cover how to create a Red5 server on your Ubuntu box in order to properly stream flash video to your Wii. (or your PS3, PSP, pretty much anything that can view Flash videos). You don't need Ubuntu, any Debian distro will do. In fact, if you can get Apache and Java6 JDK up and running, any Linux distro should cut it.

Let me explain why I needed this working :
- I have MythTV recording my shows and converting them to FLV (Flash Video, the stuff they use on Youtube) for web streaming automatically.
- The Wii can't cache videos, so I needed a real FLV server if I wanted the Wii watching the vids.
- There are only two FLV servers in existence. One of them costs a foo-ton of money, the other one is a pain to install.

Unfortunately, as I don't have the $4500 lying about for option A, I had to take option B, which doesn't seem all that easy to get working for an beginner. Hence this guide.

Warning : All of this mess is a lot easier to get up and running in Windows. Red Kawa has a program that does it all, made especially for the Wii, I believe. I had to take this route (using server-class software) because the only computer in my house with rock-solid stability is the workhorse linux box that is also our printserver, public 'net terminal, and personal video recorder. Getting Windows to do all that with the kind of stability the computer requires was nigh-impossible, so I had to install a Red5 to get MythTV's generated FLV files playing properly on the Wii/PSP/etc. Who knows, maybe this'll also make it easy for the iPhone to play back the streams in the future (it'll probably need some sort of rss/rtmp mechanism tho)?

Installing Red5



Download and install this deb file. If you require a simple terminal method, or aren't even reading the between-terminal code guides, might I suggest :


cd ~/bin/temp
wget -c http://dl.fancycode.com/red5/debian/0.6.2/red5_0.6.2-1_all.deb
sudo gdebi-gtk red5_0.6.2-1_all.deb

Keep in mind that Gdebi might stall at a Java installation. If it does, just click the terminal and hit the spacebar or enter key to continue. If you're not using Ubuntu, find your package here.


Adding your flash video streams



You're pretty much ready at this point. All you need to do is have it point properly to your FLV files and the RMTP links in your flash player should work. Now, I tried wrapping my head around Red5's tutorial for this, but I'm going to level with you. I have zero clue how to make a new folder for the FLV files that Red5 will properly distribute. As such, my solution revolves around the rather dirty hack of simlinking that folder to where your FLV files actually are. As such :


cd /usr/lib/red5/webapps/oflaDemo/
mv streams backup_streams
sudo ln -s /path/to/your/FLV/ streams


So for example, assuming your FLV files match the filenames of your videos, a recording RTMP link will be something like this :

rtmp://localhost/oflaDemo/1054_20080610085700.mpg.flv

You probably don't even need the .flv in most cases, btw.

At this point, you can use any RTMP-supporting flash video player swf file to show your videos, or even roll out your own. Assuming that you have zero clue as to how to do that, might I suggest the JW player?

Install Apache


If you're running mythweb, which you most likely are, you probably won't need this step. But, just in case, this part's easy :

sudo apt-get install apache2


Now you'll have a webserver running at : http://localhost/
Whatever you see in there is located in : /var/www/

Install and configure the JW FLV Media Player


1. First, download the player from the site. If you're using Firefox, it's going to save to the desktop. Either way, for simplicity's sake, save it there. The next set of directions will move it back to ~/bin/temp

2. Move it to temp, extract it, move to your webserver (this keeps a copy of the archive in temp just in case). At this point, the commands will download 7z just in case you don't have it. It's a helpful app, unzips practically anything.


mv ~/Desktop/mediaplayer-3-16.zip ~/bin/temp/
cd ~/bin/temp/
sudo apt-get install p7zip-full
7z x mediaplayer-3-16.zip
sudo mv mediaplayer-3-16 /var/www/mediaplayerjw


3. Make an html file in your /var/www/ folder called "testflv.html".

sudo gedit /var/www/testflv.html


4. Paste the following into it :

Get the Flash Player to watch this.







Now go to http://localhost/testflv.html and click the play button on the player. You should be watching the Transformers trailer any moment now. Congrats, your RTMP server now works, and is incredibly Wii-friendly. All you need to do if you want this to work outside of your local machine is sign up for a DDNS account, and once that works, forward port 1935 to the Red5 server computer's address on your router. Then just swap out localhost in the html to whatever your website's address is.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home