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!
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 (29 March 2018):
- Fixed some minor issues in a few commands and added the dos2unix tool to help make the 2 copied files work in linux.
- 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.
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.
The basic steps to completion is as follows:
- Get the Raspberry Pi up and running
- Update and install packages
- Configure minidlna
- Configure statis IP and DHCP server
- Configure hostapd
1. Get the Raspberry Pi up and running
- Download Raspbian.
- Download and install Win32 Disk Imager.
- Use the disk imager to write the Raspbian image to a micro SD card.
- Plug the card into the RPi. Ensure that its connected to a monitor and also connect a keyboard.
- Once powered, it displays the boot sequence.
- Login using user ‘pi' and password ‘raspberry'.
- Start the configuration (by running ‘sudo raspi-config').
- Expand the File System, enable SSH, set auto login (console), time zone and country and the keyboard layout. Save and chose to reboot.
- Now stick in a USB flash disk with some videos on the root of the disk (will be used later).
I wanted to connect through Wifi, so I had to edit the config file to get this going.
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following lines to the end of the file (replace with your network details)
Save the file and reboot by running
Login again and ping google.com to see that you have connectivity.
Install all the required packages now as some of them are required when you may no longer have an internet connection.
sudo apt-get update
sudo apt-get install minidlna isc-dhcp-server hostapd
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 *
Add the following line to the file .bashrc in home directory, then save the file.
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.
sudo mkdir -p /media/pi
sudo chmod 755 /media/pi
Edit the configuration file
sudo nano /etc/minidlna.conf
and change the following lines (according to your setup).
# Change directories to match your setup
db_dir=/var/cache/minidlna # Uncomment
log_dir=/var/log # Uncomment
friendly_name=“Raspberry Pi” # Just to have a cool name displayed
Save the file and reboot by running
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.
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).
iface wlan0 inet static
5. Configure DHCP server
Edit the DHCP configuration file.
sudo nano /etc/dhcp/dhcpd.conf
Add the following lines at the end
subnet 192.168.1.0 netmask 255.255.255.0
range 192.168.1.100 192.168.1.200;
Save the file and then run the following
#bring up the interface
sudo ifconfig wlan0 192.168.1.1
#restart the DHCP server
sudo /etc/init.d/isc-dhcp-server restart
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
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
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.
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!
A few things that could be made better is:
- Use a web interface to configure the device according to you liking.
- Adding a 3G dongle to allow surfing the web as an additional service.
- Use a Pi Zero instead of the the Pi 3.
Read More Detail: Portable media server and access point