DVBICE

Introduction

DVBICE is a tool for streaming digital TV in realtime to an icecast server:

DVBICE fully decode, decompress the digital TV MPEG2 TS signal, recompress using XIPH CODECs and then stream to an icecast server in realtime:

The software can directly attach to a DVB Linux device or use a RTP/MPEG-TS from the dvbstream tool.

Quick install

First you need the following library installed on your computer:

  • FFMPEG with MPEG2,
  • Xiph LibVorbis,
  • Xiph LibTheora and
  • LibShout.

Use the “make” command to compile dvbice. Except for accessing the DVB card on some distribution, the process don't need root access. A simple chmod can fix that.

Quick how-to guide

To run dvbice, you need to create a configuration XML. A template is included in the zip file.

Just run:

dvbice <XML config>

How it works

The TV has changed and the era of analogue transmission is almost over. Single TV channel broadcast have been replaced by digital one capable of transmitting more than one program at once. In Europe, the DVB (for Digital Video Broadcasting) is now universally used on all transmission media: Terrestrial, Satellite and Cable. The main part of the norm is to define how the signal is transmitted on the different media. The designers were clever enough to define that the carried digital signal should be in the same format irrespective of the carrier: an extension of the MPEG2-TS.

The MPEG2-TS stream is a packet stream of a fixed length (188 bytes) starting with the Sync Byte (0x47) and associated to a 13-bits Program Identifier or PID. To avoid flooding the CPU with non interesting information, DVB receiver have built-in hardware filter that allows the software to select which PID packet streams they are interested in.

For a programmer perspective, this fascinating as you can access TV broadcast as a form of fancy read-only file that never end. I was looking for a solution for retransmitting some TV broadcast without paying some crippled fancy boxes. So I decided to develop my own solution.

DVBICE is developed in C (because of issue with some early version of GCC that was installed on one of my Linux box). The sources are URL plug-ins and are registered into FFMPEG AVFORMAT at runtime. They contain the glue code that receives the MPEG-TS packets from the DVB card or the network card. Because the AVFORMAT loop is synchrone (read-process-read-process), the source plug-ins uses Linux asynchronous IO to avoid loosing packets.

I’m using the FFMPEG AVFORMAT library for un-muxing the different streams as the FFMPEG decoders depends on some quirk of the FFMPEG implementation. The decoded stream is scaled down using FFMPEG SWSCALE library and then fed to the XIPH stack.

The data flows are controlled by object like structures that process their stage of process:

The PushPacket function stage is to: decode incoming data, rescale and use the associate XIPH codec. The result OGG Pages, if one or more are created, are then given to the associated Mux for transmission. All the structures are built and linked by the configuration reader.

AttachmentSize
dvbice.zip30.61 KB
config.xml2.29 KB