Command Line Television

I have some grand plans for the final software for this project, but as an intermediate step I'm writing a set of command-line programs to view DVB-T live television, to play DVDs, and to view iPlayer content. So far I have TV and DVD programs. Source is here. I have attempted to make the source reasonably readable so don't hesitate to look at it to understand what is going on. The TV program:

The DVD program:

These programs both run with CPU usage below 10%, which I presume is mostly attributable to the audio decoding. Having said that the reported load average is around 0.9 - what does that mean?

AV Synchronisation and Binary Blobs

Currently I'm experimenting with how to synchronise audio and video. I think that what I should do is to save the timestamps from the two streams as I demultiplex them and then have a single output thread that outputs both streams synchronously. A much simpler alternative, however, is simply to start playing both streams at the same time and to rely on their rates matching to ensure that they stay in sync. I have experimented with this in the DVD program by buffering the encoded audio data as it is demultiplxed until the first video frame is ready for display, and then starting the audio decoding. This seems to work but is rather fragile; it's not clear what the buffer sizes should be, and I get crashes where the VPU driver times out waiting for an interrupt. So do I have to do it "properly"?

Ideally, the VPU would extract the timestamps from its input stream and report them for each frame that it outputs. Any other scheme requires that you either guess the latency of the VPU, or parse enough of the video stream to work it out. The reason for the difficulty is that you can start at any point in the video stream, but the VPU will skip forward to the next I-frame before it outputs anything. You need to parse the input to know where the I-frames are. As I understand it, the VPU consists of a DSP processor and some hardware blocks for e.g. DCT calculations. If we had the source to the DSP code we could probably modify it to put these timestamps in its output - but we have only binary blobs.

cltv Shell

I've created a command interpretter shell that runs on the TV display:

I can use this with a wireless keyboard to select TV channels, and easily add more features as needed.

I have a number of challenges with this:

I feel this should all be easy, but the console seems surprsingly complicated.