Speeding up a queue

simo zz simon.zz at yahoo.com
Thu Sep 7 16:00:18 UTC 2017


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/20170907/e4477ac5/attachment-0001.html>


More information about the gstreamer-devel mailing list