Speeding up a queue

Martin Vachovski Martin.Vachovski at skytek.com
Fri Sep 8 09:11:02 UTC 2017


Hi Simon,


Three suggestions in the order of relevance:


1) I think there is no need to explicitly call

gst_buffer_ref(buffer)-- the gst_sample_get_buffer should do it internally


2) Are you sure that the performance is the issue here?

Try changing the condition whether you access the data

and see when it stops working, like:

if(!(buffCntr % 20)) // every 20th

then

if(!(buffCntr % 15)) // every 15th

and see if for sufficiently small denominator it stops working


3) Also, try calling the "unref" methods in the opposite order as the "get/ref" methods:

You have

ref(sample)

ref(buffer)

But you release the sample first

unref(sample)

unref(buffer)?

I think it should be:

unref(buffer)

unref(sample)


Hope that helps

Martin


________________________________
From: gstreamer-devel <gstreamer-devel-bounces at lists.freedesktop.org> on behalf of simo zz <simon.zz at yahoo.com>
Sent: Thursday, September 7, 2017 5:00 PM
To: Discussion of the Development of and With GStreamer
Subject: Speeding up a queue

Hello,
I need to record a video from the USB camera and process the raw-data at the same time, so I successfully implemented this pipeline in C:

v4l2src device=/dev/webcam ! videoconvert ! video/x-raw,width=544,height=288,framerate=10/1 ! tee name=t ! queue ! v4l2h264enc ! h264parse ! mp4mux ! filesink location=video.mp4 t. ! queue ! appsink

I can access to raw-data from USB camera is read using the "new-sample" signal of appsink in a function called "dataProbe", code as follows:

GstFlowReturn dataProbe(GstElement *source)
{
    // buffCntr is just a counter to choose when I want to process the raw-data
    if (!(buffCntr % 10))
    {
        GstMapInfo map;
        GstSample *sample = gst_app_sink_pull_sample(GST_APP_SINK(source));
        GstBuffer *buffer = gst_sample_get_buffer(sample);
        gst_buffer_ref(buffer);
        gst_buffer_map (buffer, &map, GST_MAP_READ);
        g_print("Map size: %d\n", map.size);

        /*int8_t fd = open("/path/to/someFile", O_CREAT | O_WRONLY);
        if (fd != -1)
        {
            if(write(fd, map.data, map.size) == map.size)
                g_print("Written whole data\n");
            else
                g_print("Cannot write whole data\n");
        }
        close(fd);*/
        gst_buffer_unmap(buffer, &map);
        gst_sample_unref(sample);
        gst_buffer_unref(buffer);

        //buffCntr = 0;
    }
}

But the execution of the function dataProbe is so critical that if I set buffCntr to zero (as shown in the last commented instruction of the function) even without writing map.data to some file, the whole program hangs, so the mp4 video is not written anymore..
But I need both raw-data and mp4 video.

What can I do to 'speed up' this queue and let my gstreamer program to record the video and write the raw data somewhere ? Pthread ? There is some helpful feature already available from gstreamer library to handle this situation ?

The device which run the application is an embedded board with a quad core CPU.

Thank you in advance.
Regards,
Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170908/468fd437/attachment.html>


More information about the gstreamer-devel mailing list