VoD server

From the old weebly site:

I decided to write this in perl – I am confortable with the language, and have had experience in using it to query XML/HTTP based servers before as part of my job, so for me it is a natural choice. With an extensive (free) library available on CPAN, we can create a HTTP server that we simply “plug in” our code to without having to worry about any of the HTTP transport layer;  a JSON encode/decode library that translates to/from JSON to standard perl data structures; and a simple interface to a MySQL database server – perfect! Here is the first cut:

Dropbox links:

server: https://www.dropbox.com/s/ne37sihr2loq74c/myserver?dl=0

server.conf: https://www.dropbox.com/s/h4l7yy8d7j8ux5j/myserver.conf?dl=0

So, how do I set this up?

PC with 2 network interfaces plus storage – the storage can be anything that Linux can mount, so internal/external HDD, NAS storage etc.Software:
Linux – any version less than a handfull of years old will do fine, I use CentOS 5.7 (because I had it already).

NIC 1: connects to your home network or ADSL modem/router. I use on this, but any private netwrok address (eg is fine.
NIC 2: connects to the TBox (you will need either a small network switch or a “A” to “B” cross-over network cable) I use – if you use a different address, that is fine, but you will need to adjust the network addresses appropriately.

I installed webmin (CPanel would laso work, but webmin is free!) which makes the database setup easier.

install named – my configuration file is:
Install dnsmasq – my configuration file is:

dnsmasq.conf: https://www.dropbox.com/s/hixya1d5zdss77c/dnsmasq.conf?dl=0

Due to the vagaries of DNSMasq and named, you need to ensure DNSMasq runs before named.

If your media is stored locally and/or your media can’t be accessed via HTTP, install apache and configure it to serve files where your storage is mounted.

Ensure there is file called default.jpg in the root of your media storage. It doesn’t need to be anything in particular, but if it doesn’t exist, the database build will never complete.

Ensure none of your media files use square brackets in the file name, as the TBox does not handle these!

Install ffmpeg package (this gets data from your media such as duration, codec etc. It also lets you extract jpeg images from video files)

Install MySQL.
set permissions to allow passwordless root access from loopback interface (
create database “video”
create tables:
var: varchar(128)
value: varchar(512)
navid: integer, null not allowed, default 0, primary key
title: varchar (128)
parent: integer(11)
navid: integer(11), null not allowed, default 0, primary key
contentid: integer(11), null not allowed, default 0, primary key
title: varchar(128)
imageurl: varchar(512)
description: varchar(4096)
duration: int(11)
contentid: int(11), null not allowed, default 0, primary key
mediaid: int(11)
duation: int(11)
groupid: int(11)
mediaformat: varchar(32)
contentid: int(11), null not allowed, default 0, primary key
bitrate: int(11)
mediafileid: int(11)
url: varchar(512)

Then add the following entries into the config table:
var = “path”; value = <where your media files live> (ie, the mount point of your storage, eg “/home/media”)
var = “url”; value = <where your media can be accessed by HTTP> (eg, “;)

Install the following perl packages from CPAN (from bash shell: perl -MCPAN -e “install <package>”):

Configure linux firewall:
Turn on “act as a router”
masquerade where outgoing interface = NIC1
redirect to port 8002 where destination address = and incoming interface is NIC2 and protocol is TCP and destination port is 80.

configure the myserver script to run a boot time (I added it to my /etc/inittab file)

With the media storage mounted correctly, go to  <NIC1 address>:8003 and click on “rebuild database” – this can take a long time if you have lots of videos, as it scans each file for codec etc.

Re-start the machine and check that:
“dig tbox.bigpondvideo.com @” returns
“dig tbox.bigpondvideo.com” returns some other address not on your local network (the real server address!)

Make sure your TBox is using the ethernet connection.
Put your TBox into sleep mode (from turned on, hold down the power button until the banner appears at the bottom of the screen)
Wake your TBox up.
Check your TBox setup to be sure you have full internet connectivity (if not, your firewall setup and/or DHCP/DNS setup may be incorrect!)
Get the TBox menu and select “Bigpond Videos”
The menu you now see will be a list of directories from your media storage! Select what you want to watch, grab the popcorn and enjoy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s