Difference between revisions of "Simple DVB with Gstreamer and GNU Radio"

From MyLabWiki
Jump to: navigation, search
(Problems / TODOs)
(Simulator)
 
(2 intermediate revisions by one user not shown)
Line 3: Line 3:
 
== Overview ==
 
== Overview ==
  
The objective is to create a simple digital video broadcasting setup using easily available components as illustrated on the figure below. The long term goal is to get a similar setup up to [http://en.wikipedia.org/wiki/Near_space near space] by the end of 2010 and [http://en.wikipedia.org/wiki/Low_Earth_orbit LEO] by the end of 2011.
+
The objective is to create a simple digital video broadcasting setup using easily available components as illustrated on the figure below. The long term goal is to get a similar setup up to [http://en.wikipedia.org/wiki/Near_space near space] and [http://en.wikipedia.org/wiki/Low_Earth_orbit LEO].
  
 
[[Image:DvbSys.jpg|600px]]
 
[[Image:DvbSys.jpg|600px]]
Line 90: Line 90:
 
=== Simulator ===
 
=== Simulator ===
  
This simple simulator was used to test the idea before it was put on the air. It simply sends the video through a GMS modulator, mixes it with noise, the a GMSK demodulator.
+
This simple simulator was used to test the idea before it was put on the air. It simply sends the video through a GMSK modulator, mixes it with noise, the a GMSK demodulator.
  
 
[[Image:Gmsk_sim.grc.png|700px]]
 
[[Image:Gmsk_sim.grc.png|700px]]
Line 129: Line 129:
 
** Independent of frame rate and computer speed
 
** Independent of frame rate and computer speed
 
** Only happens with the camera (not video test stream)
 
** Only happens with the camera (not video test stream)
** Only happens with USRP attached (not when using the simulator=
+
** Only happens with USRP attached (not when using the simulator)
  
 
== References ==
 
== References ==

Latest revision as of 14:26, 25 June 2011

This article describes a simple video broadcasting setup based on Gstreamer, GNU Radio and the Universal Software Radio Peripheral (USRP). It does not (yet) provide any DVB-T or DVB-S compatible system — just a simple way to get your webcam on the air!

Contents

Overview

The objective is to create a simple digital video broadcasting setup using easily available components as illustrated on the figure below. The long term goal is to get a similar setup up to near space and LEO.

DvbSys.jpg

UVC Webcam
An UVC compliant webcam is used as a cheap but efficient video source. Current webcams can provide video at HD resolutions, though the image quality is not as good as with a good HD camcorder. Nevertheless, UVC cameras are very easy to capture via USB and are thus excellent for functional and performance testing purposes.
Gstreamer
Gstreamer is used for everything related to video processing. This includes capturing the video frames from the camera(s), adding text overlays, compressing, encoding and multiplexing into a transport stream. See my Gstreamer Cheat Sheet for all the cool stuff we can do with Gstreamer.
GNU Radio
GNU Radio is used to create the software defined radio transmitters and receivers.
USRP
The Universal Software Radio Peripheral provides the necessary transmitter and receiver hardware to get our signals on the air (bits and bytes can not fly)

Standard PC hardware is used to run both the Gstreamer and GNU Radio processes, i.e. we do not use any expensive video compression hardware. A modern PC with an Intel i7 processor is perfectly capable of compressing the HD video and running the software radio process at the same time.

Using these components we can accomplish some very advanced and cool functionalities, such as:

  1. Get multiple video streams and other data into one data stream (e.g. MPEG-TS)
  2. Experiment with different codecs and containers
  3. Experiment with different combinations of modulation and FEC
  4. Run simulations without any RF hardware in the loop
  5. Get on the air on 1.2 GHz (WBX, DBSRX, RFX1200), 2.4 GHz (RFX2400) and many other frequencies
  6. Setup two-way video chats

Source code

The source code is available from http://github.com/csete/gnuradio-dvb - check out with:

 git clone http://github.com/csete/gnuradio-dvb.git

or

 git clone git://github.com/csete/gnuradio-dvb.git

V1: Conceptual prototype

This is the very first muck-up that I used to get my Logitech Webcam Pro 9000 webcam on the air. It encodes the video to H.264/MPEG-TS and uses GMSK modulation. There is no error correction. Gstreamer and GNU Radio are connected using named pipes.

DvbSysDia.png

The setup is quite functional and robust, though it suffers from the fact that the MPEG-TS muxer does not support CBR, which is required by GNU Radio and the USRP. Consequently, the video freezes every now and then for about half a second (buffering).

There are two videos showing this prototype in action, one using a video test source and one using a webcam.

Transmitter

GNU Radio Companion flow graph:

Gmsk tx.grc.png

Gstreamer pipeline:

 gst-launch -e -v v4l2src device="/dev/video1" ! video/x-raw-yuv, framerate=25/1, width=640, height=360 ! \
   timeoverlay halign=right valign=bottom shaded-background=true ! \
   textoverlay text="Test Video 640x360 25fps" halign=left valign=bottom shaded-background=true ! \
   x264enc bitrate=498 ! mpegtsmux ! filesink location=video1.ts

Before executing anything, create the pipe that will be used to connect Gstreamer with GNU Radio:

 mkfifo video1.ts

Receiver

Gmsk rx.grc.png

For Gstreamer pipeline I wanted to use something simple like

 gst-launch -v playbin uri=file:///path/to/video2.ts

but this does not work (probably due to the mixed VBR/CBR). Fortunately, mplayer can be used instead:

 mplayer video2.ts

Before executing anything, create the pipe that will be used to connect Gstreamer with GNU Radio:

 mkfifo video2.ts

Transceiver

This simple, full duplex transceiver was created to allow using one computer and one USRP for both transmit and receive. By default, both the receiver and the transmitter are set to use the same frequency so that the receiver will receive what the local transmitter transmits; however, it can also be used to make two way video contacts.

GmskTrx.grc.jpg

This transceiver has been running well on a 13" 2.4GHz MacBook Pro for more than 4.5 hours (video of the setup and blog post).

GmskTrxSetup.jpg GmskTcvrScreenshot.png

Simulator

This simple simulator was used to test the idea before it was put on the air. It simply sends the video through a GMSK modulator, mixes it with noise, the a GMSK demodulator.

Gmsk sim.grc.png

A video demo of the simulator in action is available here.

Other codecs

The setup was also tested using Theora codec in Ogg container. It ran very well (in some way better than H.264+MPEG-TS) in simulator and transceiver mode when using a vuideotestsrc; however, with the Logitech Webcam Pro 9000 it lost sync after a few minutes and the mplayer console got filled with "Ogg: bad packet in stream 0" messages and the effective framerate was down at 1 fps.

GR-DVB-TheoraSim.png

GR-DVB-TheoraTrx1.png GR-DVB-TheoraTrx2.png

See blog post: An experiment with Theora and Ogg for DVB.

V2: Phase Shift Keying

Will introduce BPSK and QPSK


V3: FEC

Will ad error correction code


Problems / TODOs

  • The MPEG-TS muxer in Gstreamer does not currently support CBR and the only way to get close to CBR is via the H.264 encoder, which is not constant enough.
    • Fix the MPEG-TS muxer
    • The MPEG-TS muxer in the mplayer repository has been updated to support CBR
  • Reduce the delay. I suspect it is introduced by the encoder because when I mess with the RF parameters I can observe the effects immediately.
  • The default encoding is not optimal. Try to translate ffpreset to x264enc parameters
  • On Ubuntu 10.04, mplayer reports the framerate to be twice the actual frame rate. On 9.10 it reports the correct frame rate.
  • There is a ~300 msec freeze in the stream every 2 seconds
    • Independent of frame rate and computer speed
    • Only happens with the camera (not video test stream)
    • Only happens with USRP attached (not when using the simulator)

References

Blogs

Videos

  • 2010.07.25: GStreamer / GNU Radio video transmission simulator - first signals: YouTube.
  • 2010.08.03: DVB with GNU Radio and Gstreamer - Test stream: YouTube.
  • 2010.08.03: DVB with GNU Radio and Gstreamer - Webcam: YouTube.
  • 2010.08.07: DVB with GNU Radio and GStreamer - GMSK Transceiver: YouTube.

Related articles

  1. Embedded Video Processing and Radio Unit