I was playing around with a Raspberry Pi this weekend. Normally I have the Pi hooked up as a high-definition audio player for 24-bit 96kHz audio files through a USB audio adapter.
But this time I wanted to do something a little different—I wanted to be able to play some movies stored on a USB stick on an iPad or iPhone. The Pi to the rescue!
It's really trivial to set the Pi up to serve media files that you can play on a mobile device. One way to do that is to use a DLNA server and client. You can go all out and use something like XMBC, but that's a little heavyweight and more fuss than I wanted for this application.
All I needed to do was to install a small package named minidlna,and to mount the 32GB USB stick that had movies on it.
First, to get the UDB stick mounted, you need to find the device name, which will be something like /dev/sda1. To see what device it may be, insert the USB stick into a USB slot on the pi and use fdisk:
sudo fdisk -l
In that output, you'll see some lines for your USB stick that might look like this:
Device Boot Start End Blocks Id System
/dev/sda1 * 8064 60566015 30278976 c W95 FAT32 (LBA)
Ok, on the last line I see that's my FAT32 formatted (DOS) 32GB USB drive, and it's on device /dev/sda1. What I'd like to do now is make a mount point for the USB drive (I'll call it /media/usb32) and tell Linux to automatically mount that device on that mountpoint:
sudo mkdir /media/usb32
sudo mount -t auto /dev/sda1 /media/usb32
Now the USB files will show up in the directory /media/usb32.
All we need next is to install the minidlna package:
sudo apt-get install minidlna
And configure it by editing it's config file. I'll use vi, but you can use a simpler editor such as nano (sudo apt-get install nano) if you're not into vi.
sudo vi /etc/minidlna.conf
You need to add a line to tell the dlna server where your video files are:
The "V," tells it to look for video files under that directory. Now that you've saved the config file, reload the server:
sudo service minidlna force-reload
And you're good to go. The server will lurch into life and start indexing your files, which might take a minute or two. While it's getting set up, go ahead and install a DLNA-compliant viewer on your mobile device.
I had good luck with an app named ArkMC that seems to work smoothly for me on the local network.
And that's it! Simple, easy to set up, and it works a charm. Now I can stream locally from a a larger selection of movies, audio or photos than fits on any of the iPads or iPhones. So first up I'll replace the 32GB stick with a 128GB stick, or maybe a 1TB disk drive...
That's the fun of doing it yourself instead of buying a pre-built, bespoke device. Want more memory? Just plug it in. Need different features? Load a different package or get to hackin' it yourself.
Gotta love the Pi.