Tuesday, 4 June 2013

MythTV and Recording from a SkyHD box.

At the moment my setup is as follows, a MythTV box runing Ubuntu Linux 11, with to Hauppauge Nova-S Plus S1 PCI Satellite cards. and 2TB of space.

It records (Mostly in SD since the BBC swapped to the S2 standard) quite happily day to day but I like to record the F1 to watch in the off season, so since this moved to Sky (boo hiss!!!) I need a way to get the recordings from the Sky box and on to MythTV.

3 Options present themselves

Option 1

Use Compisite out on the SkyHD box to the Composite in on one of Nova-S cards.
Downsides:Poor Quality

Option 2

open the SkyHD box take out the hard drive, nab the encrypted gp file, decrypt and ta da
Upsides:Free, HD

Option 3

use a HDMI in type recording device
Upsides:Easy, HD
Downsides:Not free, what if Sky switch on the HDCP encryption?

To begin with I'll go with Option 1 and see what the quality is like:
Capture over composite from SkyHD box.
Capture Via Composite from Sky HD Box
Not bad, watchable. But this is where i start to run into problems with sound. While the picture works a treat /dev/video0 there is no sound. Debugging the sound was a total pain in the whatsists and this blog entry is really here so I have somewhere to log the steps I went through.

Step 1, list all the audio in devices:

maff@mythbox:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC889 Analog [ALC889 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 2: ALC889 Analog [ALC889 Analog]
  Subdevices: 2/2
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
card 2: CX8801 [Conexant CX8801], device 0: CX88 Digital [CX88 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: CX8801_1 [Conexant CX8801], device 0: CX88 Digital [CX88 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And this is where the fun and games begins, you can see the two sat cards CX8801 and CX8801_1. CX8801 is always /dev/video0 and CX8801_1 /dev/video1 however some times, say every other boot, the sound in is HW:2,0 and some times HW:3,0. Weird. Ok how about I plug the sound into mic in on the PC, thats unlikely to change. HW:0,0

To test this, a quick arecord remembering to specify sample rate of 48000 as this is what MythTV needs:

arecord -D hw:0,0 -r 48000 -f S16_LE -c2 foobar.wav

and play it back:
vlc foobar.wav


excellent, so back the mythtv-setup bash in hw:0,0 in the card config, save back to mythtv and....



so whats the difference, arecord can get audio from hw:0,0 but not mythtv, turns out Mythtv needs an ALSA prefix in order to work so should be set to ALSA:hw:0,0 and finally sound!

Awesome, hopefully next time it craps out and goes silent I'll now have somewhere to look and find out what I did.