Mpeg2 ts stream gstUtils



Does anyone know if it is possible to get pixels from an mpeg2ts stream to use within OF? This is now week #6 of my excruciating attempt to get pixels from my dvb-t receiver for my university final project.

I’ve invested too much time into this, any help would be extremely appreciated! If someone can help me to get this sorted I’ll send them chocolates.

So far I have tried using:
gstreamers ‘dvbsrc’ to tune and demux straight from source.

tzap to tune the receiver and ffmpeg to convert the receiver mpegts file to an mp4 file, using gstreamers playbin to play the container file.

i receive: “couldn’t get sample caps”

ffmpeg to convert the receivers mpegts file and send over UDP back to myself to pickup with gstUtils playbin.

i receive: “unsupported format xxxxx”

  • many other combinations of the above
    Thanks in advance,


no idea about this specific device but one thing that usually helps is to get it running from the command line using gst-launch, then it’s usually a matter of removing the final sink and let OF add it’s own. Sometimes you need to add an extra element like a videorate to get things working with OF’s own videosink though


Thank you very much for your reply, I’ll keep trying the different pipelines. I’ve been having trouble with missing gst plug-ins, some appear to load in OF but not calling directly from terminal. Does OF use the same gst library/directory as if I were to call gst-launch/ inspect from terminal?

Thanks again!


it should be the same, what platform are you using?


Linux Mint 18.3

At the top of my OF gstUtils file shows (not sure if this helps):

#pragma once

#include “ofConstants.h”
#include “ofConstants.h”
#include “ofBaseTypes.h”
#include “ofPixels.h”
#include “ofTypes.h”
#include “ofEvents.h”
#include “ofThread.h”
#include <gst/gst.h>
#include <gst/gstpad.h>
#include <gst/video/video.h>
#include “ofTexture.h”
#include <condition_variable>

//#define OF_USE_GST_GL
#ifdef OF_USE_GST_GL
#include <gst/gl/gl.h>

Also when I tryout a ‘filesrc’ pipeline within OF it pulls up the glrenderer seperately to the OF window, not sure how to solve this…

using this pipeline: "playbin uri=file:/home/william/output.mp4
(reading a static mp4 file)

leaves me with:
Starting /home/william/openFrameworks/apps/myApps/dvbTV/bin/dvbTV_debug…
[notice ] ofGstUtils: setPipelineWithSink(): gstreamer pipeline: playbin uri=file:/home/william/output.mp4 ! videorate ! appsink name=ofappsink enable-last-sample=0 caps=“video/x-raw, format=RGB”
[ error ] ofGstUtils: setPipelineWithSink(): couldn’t create pipeline: could not link playbin0 to videorate0
[notice ] ofGstUtils: Got context from element ‘sink’:,"(GstGLDisplayX11)\ gldisplayx11-0";

[notice ] ofGstUtils: Got context from element ‘playsink’:,"(GstGLDisplayX11)\ gldisplayx11-0";

[ error ] ofGstUtils: startPipeline(): unable to pause pipeline after 5s
[warning] ofGstUtils: setSpeed(): unable to change speed
[warning] ofGstVideoUtils: update(): ofGstVideoUtils not loaded
[ error ] ofGstUtils: gstHandleMessage(): embedded video playback halted for plugin, module sink reported: Output window was closed
[warning] ofGstVideoUtils: update(): ofGstVideoUtils not loaded

However gstUtils works fine with my integrated camera and videotestsrc


if you are in linux the plugins path should be the same. as i said no idea about this specific device but it’s usually something related to incompatible videoformats, try adding a videoconvert after the device grabber, or timming issues which usually get solved by using a videorate somewhere in the pipeline but in general try to get things working on a terminal with gst-launch and then port it to work in OF


Thank you very much arturo, I really appreciate your reply! I’ll keep playing around with the pipeline using this:

gst-launch-1.0 filesrc location=/dev/dvb/adapter0/dvr0 ! tsdemux ! queue ! mpeg2dec ! videorate ! videoconvert ! autovideosink async-handling=true

It appears to play fine but I can never get a window to open using within terminal, I hope I can get this working soon gstreamer looks packed full of mad plug-ins!

Setting pipeline to PAUSED …
Pipeline is PREROLLING …
Got context from element ‘autovideosink0’:,"(GstGLDisplayX11)\ gldisplayx11-0";
Pipeline is PREROLLED …
Setting pipeline to PLAYING …
New clock: GstSystemClock

I’m wondering if my machine i just cursed for this sort of thing, will try out my rPi this afternoon.
Again, thanks!


mmh, filesrc is not the plugin you need for this. filesrc is used to
open images or a video or similar but not a file device.

to open a device you need a specific plugin. if the device is v4l2
compatible something like:

v4l2src device="/dev/video1"

should work, where video0 is usually the camera in the laptop and video1
would be the dvb device.

There seems to be a dbvsrc as well:

with some examples on how to use it in the description


The dvbsrc route was the first thing I tried, but can’t seem to get it running with my device. I get this bizzare error:

gst-launch-1.0 dvbsrc adapter=0 frequency=10719000 pids=163:92 polarity=v symbol-rate=27500 ! tsdemux ! mpeg2dec ! autovideosink
Setting pipeline to PAUSED …
ERROR: Pipeline doesn’t want to pause.
Got context from element ‘autovideosink0’:,"(GstGLDisplayX11)\ gldisplayx11-0";
ERROR: from element /GstPipeline:pipeline0/GstDvbSrc:dvbsrc0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
Additional debug info:
gstbasesrc.c(3354): gst_base_src_start (): /GstPipeline:pipeline0/GstDvbSrc:dvbsrc0:
Failed to start
Setting pipeline to NULL …
Freeing pipeline …

I save the stream to a file using Tzap (to tune the receiver) and this ffmpeg command:
ffmpeg -i /dev/dvb/adapter0/dvr0 out.mp4

This builds a file I can view absolutely fine and dandy after I have stopped ffmpeg working its magic. I can also view this file in OF using ofGstVideoPlayer. Do you think there would be a way of viewing the mp4 file as a stream live within OF?

Thanks for sticking this out.


I think you should keep trying with dvbsrc or v4l2src rather than trying to read directly from the device file but no idea really. have never worked with a dvb device so can’t tell for sure though.

you can call:

GST_DEBUG=4 gst-launch...

to get more info, the output is quite verbose but usually has information about what elements are failing and why


Brilliant, thanks arturo today has been the most productive with this project.
I have got it running fine within terminal using:

gst-launch-1.0 dvbsrc modulation=qam-64 bandwidth=8 frequency=490000000 code-rate-lp=AUTO code-rate-hp=2/3 guard=16 ! tsdemux ! mpeg2dec ! videorate ! autovideosink

however when removing autovideosink for use within gstUtils I receive:
[ error ] ofGstUtils: setPipelineWithSink(): couldn't create pipeline: could not link videorate0 to ofappsink

(the trouble i was having with dvbsrc was solved looking into GST_DEBUG=4 mode, i swapped my dvb receiver for my other realtek2838 which worked fine (after removing modprobe.d rules which I had previously been messing around with for SDR radio, learn’t my lesson!)).

Feeling very close to the solution I have been dancing around these past weeks!


try adding a videoconvert after the videorate or setting the fps or the full format specification after the videorate


Nailed it, thank you so much Arturo!

Let me know where I can send the chocolate!

#14 :wink: