The Mac mini as a digital video recorder
This text describes how I turned a Mac mini into a digital video recorder.
Actually, the same procedure could easily be adapted to any other Linux-capable
computer — the only Mac mini-specific parts are the prerequisites below,
and the configuring of the Mac mini remote control.
The prerequisites are:
-
Slackware on the Mac mini. Other distros will
work just as well, but you'll have to improvise some steps since my
assumptions are based on the installation and boot procedures for
Slackware/Slamd64.
-
TV Output on a Linux Mac mini. Describes
how you configure the analog TV-out capabilities of the Mac mini
in Xorg 7.3. Only PAL is covered so far, some adjustments of the
video geometry and timing signals will be necessary for NTSC.
You don't of course need TV Output in order to just record video,
but the rest of this text will assume that the Mac mini will also be used
for viewing video in full-screen mode on some TV-like device.
Install video capturing hardware and Linux driver
I use a several years old version of a
Hauppauge WinTV-PVR-USB2
device, which is a TV tuner and MPEG2 encoder that is connected via the USB bus.
Before my Mac mini came along, the same device was attached to a Microsoft
Xbox running Linux, which had the Hauppauge device encoding all the time (even
while nothing is being recorded) because of driver issues in the primitive
userspace driver I was using. As of April 2008 the device has been encoding
constantly for more than four years, with occasional breaks only a few times
per year for rebooting the Xbox. So this Hauppauge hardware has been very reliable.
Until August 3, 2008, when a thunderstorm zapped it, together with the Mac mini.
Both are now replaced, and the new PVR-USB2 device is faster, less expensive,
and brews better coffee than the old one. And it has an
IR Blaster!
Note: Hauppauge pays me way too little for plugging their product like this...
If you have some other capturing device, you're on your own for now, but
you might want to skim through the rest of this page anyway since it also
contains some general tips that may be useful.
The driver to use for the PVR-USB2 device under a 2.6+ kernel is Mike Isely's
pvrusb2 driver, which is included in the official
Linux kernel source. To get it working, do the following:
Install and configure LIRC
LIRC is the de-facto Linux standard interface for infrared and other types of
remote controls. I have never been able to get along very well with LIRC,
and in fact I think LIRC sucks really bad for several reasons. But until
something better replaces LIRC, it's still the most portable option for
remote controls in Linux.
-
Ideally, you should download and install the latest stable LIRC release from
http://www.lirc.org. However, when I tried
lirc-0.8.3 it didn't compile due to incompatibilites with the 2.6.26 kernel,
so a more successful approach is to download from CVS:
http://www.lirc.org/cvs.html.
Then do ./autogen.sh
to create the configure script for the CVS version.
-
For the Apple IR remote, configure like this:
./configure --with-moduledir=/lib/modules/`uname -r`/misc --with-x --with-driver=macmini --with-major=61 --with-port=none --with-irq=none
-
For the Hauppauge remote, configure like this:
./configure --with-moduledir=/lib/modules/`uname -r`/misc --with-x --with-driver=hauppauge --with-major=61 --with-port=none --with-irq=none
You want both? Sorry, not possible unless you choose all
available drivers, including a bunch that won't compile unless you
reconfigure your kernel.
Configure the device and start the daemon:
-
Copy one of the files
lircd.conf-APPLEIR,
lircd.conf-HAUPPAUGE34 or
lircd.conf-HAUPPAUGE45
to /etc/lircd.conf. The HAUPPAUGE remote
is recommended if you want to use GLOTV as your DVR software
(see below). The two versions of the HAUPPAUGE lircd.conf correspond
to the 34-button and the 45-button versions of the remote control.
Click on one of the pictures to the right to download the corresponding
HAUPPAUGE lircd.conf. APPLEIR is not yet supported by GLOTV since it
has too few buttons.
-
Change permissions on the LIRC socket:
chgrp video /dev/lircd
chmod g+w /dev/lircd
-
Put the following in your /etc/rc.d/rc.local:
if [ -x /usr/local/sbin/lircd ]; then
modprobe lirc_dev
modprobe lirc_i2c
/usr/local/sbin/lircd
fi
-
If you have one of the latest pvrusb2 devices (the ones with the IR Blaster)
you will get two lirc devices: /dev/lirc0 and
/dev/lirc1. One of them works, the other one is
an emulated device that only works with earlier hardware. To avoid confusion,
you can disable the non-working device by inserting the following in
/etc/modprobe.d/dvr:
options pvrusb2 ir_mode=0
See this explanation by Mike Isely for further details.
A replacement for LIRC would be a blessing. I am seriously tempted to write
a simple and easy remote control reader myself, but that will have to wait
for a bit.
Install DVR software
-
Install GLOTV, my own lightweight
DVR system. Other possible choices are
MythTV
or
Freevo.
Enable autologin for runlevel 4
-
Replace the Slackware script for runlevel 4,
/etc/rc.d/rc.4,
with the autologin script that is available
here.
Edit the script and change the definition of
$X11USER
to the user that you want autologin for. But first, make sure the
user exists and has a useful ~/.xinitrc.
-
Make LILO boot into runlevel 4 by default. Leave the Slackware
inittab default alone (it's runlevel 3). Instead add the boot
option "4" to the default LILO image in
/etc/lilo.conf.
Look here for such a lilo.conf.
After boot, use the commands telinit 3 and
telinit 4 to switch between runlevels
3 and 4 when needed, i.e. for maintenance work and debugging.