Portable Media Server w/ Wireless Access Point Complete Guide
Emby Server on a Raspberry Pi
Portable Media Server w/ Wireless Access Point
This is one of my favorite DIY project. It covers several complex topics, however it can be easily completed by following this guide. It's okay if some of these concepts don't make sense, all you need to do is copy and paste a few lines of code and you'll be set! This server is perfect for trailers, houseboats, road trips, etc. It uses a small Raspberry Pi and Emby server, which is incredibly small and light weight, providing an incredibly simple solution for portable streaming.
What You'll Need
Raspberry Pi Setup
Installing the Right Operating System
For this setup we will be using the Raspberry Pi OS Lite. This Operating System is lightweight and will allow for a more quick and seamless streaming process at the end of the day. Because the Raspberry Pi OS Lite has no desktop environment, you will need to be able to use the command line on your Mac or PC in order to complete this tutorial (I will be using a Mac). Don't worry if you're not very experienced using the command line though! I will do my best to walk you through each step.
The Raspberry Pi Foundation has a great tool for formatting your SD card and installing the Rasbian OS all in one go.
Install the Raspberry Pi Imager to your computer.
2. Once open, you will need to select the Operating System that you would like to flash to your SD card. Select Choose OS -> Raspberry Pi OS (other) -> Raspberry Pi OS Lite (32-bit). Once this is done, eject your card and insert it into your Raspberry Pi.
Connect your Pi via an HDMI cable to a computer monitor and wait for it to boot up, you will also need a wired keyboard to interface with the pi directly.
You will need to enter some login info to access the pi. The default username is pi and the default password is raspberry.
3. Once logged in, enter
This will take you to a simple Graphical User Interface. Navigate the interface with the arrow keys and the enter button on your keyboard.
4. Go to 'Interfacing Options' and hit enter. Now go to 'SSH' hit enter, and select 'Yes' on the next screen.
Great! Now SSH is enabled on your Pi and you can now interact with it directly from your computers command line! But were not done yet, just a few more steps before we're ready to connect your pi to the world wide web.
5. Next, go to 'Change User Password' and create a new secure password. This will be your new password when trying to login.
6. Finally, go to 'Network Options' then go to 'Hostname' and enter a new, valid Hostname. I will name mine 'mediaserver'. We will use this hostname to access the Pi via SSH later on, so make sure it is something that is both unique to your network (i.e. it could cause problems to have two raspberry pi's with the same hostname connected to your network at the same time) and easy to remember.
7. Once that is done, hit 'Finish' and say 'Yes' to rebooting the Pi.
Connect via SSH
Now that your Pi is configured for SSH, you can now unplug it from the monitor and use an Ethernet cable to connect it to your home router. Note** I am using a Mac computer, so the following instructions may be different for PC users. If you would like to follow along on a PC, I would highly recommend downloading PuTTY.
Launch a new terminal window (on a Mac hit Command + Space at the same time and type 'Terminal').
From the terminal type the following command:
where 'pi' is your login username and 'mediaserver' is the hostname that you setup in the Enabling SSH step above. You can alternatively use the Pi's IP address if this doesn't work for you, however you will have to know the IP address of the Pi:
You may be prompted with this warning:
Just type 'yes' and hit enter.
4. Enter your login password for the Pi and you should now be granted access to your Raspberry Pis command line.
5. Now lets make sure all the packages are up to date by running
sudo apt update
sudo apt full-upgrade
Say yes to any upgrades it may need, this may take a few minutes.
Great! Now everything is up to date and you are ready to start configuring your server!
Set up Your Raspberry Pi as a Wireless Access Point
If you are planning on using your Raspberry Pi as a mobile media server for vacation or travels, then enabling this feature is a must! This section can be difficult to complete, and if anything should go wrong, feel free to start over from the beginning by reformatting and reinstalling the Operating System to the SD card. Yes it is a pain to go all the way back and start from the beginning, but trust me, sometimes it's better to start over than to spend hours and hours trying to fix a mysterious bug in the system.
This section will heavily (like almost word for word) reference this article from the Rapsberry Pi foundation, but it will omit some unnecessary steps.
Don't worry too much about any terminology you may not understand, you will be able to complete these steps by simply copying and pasting the code snippets as directed.
Install the Access Point and Network Management Software
You will need to install the hostapd access point software
Enable the wireless access point service and set it to start when your Raspberry Pi boots:
In order to provide network management services (DNS, DHCP) to wireless clients, the Raspberry Pi needs to have the dnsmasq software package installed:
Finally, install netfilter-persistent and its plugin iptables-persistent. This utilty helps by saving firewall rules and restoring them when the Raspberry Pi boots:
Wow, by entering all of those commands you just installed a whole bunch of powerful software on your Raspberry Pi! Right now this software isn't doing anything though, so we will now begin to configure it so it can be used by the Pi.
Set Up the Network Router
The Raspberry Pi will run and manage a standalone wireless network. The Raspberry Pi runs a DHCP server for the wireless network; this requires static IP configuration for the wireless interface (wlan0) in the Raspberry Pi. The Raspberry Pi also acts as the router on the wireless network, and as is customary, we will give it the first IP address in the network: 192.168.4.1. In a nutshell, we need to give the Raspberry Pi a static IP address on the Network.
To configure the static IP address, edit the configuration file for dhcpcd by entering the following command:
You are now inside of the Nano editor, which may be very different from any other editor you've used before. Be very careful not to make any unwanted changes to prevent any unwanted bugs in the system. You navigate the Nano editor with the arrow keys go to the very bottom of the file and add the following:
The file should end up looking like this:
Now hit Command + X to exit the file. It will ask if you want to save the changes, press 'Y' and then hit enter.
Enable Routing and IP Masquerading
To enable routing, i.e. to allow traffic to flow from one network to the other in the Raspberry Pi, create a file using the following command, with the contents below:
Paste these contents into the file:
Save the file.
Add this single firewall rule in the Raspberry Pi:
Save the firewall rules:
Configure the DHCP and DNS Services for the Wireless Network
The DHCP and DNS services are provided by dnsmasq. The default configuration file serves as a template for all possible configuration options, whereas we only need a few. It is easier to start from an empty file.
Enter the following commands to rename the dnsmasq template and to create an empty file.
An empty Nano document will now be open. Copy and Paste the following inside the document and then save it:
Remember, to save the document just hit Control + X, then Y, then Enter.
The Raspberry Pi will deliver IP addresses between 192.168.4.2 and 192.168.4.20, with a lease time of 24 hours, to wireless DHCP clients.
Ensure Wireless Operation
Countries around the world regulate the use of telecommunication radio frequency bands to ensure interference-free operation. The Linux OS helps users comply with these rules by allowing applications to be configured with a two-letter "WiFi country code", e.g. US for a computer used in the United States.
In the Raspberry Pi OS, 5 GHz wireless networking is disabled until a WiFi country code has been configured by the user, usually as part of the initial installation process (see wireless configuration pages in this section for details.)
To ensure WiFi radio is not blocked on your Raspberry Pi, execute the following command:
This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next.
Configure the Access Point Software
First, you will need to create a hostapd configuration file which needs to be located at /etc/hostapd/hostapd.conf. Use the following command to create the file:
Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of MediaServer, and a password MyMediaServerIsTheBest. Note that the name and password should not have quotes around them. The passphrase should be between 8 and 64 characters in length. Make sure to update the country code to the country you are residing in. Click here for a list of possible ISO country codes.
Save the file when you're done.
Verify That the Access Point is Functional
Now you will need to restart your Pi to verify that the wireless access point becomes automatically available.
Once your Pi has rebooted, the network SSID you specified in the /etc/hostapt/hostapd.conf file should now be available. You should be able to see it when trying to join the WiFi on your phone, tablet or computer. Try connecting to it with the password you specified! Remember, you won't be able to connect to the World Wide Web with this wireless connection, but rather you will be able to connect to any server that you set up on the raspberry pi, which is what we are going to do next!
Install Emby Media Server on Raspberry Pi
Find the most Up to Date Version of Emby
Find the most recent release of Emby for the Debian operating system by clicking here.
Once on the page mentioned in step 1, click the drop down under 'Operating System' and change it to 'Debian'.
Now find the (armhf) version and right click the link and click 'Copy Link Address' as shown in the image.
You are now going to create a wget command by typing wget in the terminal and then pasting the link you have just copied right after it.
As of the writing of this article, the most recent release was version 184.108.40.206, so my wget command would look like this:
5. Once that is done downloading, go back to the Emby website and copy the command from step two. As of this writing, that command looks like this:
This will install the download onto your raspberry pi.
6. Great! Now Emby is installed and ready to use! Follow the next steps on a separate device (i.e. a phone or tablet if one is available to you) in order to test out your new server!
Accessing Emby Server
We're not doing any configuration in this step, we are just testing things out and making sure they're working properly.
Disconnect the pi from the router and then use a phone, computer or tablet to connect to your new wireless access point.
Once connected, go to your favorite browser and enter the following IP address:
That 8096 after the IP address is the Port that Emby Server listens on.
You may get an error message like the I got in this image. Don't worry, that is expected! Remember, the Raspberry Pi isn't actually connected to the World Wide Web, it is only creating a connection between you and itself.
Now that you can see that it works, try connecting the Pi back to the router and reboot the pi:
Once it's turned back on, connect back to your home network and try to access the pi through the network by using the Pi's hostname that you set at the beginning of this article. In my case it was:
Cool right?! You can access the media server through both your home network when it's plugged into the router and also through the private network that is broadcast by the Pi. This means you can take the Pi anywhere and stream from the media server!
We're almost done! Now all we have to do is to mount an external storage device to the Pi so that you can store all of your media in one place!
Set Up Your Hard Drive For Emby Server
If your drive isn't already using the ExFAT file system, you will need to reformat your drive. This is very simple on a Mac. First go to 'Disk Utility' and find the External Hard Drive that you are wanting to format. Click on the drive you are wanting to format, and ensure that this is the correct drive. Reformatting the drive will erase all of data on the drive so you want to make sure you don't format the wrong drive. Now click 'Erase' on the top bar and make sure the format selected is ExFAT and then click Erase.
The process is very similar on a PC, just right click the drive and click 'Format'. Choose ExFAT as the file system (and make sure its partitions are at least 4000KB) and format the drive.
Movie/TV Show Naming Conventions
- Note: I do not condone Illegally obtaining media online or through any other means. Please add Movies that you own and have obtained legally.
Emby Server requires a specific naming convention for your Movies and TV Shows so that they can be properly Identified and Organized within the Server. By following this structure, Emby Server will be able to find metadata (info about the actors, movie poster images, etc) about your Movies and Tv Shows online while your Pi is plugged into your router. You can view the Emby documentation for more in depth on file naming structures here.
Once you've prepared your media files, it's time to name your media in a way that allows Emby the best chance of determining what it is. The best way to do this is to use the format: "MovieName (year).extension" such as "Top Gun (1986).mp4" or "Avatar (2009).mkv". Because Emby allows many other advanced functions that can be used with your media we want to create a folder structure that aids in this use. The simplest method of doing this is to put all media related to a Movie in the same folder using a name "MovieName (year). Emby will then use the folder name to determine the movie. It will look like this:
Having the year in the series name is not strictly mandatory as Emby can usually match a series without it but it helps tremendously with rebooted series and those that have broadcast in different years such as Battlestar Galactica (1978) and Battlestar Galactica (2003). The year is also very helpful for some series such as Africa (2013) which could potentially match to a few different shows without the year.
\Rick and Morty (2013)
Rick and Morty S01E01.mp4
Rick and Morty S01E02.mp4
Rick and Morty S02E01.mkv
Rick and Morty S02E02.mp4
Mounting the Drive to Your Raspberry Pi
We are now going to set up the drive so that it always mounts to a specific location on your Pi. Make sure your Pi is connected to your router, and then plug your hard drive into the Pi. SSH into the Pi from your computers terminal, because my hostname is 'mediaserver', the command will look like this:
Once logged into the Pi, we will list all of the disk partitions with in the following command:
2. Use the SIZE, LABEL, and MODEL columns to identify the name of the disk partition that points to your storage device. In this case, I can see two rows that have 931.5 Gigabytes of memory, that is the size of the drive that I plugged in so I know that this is my drive. From this info I know that my drive is sda1.
3. Because we have formatted our drive to use the ExFAT file system, we need to also install the ExFAT driver with the following 2 commands:
4. We will now run the following command to ensure that we have grabbed the correct UUID for your drive.:
My drives location was /dev/sda1 (you may also identify your drive by the label if present), make a note of the drive UUID, we will need this for later. Mine was '4CAC-BDAC'
5. We are now going to create a folder to be the new mount point of the storage device. In this case, I'm going to name the mount point 'Media'.
6. Now we will modify the fstab to tell the Pi to automatically mount the drive to the new mount point every time it starts up:
7. Paste the following into the fstab file, where the UUID is the UUID of your own drive and /mnt/Media is the name of the mount point you just created:
8. Save the file with Control + X, then Y, then Enter.
9. Reboot your Pi and make sure the disk mounts correctly:
10. Once restarted, look at the files in your new mount point and make sure your hard drive files appear:
Notice that the movies folder and TV Shows folder now appear in the mount point.
Congrats! Now we are ready to let Emby Server access the external drive and stream Movies and Tv Shows directly from it!
Configuring Emby Server
Finally! You've made it to the last (and easiest) step! Now all we have to do is set up Emby server and let it know where we intend to store all of our Movie and TV Show files. This section won't cover all of the features that come with Emby server, but after tinkering around with the service for a bit you'll be able to see how powerful it can be! I think it's also worth while to note that I am in no way affiliated with Emby, nor have I been compensated in any way for endorsing them, I've just really enjoyed their service so far. If you wanted to use another service (such as Plex) I'm sure you could accomplish the same goal.
Lets just right in! Make sure that your Pi is connected to your router and that your computer is connected to your local home network.
Access Emby server from your home network by using the Raspberry Pi's hostname, i.e. My pi's hostname is mediaserver, so I will type:
You will need to replace whatever your hostname may be with 'mediaserver'. You can alternatively use you Pi's IP address by typing the following into the url bar and replacing the placeholder IP address with your Pi's address:
2. Great! You should be greeted with a startup screen that will look something like this. Select your preferred language and then click next.
3. Create a username and password, these will be the credentials you will use to access your media (much like your login and password to access your Netflix account).
4. On the Setup Media Libraries page click 'New Library'. We are going to create a Movies library that will reference the Movies folder in your hard drive. Set the content type and display name to 'Movies'. Click the plus button next to folders and search for the mount point that you created for your hard drive (it should look something like /mnt/Media).
5. After clicking on your mount point, select the folder that contains all of your movies. My folder was (rightfully so) named Movies, so my folder path was /mnt/Media/Movies. Simple!
6. Fill in the rest of the settings by entering your languages of choice and country of origin. There are many options that you can enable, but I will not be going through those at the moment (this post is long enough already). However I would highly recommend selecting 'Save artwork into media folders'.
7. Now just repeat the process for your TV Shows or for any other media you would like to add!
8. Finish the setup by leaving the default settings selected.
YOU DID IT!
It may take a little bit for your media to load depending on how much is already present on your drive. But notice how Emby automatically goes and and retrieves metadata about all of your media?! Cool right?! If you're still curious about how to use your server, feel free to continue reading. If not, I totally get it, this has been quite the project and you deserve a big pat on the back.
How to Access Emby Media Server
You've probably noticed already, but there are several different ways that you can access your new server and start streaming. There are essentially three main methods, streaming from your home network, streaming from your portable network, and streaming from the Emby app (requires an active Emby Premiere subscription).
Streaming From Your Home Network (No Subscription Required)
If you're at home, and your Pi is connected to your router, you can access the media server without having to change networks (as you've seen above). Simply go to your favorite internet browser and type in your pi's Hostname like this (replacing 'yourhostname' with your Pi's actual hostname):
Or you can access it by entering your Pi's IP address:
Streaming From Your Portable Network (No Subscription Required)
Whenever you want to stream movies on the go, whether it be while you're in the car, train, or plane, or even if you're camping in the middle of no where, just bring you're Pi with you and as long as you're able to keep it powered (I like to use this battery on the go to keep the Pi powered) you'll be able to stream movies and tv shows to your hearts content!
Use your phone, tablet, or computer to connect to your Raspberry Pi's Network. If you followed along with the tasks above, mine was called 'MediaNetwork'.
Once connected go to your favorite browser and enter the following address:
Presto! You're now connected to your Media Server and can stream movies in even the most remote of locations!
Streaming with the Emby App (Subscription Required)
If you really want to splurge, you can purchase an Emby license here. One of the many advantages of using the app is that you will no longer have to remember those pesky IP addresses and/or hostnames to access the server. You can simply open the app and it will automatically search for your server. The app also seems to be able to stream content a little better than through the webpage. The app is also nice because you can not only install it on your phone or tablet, but you can also install it on an Amazon Fire TV Stick, smart tv, etc. which can make home streaming simple and easy. I originally did not intend on buying a license, however after a few months of using the service for free I eventually caved and bought the lifetime subscription (which I highly recommend) and I've loved it since.
Overall, I personally have absolutely loved this setup and have been using it for the past 8 months. My new favorite activity has been setting up a projector screen out in the middle of no where and then using my projector, Amazon Fire TV stick, and Raspberry Pi media server to stream endless Movies and TV Shows at night while I'm camping. Additionally it works wonderfully for long car rides when my nieces all want to watch different movies, they can all separately connect to the media server and stream whatever movies they want. Emby even has a feature to set up kids accounts that automatically filter out movies with inappropriate ratings. I hope this article could be of some use, and if anyone has a question please reach out.
Scanning New Files into Emby
Oh and one last thing before I forget. As you continue adding media to your library, make sure you rescan your library files so that Emby can add them to the server. It's really simple, just go to your Dashboard on Emby and click the 'Library' tab to the right. Once you're there, click 'Scan Library Files' and Emby will find all of the new media you have added to your drive, and it will make it accessible on your server.