Sending timestamp metadata from C++ to Python

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

Sending timestamp metadata from C++ to Python

Wilkins White
I would like to send metadata, specifically GstReferenceTimestampMeta, from
my C/C++ application to a Python application. It seems like I should be able
to accomplish this with `appsrc ! ipcpipelinesink` and `ipcpipelinesrc !
appsink` but the metadata isn't showing up on the Python side.  Am I missing
something obvious, or will metadata not travel through
ipcpipelinesink/ipcpipelinesrc?

On my C++ application I am loading an appsrc with data from a CUDA pipeline
which feeds an ipcpipelinesink. I am using
`gst_buffer_add_reference_timestamp_meta` to add the reference timestamp for
when the frame was captured. I was able to read the value back using
`gst_buffer_get_reference_timestamp_meta` so I know it is there.

    // Allocate a new GstBuffer
    GstBuffer *gstbuf = gst_buffer_new_allocate(nullptr, buffer_size,
nullptr);

    // Add reference timestamp to metadata
    GstClockTime timestamp = static_cast<uint64_t>(ctx->m_frame.m_ts);

    GstCaps *reference =
gst_caps_from_string("timestamp/x-metavision-stream");

    gst_buffer_add_reference_timestamp_meta(
        gstbuf, reference, timestamp, GST_CLOCK_TIME_NONE);

    // Set pipeline timestamp
    if(ctx->m_init_ts == 0)
        ctx->m_init_ts = timestamp;

    gstbuf->pts = timestamp - ctx->m_init_ts; // ns
    gstbuf->dts = gstbuf->pts;

    // Map GstBuffer (output)
    GstMapInfo map;
    memset(&map, 0, sizeof(GstMapInfo));
    gst_buffer_map(gstbuf, &map, GST_MAP_WRITE);

    // Copy NvBuffer to GstBuffer
    ...

    // Unmap
    gst_buffer_unmap(gstbuf, &map);

    // Push buffer
    gst_app_src_push_buffer(GST_APP_SRC(ctx->m_appsrc), gstbuf);

On the Python side I create an ipcslavepipeline with an ipcpipelinesrc
feeding an appsink. Caps are negotiated properly and I am able to convert
the Gst.Buffer into a numpy array, but
`Gst.Buffer.buf.get_reference_timestamp_meta` is returning None:

    buf = sample.get_buffer()

    reference = Gst.Caps.from_string('timestamp/x-metavision-stream')
    ts_meta = buf.get_reference_timestamp_meta(reference) #
Gst.ReferenceTimestampMeta
    print(ts_meta) # None

Am I barking up the wrong tree here? I would appreciate any input.




--
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: Sending timestamp metadata from C++ to Python

Wilkins White

Found this in the logs:

0:00:13.756895364 11417   0x55ae8c7540 WARN         ipcpipelinecomm gstipcpipelinecomm.c:483:build_meta:<ipcpipelinesink0> Ignoring GstMeta type GstReferenceTimestampMetaAPI

Looks like ipcpipelinesink does ignore GstReferenceTimestampMetaAPI, I'll have to do some more research

On 8/27/20 5:42 PM, Wilkins White wrote:
I would like to send metadata, specifically GstReferenceTimestampMeta, from
my C/C++ application to a Python application. It seems like I should be able
to accomplish this with `appsrc ! ipcpipelinesink` and `ipcpipelinesrc !
appsink` but the metadata isn't showing up on the Python side.  Am I missing
something obvious, or will metadata not travel through
ipcpipelinesink/ipcpipelinesrc?

On my C++ application I am loading an appsrc with data from a CUDA pipeline
which feeds an ipcpipelinesink. I am using
`gst_buffer_add_reference_timestamp_meta` to add the reference timestamp for
when the frame was captured. I was able to read the value back using
`gst_buffer_get_reference_timestamp_meta` so I know it is there.

    // Allocate a new GstBuffer
    GstBuffer *gstbuf = gst_buffer_new_allocate(nullptr, buffer_size,
nullptr);

    // Add reference timestamp to metadata
    GstClockTime timestamp = static_cast<uint64_t>(ctx->m_frame.m_ts);

    GstCaps *reference =
gst_caps_from_string("timestamp/x-metavision-stream");

    gst_buffer_add_reference_timestamp_meta(
        gstbuf, reference, timestamp, GST_CLOCK_TIME_NONE);

    // Set pipeline timestamp
    if(ctx->m_init_ts == 0)
        ctx->m_init_ts = timestamp;

    gstbuf->pts = timestamp - ctx->m_init_ts; // ns
    gstbuf->dts = gstbuf->pts;

    // Map GstBuffer (output)
    GstMapInfo map;
    memset(&map, 0, sizeof(GstMapInfo));
    gst_buffer_map(gstbuf, &map, GST_MAP_WRITE);

    // Copy NvBuffer to GstBuffer
    ...

    // Unmap
    gst_buffer_unmap(gstbuf, &map);

    // Push buffer
    gst_app_src_push_buffer(GST_APP_SRC(ctx->m_appsrc), gstbuf);

On the Python side I create an ipcslavepipeline with an ipcpipelinesrc
feeding an appsink. Caps are negotiated properly and I am able to convert
the Gst.Buffer into a numpy array, but
`Gst.Buffer.buf.get_reference_timestamp_meta` is returning None:

    buf = sample.get_buffer()

    reference = Gst.Caps.from_string('timestamp/x-metavision-stream')
    ts_meta = buf.get_reference_timestamp_meta(reference) #
Gst.ReferenceTimestampMeta
    print(ts_meta) # None

Am I barking up the wrong tree here? I would appreciate any input.




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

Wilkins White | Firmware Engineer | [hidden email]
517 N 19th St, Philomath, OR | <a href="tel:+15038050762">503.805.0762


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel