Prepare VDR LiveTV for limited bandwidth howto


I assume that you already have a working VDR on your PC. If not you can install VDR from the sources or get binary packages which made for all well-known Linux distribution (in my case it’s Debian).

The solution

The solution is clear – scale bandwidth down due to some reasonable value. It can be done by several ways but the most appropriate way is using external callback of VDR plugin streamdev-server. Streamdev-server listens port 3000, gets PES, PS, TS or ES and streams it over LAN.
Hovewer, if you call streamdev-server with parameters Extern it provides the stream to the filesystem via FIFO. It creates the stream to /tmp/out.avi that an external transcoder can grab and process on the fly. Streamdev-server invokes an external script which can be used to call an application that will process the stream.


You should install VDR plugin streamdev-server to have possibility to stream LiveTV over LAN. Just add this repository to your apt sources.list:
deb sarge base backports addons vdr-multipatch
and run
apt-get update
apt-get install vdr-plugin-streamdev-server

To configure streamdev-server we have to set correct access permissionsits in the /etc/vdr/plugins/streamdevhosts.conf:
# streamdevhosts This file describes a number of host addresses that
# are allowed to connect to the streamdev server running
# with the Video Disk Recorder (VDR) on this system.
# Syntax:
# IP-Address[/Netmask]
# # always accept localhost # any host on the local net
# # a specific host
# # any host on any net (USE THIS WITH CARE!)

After restart VDR you should see streamdev-server in the list of loaded plugins:
Restarting Linux Video Disk Recorder: vdr
Rewriting remote changes
Searching for plugins (VDR 1.3.49/1.3.47): streamdev-server xine skinelchi
Checking remotes.

To test the streaming run a following command:
mplayer http://vdr-IP-or-host:3000/TS/1
You should see a video if everything ok.

To process the stream we’ll use MEncoder which is a part of of MPlayer package. But I found only separate packages. So, I installed them both:
deb stable main
deb sarge main

And after that just install mplayer and mencoder using apt-get.

As I already mentioned above streamdev-server can use callback mechanism that allows to call an external script. The name of the script is hardcoded in the streamdev-server – /root/ So, let’s create it and grant its right permissions:
touch /root/
chmod 0755 /root/

Now it’s time to put the logic in out script:
rm -f /tmp/out.avi /tmp/out.log
/usr/bin/mkfifo /tmp/out.avi
cat /tmp/out.avi & /usr/bin/mencoder -ovc xvid -xvidencopts bitrate=75 -ffourcc XVID -oac lavc -lavcopts acodec=aac:abitrate=20 -vf scale -zoom -xy 200 -channels 1 -o /tmp/out.avi &>/tmp/out.log

You can play with parameters which described in the Chapter 12. Basic usage of MEncoder or Mplayer manual.
We should tell streamdev-server that it should use external script. To do that just create a new file /etc/vdrdevel/plugins/plugin.streamdev-server.conf and add there a following line:
-r /root/
Restart VDR and test processed stream (use Extern as source):
mplayer http://vdr-IP-or-host:3000/Extern/1


VDR is power and flexible software to build your own PVR system. It includes many plugins which can help you realize all your fantasies. You need just find appropriate ones.


Thanks to Timo -Blazko- Boewing who wrote excellent howto, Kanotix Linux distribution team who adds excellent example of (see below) and Sascha Volkenandt who develop excellent VDR plugin – streamdev-server.

Append 1. Example of
# put file to /root, then
# chmod 755 /root/
# echo -r /root/ > /etc/vdr/plugins/plugin.streamdev-server.conf
# /etc/init.d/vdr restart
# you can use any other postition too (just exchnage /root)
# usage
# xine
rm -f $OUT.avi /tmp/out-*log
/usr/bin/mkfifo $OUT.avi
#cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=480 -oac mp3lame -lameopts preset=15:mode=3 -vf scale=576:324 -o $OUT.avi &>$OUT.log
#cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc xvid -xvidencopts fixed_quant=6 -oac lavc -lavcopts acodec=mp3:abitrate=64 -vf scale=400:225 -o $OUT.avi &>/tmp/out.log
#cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc xvid -oac mp3lame -ffourcc XVID -lameopts vbr=3:abr:cbr=50:aq=9:mode=3 -xvidencopts bitrate=350 -vf scale -zoom -xy 400 -o $OUT.avi &>$OUT.log
#cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc lavc -oac lavc -lavcopts vcodec=mpeg4:vbitrate=75:acodec=aac:abitrate=20 -vop expand=176:144,scale=176:-2 -channels 1 -o $OUT.avi &>$OUT.log
# DSL 1024/128 or 768/128
cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc xvid -xvidencopts bitrate=75 -ffourcc XVID -oac lavc -lavcopts acodec=aac:abitrate=20 -vf scale -zoom -xy 200 -channels 1 -o $OUT.avi &>$OUT.log
# DSL 3000/384
#cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc xvid -xvidencopts bitrate=260 -oac mp3lame -ffourcc XVID -lameopts vbr=3:abr:cbr=8:aq=9:mode=3 -vf scale -zoom -xy 280 -o $OUT.avi &>$OUT.log
# DSL 6000/576
#cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc xvid -xvidencopts bitrate=448 -ffourcc XVID -oac lavc -lavcopts acodec=aac:abitrate=96 -vf scale -zoom -xy 350 -o $OUT.avi &>$OUT.log

Append 2. Example of for PDA (uses MPEG4)
rm -f /tmp/out.avi
/usr/bin/mkfifo /tmp/out.avi
cat /tmp/out.avi & /usr/bin/mencoder -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=350 -oac mp3lame -lameopts preset=15:mode=3 -vf scale=320:208 -o /tmp/out.avi -- - &>/tmp/out.log