jelleke60
Posts: 39
Joined: Mon Aug 05, 2013 7:49 pm

How-To: Raspberry Pi media SERVER (easy)

Fri Sep 20, 2013 8:59 pm

In this tutorial I will attempt to explain how to turn your Raspberry Pi in a media SERVER to stream media to your home network or even remote network.

This setup will allow the following:
  • -> Stream movies/photo's/music TO your home network and remote network.
    -> Stream to any device (PC/laptop/XBMC/WD Live/Popcorn/Android/...)
    -> SRT support for movies
    -> HD support
    -> Using samba share and FTP share methods
You will need:
  • -> Raspberry Pi with the latest Raspbian image installed http://www.raspberrypi.org/downloads
    -> internet connection to your PI
    -> External USB HDD with media content (ordered in seperate folders)
    -> Another device to stream the content to such as a laptop,media box, ...[/url]
Let's get started

You can use SSH to acces your terminal on the RPI from another device or use the terminal on the device itself by using a monitor/keyboard with the RPI.
In your terminal type the following:

Update your Repo's

Code: Select all

sudo apt-get update
If you are going to use a NTFS based external hard drive (most are) (TIP: ext4 file systems are the fastest)

Code: Select all

sudo apt-get install ntfs-3g
Now insert your usb hard drive in the RPI and wait untill it gets mounted. If it's mounted type the following

Code: Select all

sudo df
A list of installed hard drives will appear. Write down your external HD's location. Mine was /dev/sda1. Type the following commands. (You might want to CHMOD your HDD folder permissions if you get permission errors later)

Code: Select all

cd /media
sudo mkdir HDD
sudo nano /etc/fstab
A file will open, on the bottom of the file type the following and then exit and save the file (ctrl+x, Y, enter, enter). Remember to replace /dev/sda1 with your HDD location. Also replace ntfs-3g with vfat if your have a fat based HDD or ext4 for a ext4 filesystem. Whitespaces are TABS

Code: Select all

/dev/sda1         /media/HDD       ntfs-3g     defaults,noatime      0        0
Back in terminal, type these commands

Code: Select all

sudo umount /dev/sda1
sudo mount /dev/sda1
Your external Hard drive should now always be mounted in the folder HDD. So far so good, now lets install samba and vsftpd.

Code: Select all

sudo apt-get install samba samba-common-bin
sudo apt-get install vsftpd
sudo apt-get install hdparm
sudo hdparm -S 240 /dev/sda1 ##DO THIS ONLY if you want to spindown your external hard drive when it's inactive for 20min, handy if you always want to keep everything powered.
Configure Samba, for home network share (skip if you only want a remote share)

Code: Select all

cp /etc/samba/smb.conf /etc/samba/smb.conf.bak  //Make a backup of the config file
nano /etc/samba/smb.conf
when the file opens scroll to the bottom and paste the following, then save and exit

Code: Select all

[media] 
comment = Media share
path = /media/HDD
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no
Now make an extra account to log into samba on another device

Code: Select all

sudo service samba restart
sudo useradd ChooseUsernameHere -m -G users
sudo passwd TheChosenUsername //after this choose a password for the new user
sudo smbpasswd -a TheChosenUsername //after this enter passwd again
All set! Scroll to the bottom to see how to stream movies on another device now in the home network if you want to skip remote streaming.

Configure remote streaming
First make an extra user (if you skipped samba setup)

Code: Select all

sudo useradd ChooseUsernameHere -m -G users
sudo passwd TheChosenUsername //after this choose a password for the new user
Configure vsftpd

Code: Select all

sudo nano /etc/vsftpd.conf

##Edit or uncomment the following lines ::::
Anonymous_enable=NO
Local_enable=YES
Write_enable=YES
Ascii_upload_enable=YES
Ascii_download_enable=YES

##ADD the following lines to the bottom of the file!
pasv_enable=YES
listen_port=64000
pasv_min_port=64001
pasv_max_port=64040
pasv_address=YOUR REMOTE IP ADDRESS (lookup my ip on google)
pasv_address_resolve=YES
local_root=/media/HDD
important! Now go into your Router settings and forward port 64000 to 64040, to the local IP of your raspberry. Make sure everything has a static address, if you don't know how to do it then lookup another tutorial, there are plenty.

Code: Select all

sudo service vsftpd restart
All done on the Raspberry Pi side! Now take your laptop/XBMC/mediabox!

On a PC/XBMC mediabox where you want to stream to

Note: it really helps if your video files on the HDD are properly ordered and in seperate folders with movie title.
If you are on a laptop/pc then install XBMC for windows/linux http://xbmc.org/download/.

Open XBMC and do the following (for video streaming on the HOME network)
  • -> videos -> files -> add videos...
    Click browse and choose Windows network (SMB) (You could even map the share into a drive first in windows)
    -> Choose the raspberry out of the list and then the folder where your files are
    -> next choose movie scraper and make sure settings are ok, then scan the content, when it's done you should be able to stream movies from your RPI!
For REMOTE streaming
  • -> videos -> files -> add videos...
    Click browse and choose Add network location
    -> protocol = FTP
    -> Address = your remote IP (the one from google)
    -> port = 64000
    -> username = the extra user you made before
    -> pass = the users passwd
    -> click OK and then select it, now choose movie scraper and check the settings
Done! I hope you enjoy your new streaming device!

For me, this works like a charm, i was able to watch HD movies in a Hotel abroad on my laptop, streaming from my RPI at home.
XBMC installs on almost everything (RPI, PC,Linux,Android) so you would be able to stream to all those devices using the above method.

Let me know what you think and ask questions if you like! Greets
Last edited by jelleke60 on Tue Oct 21, 2014 4:19 pm, edited 3 times in total.

lilone21804
Posts: 125
Joined: Thu Aug 01, 2013 11:57 am

Re: How-To: Raspberry Pi media SERVER (easy)

Thu Oct 31, 2013 10:19 am

Is there a way to set this up using Raspbmc?

jelleke60
Posts: 39
Joined: Mon Aug 05, 2013 7:49 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Tue Nov 05, 2013 7:41 pm

lilone21804 wrote: Is there a way to set this up using Raspbmc?
You can use XBMC as dlna server but this didn't stream .srt files when I tried it... I like this setup better and it still works fine. I use it for remote streaming to hotel rooms alot.

raptuz
Posts: 2
Joined: Thu Nov 28, 2013 8:47 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Thu Nov 28, 2013 8:50 pm

is it possible to do this with proftpd?

herofatih
Posts: 3
Joined: Fri Nov 29, 2013 9:28 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Nov 29, 2013 9:31 pm

Super nice. Very well explained. Very easy. Works like a charm the first time i tried and i just got my Pi. :D :D :D .. Exactly what i needed..

zwartepiet
Posts: 1
Joined: Wed Dec 04, 2013 12:44 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Wed Dec 04, 2013 12:48 pm

Must say that this tutorial helped me alot! Good and concise tutorial.

There is only one error.. pasv_address_resolve parameter does not exist in vsftpd. What should be the replacement for that? What does it do?

j0k3r
Posts: 2
Joined: Thu Nov 28, 2013 1:47 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Wed Dec 04, 2013 2:34 pm

I agree this is a great guide, I have a little issue with FTP over the internet using some of the lines of code in .conf i currently have it working but when i get a moment i will go through and confirm settings.

Great Guide :)

sphingomyelin
Posts: 1
Joined: Wed Dec 11, 2013 8:55 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Wed Dec 11, 2013 9:12 pm

First of all, thank you very much for this guide! I got streaming with samba in the local network working in no time, but I have difficulties with the remote streaming over FTP.

Could someone who has a working version please post a vsftpd.conf file?

kaom
Posts: 1
Joined: Sat Dec 14, 2013 1:04 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Sat Dec 14, 2013 1:07 pm

Greate guide! But I'm having problems with the remote streaming. I can't get xbmc to get a connection, any help is appriciated!

Bart61
Posts: 1
Joined: Sun Dec 22, 2013 3:05 am

Re: How-To: Raspberry Pi media SERVER (easy)

Sun Dec 22, 2013 3:11 am

I also agree that this is a great guide but I am having issues connecting remotely as well. When I try to restart vsftpd i get this message...

Stopping FTP server: No /usr/sbin/vsftpd found running; none killed.
vsdftpd.
Starting FTP server: vsftpd.

and I cannot connect remotely. Any ideas would be appreciated.

griso1981
Posts: 1
Joined: Thu Jun 13, 2013 12:36 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Tue Dec 24, 2013 9:35 am

Hi,
I configured samba as listed in this post.
From my remote win XP I can see my USB HDD as network source, btu when I try to access it the login window remains opened and I cannot access to HDD content.

Could someone give me some hints about to resolve this issue?

Thank you

jhiamnot
Posts: 2
Joined: Thu Dec 26, 2013 1:57 am

Re: How-To: Raspberry Pi media SERVER (easy)

Thu Dec 26, 2013 2:02 am

I know if you are behind an AT&T uverse router, then you have to go into the router setting and make an exception for the Raspberry Pi application (using the Port address) --- in the router settings, there is firewall tab and then the "Applications, pinholes, and DMZ"

If you aren't behind this kind of router, disregard. just trying to help.

jelleke60
Posts: 39
Joined: Mon Aug 05, 2013 7:49 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Dec 27, 2013 11:54 am

Thanks to all for your replies and sorry for my long abscense... For those who have problems with remote streaming, please make sure the correct PORTS are forwarded in your ROUTER settings.

Also make sure you have a correct external IP address configured in the vsftpd conf file behind pasv_address. If you have double checked, then check for any firewalls in your network and make sure your ISP allows you to open up the port range you specified.

Another problem that might come up is that large video files might not stream remotely if your upload speed isn't high enough. You should always be able to have a good connection to your FTP service though.

teeth_03
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Dec 27, 2013 1:06 pm

A couple points to make when I did this 6 months ago:

1. I had to chmod the whole directory structure before I had permission to write anything.

2. NTFS is a bad idea, backup your data and reformat using ext4.

3. I had to configure the NFS settings before XBMC on a 2nd Pi could access it.

Do you know anything about using SMART tools for monitoring the drive and sending email alerts if something goes wrong?

jelleke60
Posts: 39
Joined: Mon Aug 05, 2013 7:49 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Dec 27, 2013 5:46 pm

teeth_03 wrote:A couple points to make when I did this 6 months ago:

1. I had to chmod the whole directory structure before I had permission to write anything.

2. NTFS is a bad idea, backup your data and reformat using ext4.

3. I had to configure the NFS settings before XBMC on a 2nd Pi could access it.

Do you know anything about using SMART tools for monitoring the drive and sending email alerts if something goes wrong?
Thanks, I added some of your tips in the tutorial. Also, I don't know SMART tools, I didn't really need more control over the HDD other then putting it to sleep after 10minutes of inactivity since I use this system for personal use only.

teeth_03
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Dec 27, 2013 7:12 pm

Hard drives start to go bad eventually, it would be nice to be able to know when/if they start to develop bad sectors.

pangren
Posts: 42
Joined: Thu Dec 19, 2013 2:52 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Sat Dec 28, 2013 4:07 am

Hi, I'm all the way to the end of the tutorial, i must say it is pretty good but here's something I don't understand. I want to stream video from my pi to my android remotely.
For REMOTE streaming
-> videos -> files -> add videos...
Click browse and choose Add network location
-> protocol = FTP
-> Address = your remote IP (the one from google)
-> port = 64000
-> username = the extra user you made before
-> pass = the users passwd
-> click OK and then select it, now choose movie scraper and check the settings
For the above mentioned instructions, where does it apply? do I turn on the terminal? or is there some android app that has these steps that I can follow? I don't know how to apply the last step bascially.

jelleke60
Posts: 39
Joined: Mon Aug 05, 2013 7:49 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Sat Dec 28, 2013 5:16 pm

pangren wrote:Hi, I'm all the way to the end of the tutorial, i must say it is pretty good but here's something I don't understand. I want to stream video from my pi to my android remotely.
For REMOTE streaming
-> videos -> files -> add videos...
Click browse and choose Add network location
-> protocol = FTP
-> Address = your remote IP (the one from google)
-> port = 64000
-> username = the extra user you made before
-> pass = the users passwd
-> click OK and then select it, now choose movie scraper and check the settings
For the above mentioned instructions, where does it apply? do I turn on the terminal? or is there some android app that has these steps that I can follow? I don't know how to apply the last step bascially.
I'm talking about the XBMC android app here... get it from http://xbmc.org/download/ . Download the .apk and install it on your droid. I have to mention my experience tells me, it requires a decently fast phone (atleast 500mb RAM)

Ofcourse there are also other ways to stream from an FTP source, but XBMC is by far the best option in my opinion...

pangren
Posts: 42
Joined: Thu Dec 19, 2013 2:52 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Sun Dec 29, 2013 6:46 am

Awesome! Thank you very much! I was looking through the google store but could only find the remote. I guess this is really the answer i was looking for cheers!

red red robbo
Posts: 11
Joined: Fri Jan 03, 2014 2:32 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Jan 03, 2014 2:35 pm

I've got to about the fifth step and have hit a bit of a brick wall.

I am unable to save the /etc/fstab file becasue I apparently do not have the correct permissions.

I have tried to change the permissions via both chmod and the UI and both times been denied.

Can anybody help please?

EDIT: Never mind, I was being an idiot. It seems that I was missing the sudo!

dynamitemedia
Posts: 30
Joined: Sun Dec 01, 2013 9:12 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Thu Jan 23, 2014 6:54 am

i am not seeing any window shares on here? is it possible to view those ? got everything else working great tho thanks!

i would like to be able to stream from windows to the Pi

jelleke60
Posts: 39
Joined: Mon Aug 05, 2013 7:49 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Mon Jan 27, 2014 1:47 pm

dynamitemedia wrote:i am not seeing any window shares on here? is it possible to view those ? got everything else working great tho thanks!

i would like to be able to stream from windows to the Pi
Are you in the same local network as the PI? Is the samba service running correctly?

gett
Posts: 1
Joined: Fri Jan 31, 2014 7:37 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Jan 31, 2014 7:41 pm

Sorry for noob question. Can I use this guide to stream from NAS via Raspberry Pi to LG TV?

feichter
Posts: 2
Joined: Fri Feb 07, 2014 2:18 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Fri Feb 07, 2014 2:43 pm

Hi

Thank you for an excellent tutorial !
I am nearly getting there on having it working however have the following problem. I figured that if I put 'ftp://86.xx.xxx.xxx:8080' into a browser (i.e. Google Chrome), I should be able to see all the files on my raspberry pi. The login screen comes up, but when I enter 'root' and 'openelec' the browser says 'Unable to connect'. If I enter 'ftp://192.168.0.99:8080' then everything works fine and I can see all my files.

I have openelec 3.2 and xbmc 'Frodo' installed.
The vsftpd.conf file has the following at the end:

pasv_enable=YES
listen_port=8080
//pasv_min_port=64001
//pasv_max_port=64040
pasv_address=86.xx.xxx.xxx
pasv_address_resolve=YES
local_root=../../downloads/Movies

Also, I don't seem to be able to execute any sudo commands, therefore can't create a new user.

I know the above is not secure, but once I have this working I can make it secure.

Many thanks for any help...

feichter
Posts: 2
Joined: Fri Feb 07, 2014 2:18 pm

Re: How-To: Raspberry Pi media SERVER (easy)

Sat Feb 08, 2014 1:16 pm

Sorry... mistake in my previous post!

//pasv_min_port=64001
//pasv_max_port=64040

should of course be:

#pasv_min_port=64001
#pasv_max_port=64040

Return to “Teaching and learning resources”

Who is online

Users browsing this forum: No registered users and 1 guest