Mpeg2 ts stream gstUtils


#1

Hello!

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,
    William.

#2

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


#3

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!
William


#4

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


#5

Linux Mint 18.3
Kernel:4.13.0-41-generic.

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

#pragma once

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

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

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’: gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"(GstGLDisplayX11)\ gldisplayx11-0";

[notice ] ofGstUtils: Got context from element ‘playsink’: gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"(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


#6

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


#7

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’: gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"(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!


#8

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:
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad-plugins/html/gst-plugins-bad-plugins-dvbsrc.html

with some examples on how to use it in the description


#9

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’: gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"(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.


#10

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


#11

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!


#12

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


#13

Nailed it, thank you so much Arturo!

Let me know where I can send the chocolate!


#14

https://openframeworks.cc/donations/ :wink:


#15

Hello Everyone,
i am using DVB-S2 tuner card, for this i tried gstreamer ‘dvbsrc’ to tune for this i used it:-

gst-launch-1.0 dvbsrc polarity=“h” frequency=4064000 symbol-rate=19850 diseqc-source=0 ! decodebin ! autovideoconvert ! autovideosink

and after this i get some messages like-

Setting pipeline to PAUSED …
ERROR: Pipeline doesn’t want to pause.
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(3356): gst_base_src_start (): /GstPipeline:pipeline0/GstDvbSrc:dvbsrc0:
Failed to start
Setting pipeline to NULL …
Freeing pipeline …

It’s not to do the tuning which i want from this DVB-S2 card and not to understand what to do after that, please help me out and completely stocked here.


#16

Have you had a look at this?: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad/html/gst-plugins-bad-plugins-dvbsrc.html

I haven’t been able to get dvbt2 using this method.

Can you receive dvbt ok?


#17

Thanks for reply,
no i am not getting DVB-T also may my card TBS5927 supports only DVB-S2 and i spend too much time in this but still not succeeded…
is it work proper with DVB-T using listed command-

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


#18

It does work using a DVB-T from here in London UK, if you are using linux you might want to check out the tzap and dvbtools for linux to create a ‘.config file’ which includes a list of all the receptions you can pick up in your area.

It’s also worth buying a cheap RTL dongle, as I found that I was going round and round in circles as the GStreamer wouldn’t tune my ‘huappage’ dongle. Let me know how you get on I’ll be more than happy to assist where I can