I don’t fall asleep easily when I’m on-call so I decided I’d watch Dexter Season 2. I didn’t want to download 4.1GBs of xvid/avi’s from my parents house to my place because it’s entirely unnecessary to have the videos in two places. So, let me explain how I got a Streaming Media daemon working on my server.
I did some searching and there wasn’t anything super awesome out there that would keep me away from using the command line interface of VLC. So, the first step was to install vlc. I also use screen so I can log out of my SSH session and just use the web interface available on VLC, so I’ll include steps for using screen.
sudo apt-get install vlc screen
During or after installing vlc, you might as well set up the port forwarding on your router for access to the web interface. Log into your router and open up port 8080 to your server. If you are not trying to stream over the internet or don’t have a persistant dynamic or static IP address, you can skip this step. Check http://www.portforward.com/english/routers/port_forwarding/routerindex.htm for information on how to port forward on your router.
The next step was to get into screen and start the media daemon.
screen vlc -I http
You can then press ‘CTRL’+’A’ followed by pressing ‘D’ to detach from your screen instance and log out of your server (this is the glory of screen). You can reconnect to screen later by entering ‘screen -r’ at the shell of your server. I use screen for all of my console-based server daemons or anything I want to have run while disconnected from the SSH session I’m in (HLDS, SRCDS, VLC, ‘apt-get upgrade’, ‘tail -f’).
Then browse to your server by going to http://your.server.ip:8080/ . You should be greeted with an html representation of the VLC interface you may be familiar with on your computer. It will look something like this:
At this point you can toggle the Stream Output by clicking on the icon that has three staggered arrows pointing to the right (on the default theme). From here you want to check the ‘UDP’ box enter your external IP and a port (default is port 1234 on VLC UDP client) to use for streaming. This method makes it easiest for connecting the client side for streaming, which in most cases is ideal. If you’re going to set this up for less savvy users simplifying their end makes it easier on you as the admin, TRUST ME.
Next, open up UDP ports 1234 on the client router forwarding it to the viewing computer again this won’t be necessary over LAN and won’t be possible from a NAT’d server. Start VLC on the client computer and open Network Stream (CTRL+N) and click OK.
Back on the Web Interface, open the file and play it. If you don’t have any port forwarding or NAT issues, you’re done!
The first 2 episodes I have are not encoded with anything special, so I was able to stream them without adding any extra codecs to my server. However, episode 3 needed xvid codecs.
Here’s the steps to add the “non-free” w32codecs:
sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
sudo apt-get install w32codecs
Restart the vlc daemon and you’ll be able to play xvid (and I assume divx as well).