Tsdemux synchronous file, klv metadata extraction failed

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Tsdemux synchronous file, klv metadata extraction failed

AurelienV
Hi,

I'm trying to write an application which is able to extract (and process/convert) KLV metadata from a TS file or stream.

I found KLV support in private section of tsdemux, and I succeeded to extract them (in file for example) with this pipeline:
(gst-launch-1.0) filesrc location=mytsfile ! tsparse ! tsdemux ! meta/x-klv ! filesink location=klvextract.log

But, this only works with asynchronous TS file (no synchronization between AVC stream and KLV stream).
When I try with synchronous file from command line (gst-launch-1.0), i got this error:

./grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstTSDemux:tsdemux0:
failed delayed linking some pad of GstTSDemux named tsdemux0 to some pad of GstFileSink named filesink0
ERROR: from element /GstPipeline:pipeline0/MpegTSParse2:mpegtsparse2-0: Internal data stream error.

When i try to do same in an application like this:
main.c:
[...]
GstElement *pipeline, *filesrc, *ts_parser, *demuxer, *filter_caps_mtd, *filesink;
[...]
filesrc = gst_element_factory_make ("multifilesrc", "multifilesrc");
if(!filesrc) {
    g_print ("Filesrc not created.\n");
    return -1;
}
g_object_set(G_OBJECT (filesrc), "location", argv[1], NULL);

ts_parser = gst_element_factory_make("tsparse", "ts_parser");
if(!ts_parser) {
    g_print("Unable to created tsparse.\n");
    return -1;
}

filter_caps_mtd = gst_element_factory_make("capsfilter","mtd_filter");
if(!filter_caps_mtd) {
    g_print ("Filter caps not created.\n");
    return -1;
}
GstCaps *mtd_caps = gst_caps_new_empty_simple("meta/x-klv");
g_object_set(G_OBJECT (filter_caps_mtd), "caps", mtd_caps, NULL);

demuxer = gst_element_factory_make("tsdemux", "tsdemux");
if(!demuxer) {
    g_print ("Demuxer not created.\n");
    return -1;
}
g_object_set(G_OBJECT (demuxer), "emit-stats", true, NULL);
g_object_set(G_OBJECT (demuxer), "parse-private-sections", true, NULL);

filesink = gst_element_factory_make("filesink","filesink");
if(!filesink) {
    g_print ("Filesink not created.\n");
    return -1;
}
g_object_set(G_OBJECT (filesink), "location", argv[2], NULL);

gst_bin_add_many (GST_BIN (pipeline), filesrc, ts_parser, demuxer, filter_caps_mtd, filesink, NULL);

if(!gst_element_link(filesrc, ts_parser)) {
    g_print ("Failed to link filesrc and ts_parser!\n");
    return -1;
}

if(!gst_element_link(ts_parser, demuxer)) {
    g_print ("Failed to link ts_parser and demuxer!\n");
    return -1;
}

if(!gst_element_link(demuxer, filter_caps_mtd)) {
    g_print ("Failed to link demuxer and filter_caps_mtd!\n");
    return -1;
}

if(!gst_element_link(filter_caps_mtd, filesink)) {
    g_print ("Failed to link filter_caps_mtd and filesink!\n");
    return -1;
}
[...]

I got an error when linking demuxer(tsdemux) and filter_caps_mtd(meta/x-klv).

If someone have an idea about it ...

Thanks,
Regards
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

gagankumarnigam
Hi,
 
Can u show me your full code ??



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Ian
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

Ian
I have code that is very similar but with dynamic pad linking for the error
listed. But the error persists. Has anyone got working code that extracts
the llv stream and the video stream?



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

William
I have not been able to get tsdemux to work either.  I finally took look at
the code and sure enough tsdemux (1.16.1) only sends asynchronous metadata
out the private pad, synchronous metadata is discarded.  I supposes that is
why it is still in the "bad" plugins; it is incomplete. So I think I am
going to have to roll my own.  Right now I'm thinking that the easiest thing
would be to extend the capabilities of tsdemux. Or maybe I should write my
own plugin to parse out only the meta/x-kvl packets. Can someone with more
familiarity with gstreamer comment on what they would do? I don't want to
march off in the wrong direction and have to change direction two months
from now.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

scottca
Been working with this as well, using 1.17
As noted, Async comes through on private klv pad and looks pretty much
straight forward to decode.
I would seem (and I could be wrong) that in Sync the klv is embedded in the
PES packets of the video,
at least on the Mpeg2s that I have dumped, the H264 looks much different and
still have not confirmed how that is done. Sure wish there was clear
documentation on gstreamer somewhere...




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

scottca
In reply to this post by AurelienV
The demux outputs are linked dynamically at run time by pad, you use the
"pad-added" handler callbacks and get the "sink" pads of the element you are
connecting to.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

Jan Schmidt-6
In reply to this post by scottca

On 5/10/19 11:42 am, scottca wrote:
> Been working with this as well, using 1.17
> As noted, Async comes through on private klv pad and looks pretty much
> straight forward to decode.
> I would seem (and I could be wrong) that in Sync the klv is embedded in the
> PES packets of the video,

Synchronous mode is a different mapping of the KLV data into a PES
stream, but it's not embedded in the video stream - it's still a
separate parallel in the MPEG-TS. I don't think implementing the mapping
to get tsdemux to output the data usefully is difficult, just missing.

There is an unmerged patch at
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/434 for
synchronous KLV support. It's not quite complete - it should check some
other properties of the stream before declaring it KLV.

If anyone has / can make some redistributable sample files, those could
be used to help get that patch merged, and for use in the gst-validate
test-suite to ensure things keep working.

Cheers,

Jan.

> at least on the Mpeg2s that I have dumped, the H264 looks much different and
> still have not confirmed how that is done. Sure wish there was clear
> documentation on gstreamer somewhere...
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

William
Jan Schmidt-6 wrote
> If anyone has / can make some redistributable sample files, those could
> be used to help get that patch merged, and for use in the gst-validate
> test-suite to ensure things keep working.

ESRI has a couple of MPEG-TS files with MISB KLV data on the web that you
can grab:
One is Truck.H264 availiable from:
https://www.arcgis.com/home/item.html?id=55ec6f32d5e342fcbfba376ca2cc409a
And the other is CheyenneVAhospital.mpeg4 from:
https://community.esri.com/docs/DOC-8527-cheyennevahospitalmpeg4

In spite of their file extensions they are both actually MPEG-TS.




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Tsdemux synchronous file, klv metadata extraction failed

scottca
In reply to this post by Jan Schmidt-6
Jan thanks, Not sure I am following, "separate parallel" ? I know the
asynchronous KLV from the TS come through on the separate pad on the demux,
( it has no PST, and can contain one to many key values embedded) I have no
problem with these data blocks, they all have SMPTE start descriptors. I
just assumed the synchronous KLV was somehow in the PES of the video stream
(mpeg/264) since the klv pad does not trigger, Was figuring they came
through with just different ID values ( tagged private) so as not to be
confused as video and could identify them by parsing them from the PES
blocks.. Are you saying that is not the case? That the demux should be
feeding these through onto the klv pad? Thanks



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel