Portable media server and access point

Stream videos (and other media) to mobile devices/tables while on the go. Great for streaming video to iPads in a car on a long road trip!

Story

Background

The reason for creating this project in the first place was because I hate Apple. Both my kids unfortunately have an iPad mini 16GB. But Apple does not afford you the luxury of adding the option of SD cards and the iPads are so full of games, there is hardly space for movies while we go on a long road trip.

In the beginning I bought them small Android tablets just for in-car entertainment. But this was a nightmare to manage and keep things charged. Even if charged, you could hardly get through 2 movies with one charge.

So I thought, what if I can use my Raspberry Pi as a media server (similar to my NAS at home) and then stream content to their iPads (and any other device for that matter). To avoid using another mobile WiFi router, I would also want to set the Pi up as an access point.

Update – recent improvements (8 December 2016):

I now use a script to rebuild the database media files indexes at startup. This is just because I could not get the notify functions in minidlna working.

It now also detects the first available USB drive at startup and uses that as the default for the media drive. Unfortunately, if you plug the drive in when Pi is powered, it requires a restart.

Update – recent improvements (29March 2018):

Fixed some minor issues in a few commands and added the dos2unix tool to help make the 2 copied files work in linux.

Hardware

Raspberry Pi Model 3B (but Model 2 will also work – would just need a Wifi adapter)

USB drive (any size that can fit the media you have)

MicroSD card (for the PI operating system – I used 16GB)

Powerbank (I used Ramoss Sailing 3 – 7800mAh)

Connecter (micro USB to USB)

Additionally, during development, you need to connect the Pi to a TV or monitor using a HDMI cable, power the Pi, connect it to the internet (via ethernet or WiFi) and also connect a keyboard & mouse.

Platform

I used Raspbian (Jessie Lite, kernel 4.4, 25 November 2016) operating system (OS) as it is easy to work with and Jessie is the latest version at the time of writing. Jessie Lite is the same core as Jessie but without X server (or the new Pixel desktop) pre-bundled.

2. Installations

Copy the 2 attached files to the /home/pi (also known as ~) directory. You can use a cool application called WinSCP. After copying the files, set the permissions and run the files through the dos2unix converter to ensure it is readable in linux.

sudo chmod 755 *
sudo dos2unix

Add the following line to the file .bashrc in home directory, then save the file.

sudo ./startup.sh

3. Configure minidlna

Create the directory to be used for the mount point and set the appropriate rights to be able to read and execute all the files when mounted.

To test the streaming at this stage, you can use an app on you phone or use a smart TV (connected to the same local network) to see if you can see the streaming service called “Raspberry Pi”. It will stream to your device without an issue. I used VLC and VidOn but prefer VLC.

4. Create a static IP address

Edit the config file.

sudo nano /etc/network/interfaces

Comment out the current wlan0 lines (except for allow-hotplug wlan0 ) and add the following lines (note that I only focus on wlan0, not eth0).

6. Configure hostapd

Hostapd (Host access point daemon) is a user space software access point capable of turning normal network interface cards into access points and authentication servers. Had some help on this section from here and here.

Create and edit the config file

sudo nano /etc/hostapd/hostapd.conf

Add the lines (ensure your password is between 8-64 characters otherwise the service will not start)

Edit the default config file to tell hostapd to know where to look for its config file.

sudo nano /etc/default/hostapd

Uncomment the line #DAEMON_CONF=”” and set it as follows

DAEMON_CONF=“/etc/hostapd/hostapd.conf”

Run the following command to let hostapd service start automatically on boot

sudo update-rc.d hostapd defaults

I found that there is sometimes a big startup delay due to dhcpcd daemon trying to start up. To eliminate the delay, run the following.

sudo systemctl disable dhcpcd.service

Reboot.

Now the Pi will be visible as a access point. If you connect to it (using the credentials specified above) you will be able to stream the movies from it that is on the flash disk.

Conclusion

I am very satisfied with the final product. Thanks again to the sites listed throughout the text above for their help in some places I couldn’t get past. I thoroughly enjoyed playing around to get this functional tool going. I have tested this procedure numerous times now and it works flawlessly every time. Please shout if you find a bug!