Introduction

VDR is a Personal Video Recoder (PVR) application. It can record TV from DVB-C, DVB-S and DVB-T receivers.

This guide assumes debian-7.2.0-i386 stable has just been installed with the default settings.

This guide has been tested with the PCTV ?NanoStick 73e SE (solo) http://linuxtv.org/wiki/index.php/Pinnacle_PCTV_nano_Stick_%2873e%29

In order to watch encrypted broadcasts, a smartcard from the TV provider is required.

Compatible receivers

http://linuxtv.org/wiki/index.php/Hardware_Device_Information

Using VDR with analog TV

DVB itself cannot use analog TV, however, the plugin "Analogtv" causes analog TV cards to be seen as a DVB receiver. http://www.linuxtv.org/vdrwiki/index.php/Analogtv-plugin

Installing VDR

Enter the following command to install VDR:

# apt-get install vdr

By default, vdr uses the directory /var/lib/video.00 to store it's recordings. The installer will ask if the directory should be created. Choose "Yes" Next, the installer will ask the type of DVB cards. Choose "Satellite" Now the installer will make a new user, "VDR", and try to run VDR

Install vdr-plugin-xineliboutput and xineliboutput-sxfe to get the screen of VDR on your display:

# apt-get install vdr-plugin-xineliboutput xineliboutput-sxfe

VDR Configuration files

VDR store it's configuration files in the following directories:

 /var/lib/vdr/*
 /etc/default/vdr
 /etc/vdr/*
 /etc/init.d/vdr

Edit /etc/default/vdr, set variable ENABLED=1

# /etc/default/vdr
#
# See also /usr/share/doc/vdr/README.Debian.gz
#

# Change to 1 to enable vdr's init-script
ENABLED=1

# Change this to 1 if you want vdr to be able to shutdown the
# computer
ENABLE_SHUTDOWN=0

# Options that will be passed to vdr's commandline
# for example: OPTIONS="-w 15"
OPTIONS="-w 60"

fill /var/lib/vdr/remote.conf with the following contents in order to be able to control vdr-sxfe with the keyboard:

KBD.Up         00000000001B5B41
KBD.Down       00000000001B5B42
KBD.Menu       000000000000006D
KBD.Ok         000000000000000D
KBD.Back       000000000000007F
KBD.Left       00000000001B5B44
KBD.Right      00000000001B5B43
KBD.Red        000000001B5B5B41
KBD.Green      000000001B5B5B42
KBD.Yellow     000000001B5B5B43
KBD.Blue       000000001B5B5B44
KBD.0          0000000000000030
KBD.1          0000000000000031
KBD.2          0000000000000032
KBD.3          0000000000000033
KBD.4          0000000000000034
KBD.5          0000000000000035
KBD.6          0000000000000036
KBD.7          0000000000000037
KBD.8          0000000000000038
KBD.9          0000000000000039
KBD.Info       0000000000000069
KBD.FastFwd    0000001B5B31377E
KBD.FastRew    000000001B5B5B45
KBD.Power      0000000000000070
KBD.Volume+    0000001B5B32347E
KBD.Volume-    0000001B5B32337E
KBD.Mute       0000001B5B32317E
KBD.User7      0000001B5B31387E
KBD.User8      0000001B5B31397E
KBD.User9      0000001B5B32307E
XKeySym.Up         Up
XKeySym.Down       Down
XKeySym.Menu       m
XKeySym.Ok         Return
XKeySym.Back       BackSpace
XKeySym.Left       Left
XKeySym.Right      Right
XKeySym.Red        F1
XKeySym.Green      F2
XKeySym.Yellow     F3
XKeySym.Blue       F4
XKeySym.0          0
XKeySym.1          1
XKeySym.2          2
XKeySym.3          3
XKeySym.4          4
XKeySym.5          5
XKeySym.6          6
XKeySym.7          7
XKeySym.8          8
XKeySym.9          9
XKeySym.Info       i
XKeySym.Pause      space
XKeySym.FastFwd    F6
XKeySym.FastRew    F5
XKeySym.Power      p
XKeySym.Volume+    F12
XKeySym.Volume-    F11
XKeySym.Mute       F10
XKeySym.User7      F7
XKeySym.User8      F8
XKeySym.User9      F9
remote-pci-0000:07:00_2--event-ir.Up         0000000100010067
remote-pci-0000:07:00_2--event-ir.Down       000000010001006C
remote-pci-0000:07:00_2--event-ir.Menu       000000010001008B
remote-pci-0000:07:00_2--event-ir.Ok         000000010001001C
remote-pci-0000:07:00_2--event-ir.Back       00000001000100AE
remote-pci-0000:07:00_2--event-ir.Left       0000000100010069
remote-pci-0000:07:00_2--event-ir.Right      000000010001006A
remote-pci-0000:07:00_2--event-ir.Red        000000010001018E
remote-pci-0000:07:00_2--event-ir.Green      000000010001018F
remote-pci-0000:07:00_2--event-ir.Yellow     0000000100010190
remote-pci-0000:07:00_2--event-ir.Blue       0000000100010191
remote-pci-0000:07:00_2--event-ir.0          000000010001000B
remote-pci-0000:07:00_2--event-ir.1          0000000100010002
remote-pci-0000:07:00_2--event-ir.2          0000000100010003
remote-pci-0000:07:00_2--event-ir.3          0000000100010004
remote-pci-0000:07:00_2--event-ir.4          0000000100010005
remote-pci-0000:07:00_2--event-ir.5          0000000100010006
remote-pci-0000:07:00_2--event-ir.6          0000000100010007
remote-pci-0000:07:00_2--event-ir.7          0000000100010008
remote-pci-0000:07:00_2--event-ir.8          0000000100010009
remote-pci-0000:07:00_2--event-ir.9          000000010001000A
remote-pci-0000:07:00_2--event-ir.Info       000000010001019C
remote-pci-0000:07:00_2--event-ir.Play       00000001000100CF
remote-pci-0000:07:00_2--event-ir.Pause      0000000100010077
remote-pci-0000:07:00_2--event-ir.Stop       0000000100010080
remote-pci-0000:07:00_2--event-ir.Record     00000001000100A7
remote-pci-0000:07:00_2--event-ir.FastFwd    00000001000100D0
remote-pci-0000:07:00_2--event-ir.FastRew    00000001000100A8
remote-pci-0000:07:00_2--event-ir.Next       00000001000100A3
remote-pci-0000:07:00_2--event-ir.Prev       00000001000100A5
remote-pci-0000:07:00_2--event-ir.Power      0000000100010074
remote-pci-0000:07:00_2--event-ir.Channel+   0000000100010192
remote-pci-0000:07:00_2--event-ir.Channel-   0000000100010193
remote-pci-0000:07:00_2--event-ir.Volume+    0000000100010073
remote-pci-0000:07:00_2--event-ir.Volume-    0000000100010072
remote-pci-0000:07:00_2--event-ir.Mute       0000000100010071
remote-pci-0000:07:00_2--event-ir.Schedule   000000010001016D
remote-pci-0000:07:00_2--event-ir.Channels   0000000100010179
remote-pci-0000:07:00_2--event-ir.Recordings 0000000100010189
LIRC.Up         Up
LIRC.Down       Down
LIRC.Menu       Menu
LIRC.Ok         OK
LIRC.Back       Back
LIRC.Left       Left
LIRC.Right      Right
LIRC.Red        Red
LIRC.Green      Green
LIRC.Yellow     Yellow
LIRC.Blue       Blue
LIRC.0          0
LIRC.1          1
LIRC.2          2
LIRC.3          3
LIRC.4          4
LIRC.5          5
LIRC.6          6
LIRC.7          7
LIRC.8          8
LIRC.9          9
LIRC.Info       Info
LIRC.Play       Replay
LIRC.Pause      Pause
LIRC.Stop       Stop
LIRC.Record     Record
LIRC.FastFwd    FastFwd
LIRC.FastRew    FastRew
LIRC.Next       Next
LIRC.Prev       Prev
LIRC.Power      Power
LIRC.Channel+   Channel+
LIRC.Channel-   Channel-
LIRC.Volume+    Volume+
LIRC.Volume-    Volume-
LIRC.Mute       Mute
LIRC.Audio      Clear
LIRC.Subtitles  Enter
LIRC.Schedule   Schedule
LIRC.User1      DVD
LIRC.User4      Hash
LIRC.User5      Eject
LIRC.User6      Guide
LIRC.User9      Radio
LIRC.Recordings Recordings

Adjust directory for recordings

Make the directory where VDR can store the recordings, in this example /storage/tv/video/

# mkdir -p /storage/tv/video/
# chown vdr /storage/tv/video/

Add the -v option in /etc/default/vdr:

# /etc/default/vdr
#
# See also /usr/share/doc/vdr/README.Debian.gz
#

# Change to 1 to enable vdr's init-script
ENABLED=1

# Change this to 1 if you want vdr to be able to shutdown the
# computer
ENABLE_SHUTDOWN=0

# Options that will be passed to vdr's commandline
# for example: OPTIONS="-w 15"
OPTIONS="-w 60 -v /storage/tv/video"

Testing VDR

VDR logs to /var/log/syslog. In a new terminal, enter the following command:

# tail -F /var/log/syslog

Now start VDR:

# invoke-rc.d vdr start

Syslog now shows the messaged from VDR:

VDR version 1.7.28 started
switched to user 'vdr'
codeset is 'UTF-8' - known
found 28 locales in /usr/share/locale
loading plugin: /usr/lib/vdr/plugins/libvdr-xineliboutput.so.1.7.28
[xine..put] Listening on address '127.0.0.1' port 37890
loading /var/lib/vdr/sources.conf
loading /var/lib/vdr/diseqc.conf
loading /var/lib/vdr/scr.conf
loading /var/lib/vdr/channels.conf
loading /var/lib/vdr/commands.conf
loading /var/lib/vdr/reccmds.conf
loading /var/lib/vdr/svdrphosts.conf
loading /var/lib/vdr/keymacros.conf
registered source parameters for 'A - ATSC'
video directory scanner thread started (pid=10503, tid=10505)
registered source parameters for 'C - DVB-C'
video directory scanner thread started (pid=10503, tid=10504)
registered source parameters for 'S - DVB-S'
epg data reader thread started (pid=10503, tid=10506)
registered source parameters for 'T - DVB-T'
video directory scanner thread ended (pid=10503, tid=10505)
video directory scanner thread ended (pid=10503, tid=10504)
no DVB device found
initializing plugin: xineliboutput (1.0.90-cvs): X11/xine-lib output plugin
reading EPG data from /var/cache/vdr/epg.data
new device number 9
[xine..put] cTimePts: clock_gettime(CLOCK_MONOTONIC): clock resolution 0 us
[xine..put] cTimePts: using monotonic clock
[xine..put] RTP SSRC: 0x0217f1cb
setting primary device to 1
epg data reader thread ended (pid=10503, tid=10506)
assuming manual start of VDR
SVDRP listening on port 6419
setting current skin to "sttng"
loading /var/lib/vdr/themes/sttng-default.theme
starting plugin: xineliboutput
Remote decoder/display server (cXinelibServer) thread started (pid=10503, tid=10508)
xine..put] cXinelibServer priority set successful SCHED_RR 2 [1,99]
[xine..put] Binding server to 127.0.0.1:37890
[xine..put] Listening on port 37890
[xine..put] Listening for UDP broadcasts on port 37890
[discovery] BROADCAST: VDR xineliboutput DISCOVERY 1.0#015#012Server port: 37890#015#012Server address: 127.0.0.1#015#012Server version: xineliboutput-1.0.90-cvs#015#012#015
[xine..put] cXinelibDevice::StartDevice(): Device started
ERROR (lirc.c,48): /var/run/lirc/lircd: No such file or directory
ERROR: remote control LIRC not ready!
setting watchdog timer to 60 seconds
OSD size changed to 720x576 @ 1.42222
cTimeMs: using monotonic clock (resolution is 1 ns)
[xine..put] cXinelibOsd::CanHandleAreas(): Device does not support ARGB
Dec  1 09:29:53 tv vdr: [10503] max. latency time 1 seconds

Connect to the VDR server with vdr-sxfe:

$ vdr-sxfe

This will open a windows saying "No Signal".

Using vdr-sxfe with multiple soundcards

If you have multiple soundcards, you can choose the first one with this command:

$ vdr-sxfe --audio=alsa:hw:0,0

The second soundcard can be selected with this command:

$ vdr-sxfe --audio=alsa:hw:1,0

The above commands causes the configuration file ~/.xine/config_xineliboutput to be adjusted.

Installing and testing DVB receiver

In a new terminal, monitor syslog:

# tail -F /var/log/syslog

Plug in your USB receiver. check for error messages about missing firmware: Below, the file "dvb-usb-dib0700-1.20.fw" is not found.

usb 1-1: new high-speed USB device number 3 using ehci_hcd
usb 1-1: New USB device found, idVendor=2013, idProduct=0245
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: PCTV 73e SE
usb 1-1: Manufacturer: PCTV Systems
usb 1-1: SerialNumber: 0000000M05E19JN
Dec  1 09:07:06 tv mtp-probe: checking bus 1, device 3: "/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1"
Dec  1 09:07:06 tv mtp-probe: bus: 1, device: 3 was not an MTP device
IR NEC protocol handler initialized
dib0700: loaded with support for 21 different device-types
dvb-usb: found a 'Pinnacle PCTV 73e SE' in cold state, will try to load a firmware
usb 1-1: firmware: agent aborted loading dvb-usb-dib0700-1.20.fw (not found?)
usbcore: registered new interface driver dvb_usb_dib0700
IR RC5(x) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR MCE Keyboard/mouse protocol handler initialized
lirc_dev: IR Remote Control driver registered, major 251 
IR LIRC bridge handler initialized

This can be solved by installing the package "firmware-linux-nonfree". Start synaptic, goto settings=>repositories, and activate "Non-DFSG-compatible Software (non-free)". Close and Reload. Now the package "firmware-linux-nonfree" can be installed.

Remove and re-plug your USB receiver. Now the following messages can be seen in syslog:

usb 1-1: new high-speed USB device number 6 using ehci_hcd
usb 1-1: New USB device found, idVendor=2013, idProduct=0245
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: PCTV 73e SE
usb 1-1: Manufacturer: PCTV Systems
usb 1-1: SerialNumber: 0000000M05E19JN
dvb-usb: found a 'Pinnacle PCTV 73e SE' in cold state, will try to load a firmware
usb 1-1: firmware: agent loaded dvb-usb-dib0700-1.20.fw into memory
dib0700: firmware started successfully.
dvb-usb: found a 'Pinnacle PCTV 73e SE' in warm state.
dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
DVB: registering new adapter (Pinnacle PCTV 73e SE)
DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)...
DiB0070: successfully identified
Registered IR keymap rc-dib0700-rc5
input: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:12.2/usb1/1-1/rc/rc2/input9
rc2: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:12.2/usb1/1-1/rc/rc2
dvb-usb: schedule remote query interval to 50 msecs.
dvb-usb: Pinnacle PCTV 73e SE successfully initialized and connected.

Check if the kernel has made the device nodes:

$ ls -l /dev/dvb/
total 0
drwxr-xr-x 2 root root 120 Nov 29 21:53 adapter0
$ ls -l /dev/dvb/adapter0/
total 0
crw-rw---T+ 1 root video 212, 0 Nov 29 21:53 demux0
crw-rw---T+ 1 root video 212, 1 Nov 29 21:53 dvr0
crw-rw---T+ 1 root video 212, 3 Nov 29 21:53 frontend0
crw-rw---T+ 1 root video 212, 2 Nov 29 21:53 net0

Setting up VDR for DVB-T reception

Install DVB-apps, this allows for channels to be scanned:

# apt-get install dvb-apps

Netherlands: KPN Digitenne

In the Netherlands, KPN provides DVB-T broadcasts under the name "Digitenne".

Scanning channels

To scan the channels, first stop VDR, so the receiver is not in use:

# invoke-rc vdr stop

Then enter the following command to scan the channels. This will take a couple of minutes to run.

# scan -o vdr /usr/share/dvb/dvb-t/nl-All > /var/lib/vdr/channels.conf

(Re)start VDR, so the new channels.conf is read. Also restart vdr-sxfe.

# invoke-rc.d vdr restart
$ vdr-sxfe

The channels Nederland 1,2 and 3 can now be watched. The rest of the channels are encrypted, so on those channels "Channel not available" is displayed.

Adding support for encrypted broadcasts

Installing OSCAM from source

Note: OSCAM has not yet been packaged for debian, so we need to install manually

Information from http://www.cardsharing.ws/cardsharing/showthread.php/140984-How-to-install-oscam-debian-and-ubuntu and http://www.streamboard.tv/oscam/wiki/BuildingOscam

Install build dependencies:

# apt-get install build-essential libssl-dev libpcsclite-dev mercurial cvs subversion libncurses-dev cmake libusb-1.0-0-dev

Compile Oscam:

$ svn checkout http://www.streamboard.tv/svn/oscam/trunk oscam-svn
$ cd oscam-svn
$ make USE_LIBUSB=1
# cp Distribution/oscam-1.20-unstable_svn9065-x86_64-linux-gnu-libusb /usr/bin/oscam

Configuring OSCAM

mkdir /etc/oscam

Edit /etc/oscam/oscam.conf

# main configuration
[global]
nice          = -1
WaitForCards  = 1

# logging
pidfile       = /var/run/oscam.pid
logfile       = /var/log/oscam/oscam.log
usrfile       = /var/log/oscam/oscamuser.log
cwlogdir      = /var/log/oscam/cw

# monitor
[monitor]
port          = 8988
aulow         = 120
monlevel      = 1

# protocols

[newcamd]
key            = 000102030405060708090A0B0C0D
port           = 15050@0B00:0E030

Edit /etc/oscam/oscam.server

# reader configuration

[reader]
label    = reader1
protocol = mouse
detect   = CD
device   = /dev/ttyUSB0
group    = 1
emmcache = 1,3,2
services = services1
caid     = 0B00
mhz      = 500
cardmhz  = 500

Edit /etc/oscam/oscam.services

# definition of services 
#
# format:
# [name]
# caid=CAID[,CAID]...
# provid = provider ID[,provider ID]...
# srvid = service ID[,service ID]...

[services1]
caid=0B00
provid=0E030
srvid=

Edit /etc/oscam/oscam.user

# user configuration

[account]
user       = user1
pwd        = password1
monlevel   = 0
uniq       = 0
group      = 1
au         = 1
ident      = 0B00:0E030
caid       = 0B00

# user for group 2 with monitor access, AU enabled

#[account]
user       = user2
pwd        = password2
monlevel   = 0
uniq       = 0
group      = 1
au         = 1
ident      = 0B00:0E030
caid       = 0B00

Make sure oscam can write it's log:

mkdir /var/log/oscam

Start oscam with this line: (This should be replaced by an init script)

# /usr/bin/oscam -b -c /etc/oscam

Install vdr-plugin-sc and libvdr-sc-cardclient from source

Information taken from http://www.eurocardsharing.com/f273/vdr-1-7-21-sc-361291 Enter the following command to install the packages needed to complie

# apt-get install wget vdr-dev build-essential cdbs dpatch mercurial devscripts libssl-dev

Then enter the following commands to compile:

$ hg clone http://85.17.209.13:6100/sc
$ wget http://vdrbox.lautre.net/fichiers/VDR/debianize-sc/sc-debian-package-03062011.diff
$ cd sc/
$ patch -p1 <../sc-debian-package-03062011.diff
$ dpkg-buildpackage -us -uc -b
$ cd ..

Then enter the following commands to install:

# dpkg -i vdr-plugin-sc_*.deb libvdr-sc-cardclient_*.deb

edit /var/lib/vdr/plugins/sc/cardclient.conf to be able to connect to OSCAM. In this example the username is "user2" and the password is "password2"

# Comment lines can start with # or ;
#
# every client line starts with the client name, followed by some arguments:
# 'hostname' is the name of the server
# 'port'     is the port on the server
# 'emm'      is a flag to allow EMM transfers to the server
#            (0=disabled 1=enabled)
# 'caid'     (optional) caid on which this client should work
# 'mask'     (optional) mask for caid e.g. caid=1700 mask=FF00 would allow
#            anything between 1700 & 17FF.
#            Default is 1700 & FF00. If only caid is given mask is FFFF.
#            You may give multiple caid/mask values comma separated
#            (e.g. 1702,1722,0d0c/ff00).
# 'username' is the login username
# 'password' is the login password
#
# newcamd client
# 'cfgkey' is the config key (28bytes)
newcamd:127.0.0.1:15050:1/0B00/FF00:user2:password2:000102030405060708090A0B0C0D

make sure vdr can change the configuration files:

# chown vdr /var/lib/vdr/plugins/sc/*

(Re)start VDR, so the new configuration is read. Also restart vdr-sxfe.

# invoke-rc.d vdr restart
$ vdr-sxfe

It takes a few minutes for the first encrypted channel to start playing. After that, the encryption does not cause delays.

Extending VDR

Live

Install EPG search, streamdev-server and Live.

# apt-get install vdr-plugin-epgsearch vdr-plugin-live vdr-plugin-streamdev-server

In order to allow other computers in your LAN to connect to the streamdev server edit /var/lib/vdr/plugins/streamdev-server/streamdevhosts.conf In this example all computers in the IP range 192.168.31.0 to 192.168.31.255 are allowed access:

#
# 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]
#

127.0.0.1             # always accept localhost
192.168.31.0/24     # any host on the local net
#204.152.189.113      # a specific host
#239.255.0.0/16       # uncomment for IGMP multicast streaming
#0.0.0.0/0            # any host on any net (DON'T DO THAT! USE AUTHENTICATION)

(Re)start VDR, so the new configuration is read. Also restart vdr-sxfe.

# invoke-rc.d vdr restart
Restarting Linux Video Disk Recorder: vdr
Searching for plugins (VDR 1.7.28/1.7.28) (cache miss): quickepgsearch streamdev-server epgsearchonly sc epgsearch xineliboutput live conflictcheckonly.

$ vdr-sxfe

Enter the following address in your favorite browser to access vdr-live:

127.0.0.1:8008

The default username = "admin", default password = "live". After logging in, this can be changed under "setup"

For information about the capabilities of vdr-live, see this page: http://live.vdr-developer.org/en/index.php

Signal monitor

This plugin monitors the signal quality of the receivers. To install:

# apt-get install vdr-plugin-femon

(Re)start VDR, so the new plugin is detected. Also restart vdr-sxfe.

# invoke-rc.d vdr restart
Restarting Linux Video Disk Recorder: vdr
Searching for plugins (VDR 1.7.28/1.7.28) (cache miss): quickepgsearch streamdev-server epgsearchonly sc femon epgsearch xineliboutput live conflictcheckonly.
$ vdr-sxfe

In vdr-sxfe the new menu item "Signal Information" is visible

Playing DVD's with VDR

This plugin for VDR allows one to play back DVD Video discs from within VDR. To install:

# apt-get install vdr-plugin-dvd

Follow these instructions to be able to play encrypted DVD's: https://wiki.debian.org/CDDVD#DVD

(Re)start VDR, so the new plugin is detected. Also restart vdr-sxfe.

# invoke-rc.d vdr restart
Restarting Linux Video Disk Recorder: vdr
Searching for plugins (VDR 1.7.28/1.7.28) (cache miss): quickepgsearch dvd streamdev-server epgsearchonly sc femon epgsearch xineliboutput live conflictcheckonly.
$ vdr-sxfe

In vdr-sxfe the new menu item "DVD" is visible

Accessing VDR from other devices

vdr-sxfe

VDR

browser with VLC

This requires the installation of vdr-live, see above. Install the vlc browser plugin, and restart the browser.

# apt-get install browser-plugin-vlc

After logging into vdr-live, choose "What's on?", and press the yellow arrow "Stream this channel into browser". Now a new window pops up, playing the selected channel. The the sound is bad, move the volume slider to silence, and then back. Now the sound should be good.

VDR with streamdev

Popcorn hour

Other Settings

Auto shutdown

edit /etc/default/vdr, set ENABLE_SHUTDOWN=1

# /etc/default/vdr
#
# See also /usr/share/doc/vdr/README.Debian.gz
#

# Change to 1 to enable vdr's init-script
ENABLED=1

# Change this to 1 if you want vdr to be able to shutdown the
# computer
ENABLE_SHUTDOWN=1

# Options that will be passed to vdr's commandline
# for example: OPTIONS="-w 15"
OPTIONS="-w 60"

Restart VDR to reload the configuration.

VDR runs as the user "vdr" witch does not have permission to run the shutdown command. Edit the file /etc/sudoers to allow vdr to run the command. /etc/sudoers has to be edited by "visudo" as root. See for more info https://wiki.debian.org/sudo

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# Allow VDR to shutdown the machine
vdr     ALL = NOPASSWD: /sbin/shutdown 

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

In vdr-sxfe, pressing the key "p" now causes VDR to shutdown the PC.

Suspend

Suspend and the subsequent resume requires VDR to be stopped, the DVB driver to be unloaded. Then the kernel can suspend without crashing. On resume, the driver has to be loaded again, then VDR can be started. First check what driver is for the DVB receiver:

# lsmod | grep dvb
dvb_usb_dib0700       114523  0 
dib8000                34722  1 dvb_usb_dib0700
dib7000m               21693  1 dvb_usb_dib0700
dib0090                29953  1 dvb_usb_dib0700
dib0070                16978  1 dvb_usb_dib0700
dib7000p               31052  1 dvb_usb_dib0700
dib3000mc              17664  1 dvb_usb_dib0700
dibx000_common         13220  5 dvb_usb_dib0700,dib3000mc,dib7000p,dib7000m,dib8000
dvb_usb                18348  1 dvb_usb_dib0700
dvb_core               77734  3 dvb_usb,dib7000p,dib8000
rc_core                18286  10 dvb_usb_dib0700,dvb_usb,ir_nec_decoder,ir_rc5_decoder,ir_rc6_decoder,ir_jvc_decoder,ir_sony_decoder,ir_mce_kbd_decoder,ir_lirc_codec,rc_dib0700_rc5
i2c_core               23876  14 dvb_usb_dib0700,i2c_algo_bit,i2c_piix4,drm,drm_kms_helper,radeon,dvb_usb,dibx000_common,dib3000mc,dib7000p,dib0070,dib0090,dib7000m,dib8000
usbcore               128741  8 xhci_hcd,ehci_hcd,ohci_hcd,usb_storage,usbhid,dvb_usb_dib0700,dvb_usb

In this case, its "dvb_usb_dib0700"

Edit the following file: /usr/lib/pm-utils/sleep.d/00vdr-and-modules

# Shutdown VDR and unload driver to not crash during suspend


. "${PM_FUNCTIONS}"

case "$1" in
        hibernate|suspend)
                #Stop VDR to make sure the DVB receiver is no longer busy
                invoke-rc.d vdr stop
                #unload the driver for the DVB receiver
                rmmod dvb_usb_dib0700
                ;;
        resume|thaw)
                #load module to use the DVB receiver again
                modprobe dvb_usb_dib0700
                #start VDR again
                invoke-rc.d vdr restart
                ;;
esac

To let VDR use suspend instead of shutdown, edit /etc/init.d/vdr, and set VDRSHUTDOWN="/var/lib/vdr/vdr-shutdown-wrapper"

#
# vdr start-stop script
#
### BEGIN INIT INFO
# Provides:          vdr
# Required-Start:    $remote_fs $network $syslog
# Required-Stop:     $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts the Linux Video Disk Recorder (VDR)
# Description:       Starts the Linux Video Disk Recorder (VDR),
#                    if it is enabled in /etc/default/vdr.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=vdr
DESC="Linux Video Disk Recorder"

DAEMON=/usr/sbin/runvdr
PIDFILE=/var/run/runvdr.pid
VDRPRG=/usr/bin/vdr

test -x $DAEMON || exit 0
test -x $VDRPRG || exit 0

. /usr/lib/vdr/config-loader.sh

# Set shutdown command
VDRSHUTDOWN="/var/lib/vdr/vdr-shutdown-wrapper"
#test "$ENABLE_SHUTDOWN" = "1" && VDRSHUTDOWN="/usr/lib/vdr/vdr-shutdown.wrapper" \
#                              || VDRSHUTDOWN="/usr/lib/vdr/vdr-shutdown-message"

. /usr/lib/vdr/plugin-loader.sh
. /usr/lib/vdr/commands-loader.sh


clean_console()
{
    if [ "$KEYB_TTY" != "" ]; then
        tput -Tlinux clear > $KEYB_TTY
    fi
}

configure_console_input()
{
    if [ "$KEYB_TTY" != "" ]; then
        clean_console
        echo -e "This tty is currently mapped to VDR, keypresses aren't echoed.\r" > $KEYB_TTY
        echo -n "For a login prompt switch to another console." > $KEYB_TTY
        REDIRECT="< $KEYB_TTY"
        if [ "$KEYB_TTY_SWITCH" = "1" ]; then
            chvt `echo "$KEYB_TTY" | sed "s/\/dev\/tty//"`
        fi
    fi
}

get_status()
{
    if start-stop-daemon --start --startas $DAEMON --test \
        --name $(basename $DAEMON) --pidfile $PIDFILE >/dev/null
    then
        echo " - is not running."
        exit 3
    else
        echo " - is running."
        exit 0
    fi
}

startvdr()
{
    if [ "$ENABLED" != "0" ] ; then
        # only start vdr if there is no other instance running
        if start-stop-daemon --start --startas $DAEMON --test \
            --name $(basename $DAEMON) --pidfile $PIDFILE >/dev/null
        then
            getplugins
            mergecommands "commands"
            mergecommands "reccmds"
            configure_console_input

            if [ "$VFAT" == "1" ]; then
                OPTIONS="--vfat $OPTIONS"
            fi

            start-stop-daemon --start --quiet --startas $DAEMON --background \
                --name $(basename $DAEMON) --pidfile $PIDFILE --make-pidfile -- \
                -v $VIDEO_DIR -c $CFG_DIR -L $PLUGIN_DIR -r $REC_CMD \
                -s $VDRSHUTDOWN -E $EPG_FILE -u $USER -g /tmp \
                --port $SVDRP_PORT $OPTIONS $PLUGINS $REDIRECT
        else
            echo -n " - seems to be running already"
        fi
    else
        echo -n " - aborted (to enable the daemon, edit /etc/default/vdr)"
    fi
}

stopvdr()
{
    if start-stop-daemon --stop --retry 30 \
        --name $(basename $DAEMON) --pidfile $PIDFILE >/dev/null
    then
        start-stop-daemon --stop --retry 30 --oknodo --exec $VDRPRG >/dev/null
        rm -f $PIDFILE
        clean_console
    else
        echo -n " - seems not to be running"
    fi
}

case "$1" in
    start)
        echo -n "Starting $DESC: $NAME"
        startvdr
        echo "."
        ;;
    stop)
        echo -n "Stopping $DESC: $NAME"
        stopvdr
        echo "."
        ;;
    restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        stopvdr
        sleep 4
        startvdr
        echo "."
        ;;
    status)
        echo -n "Getting status of $DESC: $NAME"
        get_status
        ;;
    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Create the file /var/lib/vdr/vdr-shutdown-wrapper

sudo /usr/sbin/pm-suspend

VDR runs as the user "vdr" witch does not have permission to run the pm-suspend command. Edit the file /etc/sudoers to allow vdr to run the command. /etc/sudoers has to be edited by "visudo" as root. See for more info https://wiki.debian.org/sudo

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# Allow VDR to suspend the machine
vdr     ALL = NOPASSWD: /usr/sbin/pm-suspend 

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

Auto startup

In order to start the PC just before a recording is planned, the PC must have a supported RTC. See http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm for details

Create the file /var/lib/vdr/vdr-shutdown-wrapper

# This script will be called with five parameters.
# $1 is the time (in UTC) of the next timer event (as a time_t type number)
#  If a timer is recording this is a time in the past.
# this is the actual start time of the recording, so substract startup time
# $2 is the number of seconds from the current time until the next timer event.
#  this is the actual start time of the recording, so substract startup time
#  If a timer is recording this is a  negative number
# $3 contains the number of the channel that will be recorded by the next timer
#  (or 0 if no timer is present),
# $4 contains the file name of the recording as defined in the timer
#  (or an empty string if no timer is present).
# $5 indicates the reason why the shutdown was requested.
#  '0' means this is an automatic shutdown due to some timeout,
#  while '1' means that this is a user requested shutdown

# $2 is the best number to use, when negative, probably something terrible is going on,
# so do a complete shutdown, and start after two minutes

# when $2 is 0, start the PC 24 hours from now, so the EPG can be updated

# when $2 is positive, subtract the startup time. When still positive, add this number to now, and write this to rtc.

EMERGENCY_SECS=121 #seconds to stay off after powerdown during recording
STARTUPTIME=120 #seconds to startup
ONE_DAY_SECS=86400 #seconds in one day
GO_INTO_SUSPEND_SECS=15 #seconds to perform suspend

if [ $2 -eq 0 ]
then    #no recordings planned in the future, suspend, and try again tomorrow
        sudo /usr/bin/setwakeup $ONE_DAY_SECS
        sudo /usr/sbin/pm-suspend
elif [ $2 -lt 0 ]
then    #timer recording, shutdown, and boot after 2 minutes.
        sudo /usr/bin/setwakeup $EMERGENCY_SECS
        sudo /sbin/shutdown
elif [ $2 -gt $(($STARTUPTIME +$GO_INTO_SUSPEND_SECS)) ]
then    #timer in the (far) future, suspend, and set time
        sudo /usr/bin/setwakeup $(($2 - $STARTUPTIME ))
        sudo /usr/sbin/pm-suspend
else    #timer very soon in the future, don't shutdown the machine. Should not happen
        echo
fi

Edit /usr/bin/setwakeup

# set RTC to $1 + now
nowTime=`date +%s`
targetTime=$[$nowTime+$1]

echo 0 > /sys/class/rtc/rtc0/wakealarm
echo "$targetTime" > /sys/class/rtc/rtc0/wakealarm

Make sure the two above files are executable:

# chmod +x /var/lib/vdr/vdr-shutdown-wrapper /usr/bin/setwakeup

Edit /etc/init.d/vdr, Set VDRSHUTDOWN="/var/lib/vdr/vdr-shutdown-wrapper"

#
# vdr start-stop script
#
### BEGIN INIT INFO
# Provides:          vdr
# Required-Start:    $remote_fs $network $syslog
# Required-Stop:     $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts the Linux Video Disk Recorder (VDR)
# Description:       Starts the Linux Video Disk Recorder (VDR),
#                    if it is enabled in /etc/default/vdr.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=vdr
DESC="Linux Video Disk Recorder"

DAEMON=/usr/sbin/runvdr
PIDFILE=/var/run/runvdr.pid
VDRPRG=/usr/bin/vdr

test -x $DAEMON || exit 0
test -x $VDRPRG || exit 0

. /usr/lib/vdr/config-loader.sh

# Set shutdown command
VDRSHUTDOWN="/var/lib/vdr/vdr-shutdown-wrapper"
#test "$ENABLE_SHUTDOWN" = "1" && VDRSHUTDOWN="/usr/lib/vdr/vdr-shutdown.wrapper" \
#                              || VDRSHUTDOWN="/usr/lib/vdr/vdr-shutdown-message"

. /usr/lib/vdr/plugin-loader.sh
. /usr/lib/vdr/commands-loader.sh


clean_console()
{
    if [ "$KEYB_TTY" != "" ]; then
        tput -Tlinux clear > $KEYB_TTY
    fi
}

configure_console_input()
{
    if [ "$KEYB_TTY" != "" ]; then
        clean_console
        echo -e "This tty is currently mapped to VDR, keypresses aren't echoed.\r" > $KEYB_TTY
        echo -n "For a login prompt switch to another console." > $KEYB_TTY
        REDIRECT="< $KEYB_TTY"
        if [ "$KEYB_TTY_SWITCH" = "1" ]; then
            chvt `echo "$KEYB_TTY" | sed "s/\/dev\/tty//"`
        fi
    fi
}

get_status()
{
    if start-stop-daemon --start --startas $DAEMON --test \
        --name $(basename $DAEMON) --pidfile $PIDFILE >/dev/null
    then
        echo " - is not running."
        exit 3
    else
        echo " - is running."
        exit 0
    fi
}

startvdr()
{
    if [ "$ENABLED" != "0" ] ; then
        # only start vdr if there is no other instance running
        if start-stop-daemon --start --startas $DAEMON --test \
            --name $(basename $DAEMON) --pidfile $PIDFILE >/dev/null
        then
            getplugins
            mergecommands "commands"
            mergecommands "reccmds"
            configure_console_input

            if [ "$VFAT" == "1" ]; then
                OPTIONS="--vfat $OPTIONS"
            fi

            start-stop-daemon --start --quiet --startas $DAEMON --background \
                --name $(basename $DAEMON) --pidfile $PIDFILE --make-pidfile -- \
                -v $VIDEO_DIR -c $CFG_DIR -L $PLUGIN_DIR -r $REC_CMD \
                -s $VDRSHUTDOWN -E $EPG_FILE -u $USER -g /tmp \
                --port $SVDRP_PORT $OPTIONS $PLUGINS $REDIRECT
        else
            echo -n " - seems to be running already"
        fi
    else
        echo -n " - aborted (to enable the daemon, edit /etc/default/vdr)"
    fi
}

stopvdr()
{
    if start-stop-daemon --stop --retry 30 \
        --name $(basename $DAEMON) --pidfile $PIDFILE >/dev/null
    then
        start-stop-daemon --stop --retry 30 --oknodo --exec $VDRPRG >/dev/null
        rm -f $PIDFILE
        clean_console
    else
        echo -n " - seems not to be running"
    fi
}

case "$1" in
    start)
        echo -n "Starting $DESC: $NAME"
        startvdr
        echo "."
        ;;
    stop)
        echo -n "Stopping $DESC: $NAME"
        stopvdr
        echo "."
        ;;
    restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        stopvdr
        sleep 4
        startvdr
        echo "."
        ;;
    status)
        echo -n "Getting status of $DESC: $NAME"
        get_status
        ;;
    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Run visudo (as root) to enable the user vdr to execute "shutdown" "pm-suspend" and vdr-shutdown-wrapper:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# Allow VDR to shutdown, suspend and set RTC
vdr     ALL = NOPASSWD: /sbin/shutdown, /usr/sbin/pm-suspend, /usr/bin/setwakeup 

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

Restart vdr and vdr-sxfe to pick up the new configuration

# invoke-rc.d vdr restart
$ vdr-sxfe

First go into setup - miscellaneous - min event timeout 30 -> 5 Now make a timer 15 minutes in the future, and press p to shutdown the machine. Now the machine should suspend, and wakeup in 10 minutes.

Known Problems

DVB-T USB receivers

PCTV NanoStick 73e SE (solo) receiver needs USB2

My DVB-t receiver has no filter, so you get the complete transport stream. This is 8MB/s (64Mb/s), more than USB-1 (12Mb/s)

PCTV NanoStick 73e SE (solo) receiver needs 500mA

The receiver needs 500mA of power, otherwise the analog functions don't fully work. ==== PCTV ?NanoStick 73e SE (solo) receiver has to be powered down ==== Some USB ports stay powered after the PC has shut down. This can be seen by the LED on the receiver staying on. When the PC is then booted, the kernel driver is confused, and fails to enable the preamplifier. This leads to deteriorated reception.

PCTV NanoStick 73e SE (solo) receiver disconnect while in use confuses the kernel

When VDR is accessing the receiver, and it is pulled from a USB port, that USB port does not react to any USB device anymore, until VDR is stopped.

Smartcards

Digitenne smartcard looses subscription every 3 months

Every 3 months, my digitenne smartcard stops giving keys. The solution is to put the smartcard in an official digitenne receiver for about 15 minutes.

Debian specific information

Upstream specific information

other information


CategorySoftware CategoryVideo