How To Stream MP4 Video Files From My VPS

This is a really good question and was actually the subject of a support ticket. I scratched my own head for a second and realized the solution was much easier than I thought.

What you need:

  • A virtual private server running Windows or Linux
  • A web server such as Apache, IIS, nginx, Lighttpd, etc.
  • Enough disk space for the operating system and video files
  • Enough bandwidth for your video files

Step One:
Install the operating system

This is relatively easy and I have to assume everyone has done this as there is nothing specific or special you need to install on your operating system except make sure it connects online.

Step Two:
Install the web server

For Apache, it’s relatively easy with most Linux operating systems.

Apache download pageApache for Windows

yum install httpd

Debian / Ubuntu:
apt-get install apache2

For Windows and IIS, the installation is relatively easy since most Microsoft Windows VPS servers come with IIS if you choose Windows Server 2003 or 2008 Web Edition.
Microsoft – Instructions For Installing IIS7 on Windows Server 2008

Step Three:
Disk Space and Bandwidth For the VPS

With a basic CentOS, Debian or Ubuntu operating system on a virtual private server, I mentally give the base operating system about 3 gigabytes with 5 gigabytes maximum. With that understanding, you can look at how much disk space you need for this video streaming.

I am not sure how big your MP4 files are, but since you use and produce them you will know how much disk space you will need for your MP4 files since you are generally unsure how much disk space you need for a Linux operating system.

As far as bandwidth, it’s the amount of data used to transfer a specific file. If that MP4 file is 5mb, it requires 5mb of bandwidth to transfer that file to one person downloading it 100% completely. If it’s watched 100 times, that’s 500mb of bandwidth and if those 100 people tell 900 more people that is 5000mb of bandwidth or 5 gigabytes.

Bandwidth can easily add up rather quickly.

However don’t dupe yourself on unlimited bandwidth services unless it’s a fixed rate like 10, 20, 25, or 50Mbps because a minimum of 10Mbps unlimited means you have full, 24/7 usage of a 10Mbps data port. You can use up the theoretical 24/7 consumption of a 10Mbps port which is 3.3TB of data per month or 3,300 gigabytes.

So technically, 50Mbps would be 16,650 gigabytes and 100Mbps is 33.3 terabytes of data.

For this streaming project of 5mb of MP4 file, 3,300GB of network transfer on a 10Mbps connection is more than enough if we have a small audience but if we have spikes of visitors from social media campaigns, social bookmarking, etc. that 10Mbps connection will max out and that is the disadvantage of an “unlimited” connection that generally locks you into a fixed rate as mentioned above.

When choosing a VPS provider, try to go with one with a shared Gigabit uplink with the VPS node and what this means is a physical Gigabit connection goes to each VPS node. Another provider may take that connection and try to use it between two or more nodes to oversell the bandwidth to reduce costs.

However 100Mbps is only available in locations without great networking infrastructure so please be warned about that and not everywhere has Gigabit uplinks. It should not be looked as a lesser quality of a network or a company because I use tons of companies with 100Mbps uplinks and in the past have used poor companies with Gigabit uplinks so choose carefully, read reviews and make sure to find a reputable provider.

Step Four:
JW Player Code For Your Website

Thanks to the folks at eHow, they made the process very simple with a JW Player tutorial for using the open source video player on your website.

Congratulations on the good job

This is a good idea to stream your video files on your website, rather than offering them as downloads. If you find your bandwidth and disk space is getting expensive, look into compressing your MP4 files into lower or higher quality FLV files which look great but are a considerably lower file size than the MP4 file size.

Also an idea that you can consider is taking 3 VPS servers:

All run the same operating systems and web servers, configured with the same web directory. You can upload let’s say video1.mp4 on and download it to the remaining 2 VPS servers, and in the web directories.

Now you can have your DNS server have multiple “A Records” or subdomains for your domain. Let’s call this A Record / subdomain “video.media.site” for your “media.site” website. With these VPS servers in different locations, let’s say Los Angeles, Chicago and New York you have increased the speed of your video streaming from these individual VPS servers to the visitors which are closest to the area.

If you toss in a VPS server down in Atlanta or Charlotte, North Carolina for Southeast US visitors and the great networking infrastructure in the region, you will have all the visitors on your website happy about your MP4 streaming.

You can have your TTLs for your A Record / Subdomain really low so if you exceed your bandwidth with cheap VPS servers with 500gb – 1TB of bandwidth per month, you can take that A Record / Subdomain out for the VPS IP address and put in a new one with another IP address of a new VPS server.

This reason why you would invest in a system with multiple VPS servers or even one alone is to reduce the load off your primary web server. If you leave your web server’s data connection for text and small image files, your site will load fast.

I have a website that is operated through advertisement revenue.

I have a setup with 5 VPS servers in the US and 2 overseas in Europe to take the usual 1MB or so off of my primary VPS web server’s page loading. That keeps my load times off my primary VPS fast because of small file requests and the idling VPS servers with my image files serve up the images very quickly.

If one VPS goes down, my TTLs are low and I just take out a VPS to load up a new one or just delete the A Record / Subdomain for that IP. It’s really that simple.

For large image files, documents and video files a setup like mine will work however I have not perfected the “perfect setup” where all locations synchronize with a central location. I will be looking into a setup.