Writing a plugin that outputs to NV12

arta adrian.szatmari at protonmail.com
Wed Oct 30 15:14:59 UTC 2019


For those that have a similar problem, I was able to solve by doing something
like this in the create function:

    GstSpinnakerSrc *src = GST_SPINNAKER_SRC(psrc);
    GstMapInfo minfo;

    //from
https://github.com/joshdoe/gst-plugins-vision/blob/master/sys/genicam/gstgenicamsrc.c,
line 1325
    GstClock *clock;
    GstClockTime clock_time;

    *buf = gst_buffer_new_and_alloc(src->m_Height * src->m_Width +
src->m_Height * src->m_Width / 2);

    gst_buffer_map(*buf, &minfo, GST_MAP_WRITE);

    if (src->m_spinBoolL4_IsAcquisitionStarted) spinnaker_frame(src,
&minfo);

    clock = gst_element_get_clock(GST_ELEMENT(src));
    clock_time = gst_clock_get_time(clock);
    gst_object_unref(clock);

    GST_BUFFER_TIMESTAMP (*buf) = GST_CLOCK_DIFF(gst_element_get_base_time
(GST_ELEMENT (src)), clock_time);

    gst_buffer_unmap(*buf, &minfo);
    return GST_FLOW_OK;

And then in src_get_caps:

    vinfo.finfo = gst_video_format_get_info(DEFAULT_VIDEO_FORMAT);
    gst_video_info_set_format(&vinfo, DEFAULT_VIDEO_FORMAT, src->m_Width,
src->m_Height);
    caps = gst_video_info_to_caps(&vinfo);

With 
#define DEFAULT_VIDEO_FORMAT GST_VIDEO_FORMAT_I420 //the only one supported
In the header file. If anyone has a better way, let me know!



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list