Streaming Multimedia Server


A media server on a local network allows you to centrally manage your movie or music collection while having it available on any host of the network. More advanced configurations will let you broadcast ("multicast", see further) audio, video, announcements, pictures, ... to all or a selection of host to your network, or server content "on demand"

Here are some examples on how to set up a media server for a local network.

Basic example : streaming a media file

We'll start with something simple : streaming a file from a server to a client. This will illustrate the basics of streaming with vlc (videolan), and help to understand the more complex configurations later.

Server Installation

Start with installing vlc-nox + (optionally) some support for Windows media formats (w32codecs) and dvd's.
We also create a dedicated user account on the server, so we have a non-root user to manage the media files and run vlc. This user has as home directory the directory where we keep the content that we will be streaming later.

    apt-get install vlc-nox
    apt-get install w32codecs libdvdcss2
    
    ## create a user account that will run vlc on the server
    adduser videolan 
    chown -R videolan:videolan /srv/stream/
    usermod -d /srv/stream/ videolan  && rm -r /home/videolan
    

We use vlc-nox (command line vlc) as server. You can also use plain vlc, but that requires a desktop environment (or at least the X window server system). Note that there used to be a separate server component to VideoLAN, VLS or vls , but that has been depreciated. Use vlc(-nox) in stead.

client setup

for simplicity, we start by using vlc as media player because it's 100% compatible with all features of vlc on the server. Note that vlc is used both as a streaming server and as a (streaming) media player. We'll look into other media players later.

    apt-get install vlc
    

streaming a movie from the server to the client

See also Videolan Howto : streaming a file, or in the Videolan Wiki.

The gist of it is : run vlc on the server and tell it what you want to stream (eg a movie file) and to whom. run vlc on the client(s) so they'll receive the stream and render (display, play) it.

On the server :
log an (as 'videolan') and run
vlc <file> --sout udp:<host> [--ttl n ]
where
On the client :
run vlc udp:
or : select vlc from the menu, and select udp as input stream

Note that some controls (FF, RW, continuous play, Pause, ... ) will only on the server. The client is just a receiver of whatever the server transmits. Look into more advanced setups (see further) for ways to deal with this.

add -v (or -vv or -vvv ) to those commands for more verbose output.

Multicast : Sending a file to multiple clients simultaneously

You can send the same stream to multiple clients. This works as a radio or TV broadcast : the server emits the stream, and any client on the network can 'tune in' and start receiving it. It's a convenient, bandwidth-friendly solution to get the same output to multiple displays, e.g. to provide (identical) music or video footage to multiple hosts.

It works identical to streaming to 1 client, but in stead of a hostname or ip address, you stream to a multicast address. This is a special ip address that reaches all hosts on a network at once, without having to duplicate the data for each client. The address 224.0.0.1 means "All Hosts On This Subnet" (multicast addresses). With multicast, you also need to specify how many routers your stream may travers. For a single network (no routers), 1 hop is just right. The number of hops parameter is required for multicast, and optional for unicast (1 client)

server :
vnc /srv/stream/WarGames.avi --sout udp:224.0.0.1 --ttl 1
On the client :
vlc udp:
or : select vlc from the menu, and select udp as input stream

That's it

That's all there is to it - you have a media streaming server that can stream content to one or all hosts on your LAN.

Time to look at some more exotic configurations ...

notes on additional packages

installing vlc-nox (server) will automatically install required packages to support media and media formats. Due to patent restrictions a.o., additional support for certain media (dvd) and formats may have to be installed separately. Same goes for support for more exotic features. Here's a list of packages that you may need sooner or later :

vlc dependencies :

Corresponding debian packages (may be incomplete, and package names may change over time) :

Links

You can set up a streaming media server as added value to your small business Linux server


Koen Noens
June 2008