Cast Media Content from Raspberry Pi!

The idea for this post comes as a solution to one of the problems that I faced — Sharing content with a group of friends at the same time.

Sharing content (Videos, Music, Pictures) with people around you can be a bit tricky if you have to share large files to multiple people at the same time. By sharing, I mean either the user downloads the content on to his device or just casts it from another device. To do this there are some options available, but none of them seems to be good enough. Here are the popular ones — SuperBeam, SoftwareDataCable. Both these apps can share content but cannot cast it, so they are not done for my purpose!

To solve this issue, I decided to go with DLNA. Find more about it here.

Without wasting any more time, let’s get started. The first and foremost thing that needs to be done is to connect Raspberry Pi to your phone, by connecting I mean wireless connection (who likes those tangled wires!… right? & wireless makes it look cool 8-) ).

To do this, changes are required to be made in the interfaces files on Pi. This will enable the Pi to identify your phone’s wireless network.

A. Connect Pi to your Phone.

I have already written an in-depth article on how to connect Pi to your phone. Here’s the link.

B. DLNA Server set up.

Update the system by using the following commands.

 sudo apt-get update&&sudo apt-get upgrade

Install minidlna server

sudo apt-get install minidlna

Edit minidlna config file.

sudo nano/etc/minidlna.conf

Modify the below-mentioned entries to add your video, audio and picture folders. A point to remember is to create the same Folders (Music, Video, Pictures) in the hard drive that is being accessed.

media_dir=A,/mnt/Music
media_dir=V,/mnt/Video
media_dir=P,/mnt/Pictures0
db_dir=/home/pi/minidlna

Create /home/pi/minidlna directory.

mkdir -p /home/pi/minidlna

Change the permissions for the minidlna folder.

sudo chmod777/home/pi/minidlna

Reload the minidlna with the new config settings.

sudo service minidlna start
sudo service minidlna force-reload

C. Install DLNA client on the phone.

In the previous step, we have successfully setup the DLNA server. To run the content on this server, a client is required. Depending upon the OS installed on the phone download a DLNA client. For android users, I would suggest BubbleUPnP for DLNA.

D. Mount an External Hard Drive.

The SD card on the raspberry pi does not have enough space to store the media content. To counter this, I would suggest attaching an external hard drive. Things become a bit complicated here, normally external hard drives are power hungry, and the USB port on the Pi can output a maximum current of 100mA. Yeah, that’s it! So to make your external drive work properly you need an external USB port with its own power source. All this boils down to the following points:

  • Connect the external hard drive to the external USB HUB (It should be powered externally).
  • Connect the USB HUB to the Pi’s USB port.

For those who don’t know how to connect an external drive, refer this beautifully written tutorial on modmypi.

All the required steps are completed. It’s time to test our setup. Make sure that the raspberry Pi and the hard drive is ready. Check if the dlna service is started. Connect the phone to your Pi, open the dlna client and refresh, you should see the folders from your hard drive :-D

I know that a lot of work! But believe me, it’s totally worth the effort. Now sit back and enjoy your movies.


Originally published at www.awesomeweirdness.com on November 6, 2015.

Like what you read? Give Dinesh Auti a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.