<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1504799459941_2385">Hello, <br></div><div id="yui_3_16_0_ym19_1_1504799459941_8753" dir="ltr">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:</div><div id="yui_3_16_0_ym19_1_1504799459941_4394"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1504799459941_4395"><strong id="yui_3_16_0_ym19_1_1504799459941_4401">v4l2src device=/dev/webcam ! videoconvert ! video/x-raw,width=544,height=288,framerate=10/1</strong><b id="yui_3_16_0_ym19_1_1504799459941_4403"> ! tee name=t ! <strong id="yui_3_16_0_ym19_1_1504799459941_4402">queue ! v4l2h264enc ! h264parse ! mp4mux ! filesink location=video.mp4</strong> t. ! queue ! appsink</b></div><div id="yui_3_16_0_ym19_1_1504799459941_4517" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1504799459941_4518" dir="ltr">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:</div><div id="yui_3_16_0_ym19_1_1504799459941_5317" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1504799459941_5305" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_5316">GstFlowReturn dataProbe(GstElement *source)<br id="yui_3_16_0_ym19_1_1504799459941_5280">{  <br></b></div><div id="yui_3_16_0_ym19_1_1504799459941_5441" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_5316">    // buffCntr is just a counter to choose when I want to process the raw-data<br></b></div><div id="yui_3_16_0_ym19_1_1504799459941_5322" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_8236">    if (!(</b><b id="yui_3_16_0_ym19_1_1504799459941_5316"><b id="yui_3_16_0_ym19_1_1504799459941_8237">buffCntr</b> % 10))<br id="yui_3_16_0_ym19_1_1504799459941_5282">    {   <br id="yui_3_16_0_ym19_1_1504799459941_5283">        GstMapInfo map;<br id="yui_3_16_0_ym19_1_1504799459941_5284">        GstSample *sample = gst_app_sink_pull_sample(GST_APP_SINK(source));<br id="yui_3_16_0_ym19_1_1504799459941_5285">        GstBuffer *buffer = gst_sample_get_buffer(sample);<br id="yui_3_16_0_ym19_1_1504799459941_5286">        gst_buffer_ref(buffer);<br id="yui_3_16_0_ym19_1_1504799459941_5287">        gst_buffer_map (buffer, &map, GST_MAP_READ);<br id="yui_3_16_0_ym19_1_1504799459941_5288">        g_print("Map size: %d\n", map.size);</b></div><div id="yui_3_16_0_ym19_1_1504799459941_5669" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_5316"><br></b></div><div id="yui_3_16_0_ym19_1_1504799459941_5671" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_5316">        /*int8_t fd = open("/path/to/someFile", O_CREAT | O_WRONLY);<br id="yui_3_16_0_ym19_1_1504799459941_5290">        if (fd != -1)<br id="yui_3_16_0_ym19_1_1504799459941_5291">        {<br id="yui_3_16_0_ym19_1_1504799459941_5292">            if(write(fd, map.data, map.size) == map.size)<br id="yui_3_16_0_ym19_1_1504799459941_5293">                g_print("Written whole data\n");<br id="yui_3_16_0_ym19_1_1504799459941_5294">            else<br id="yui_3_16_0_ym19_1_1504799459941_5295">                g_print("Cannot write whole data\n");<br id="yui_3_16_0_ym19_1_1504799459941_5296">        }<br id="yui_3_16_0_ym19_1_1504799459941_5297">        close(fd);*/<br id="yui_3_16_0_ym19_1_1504799459941_5298">        gst_buffer_unmap(buffer, &map);<br id="yui_3_16_0_ym19_1_1504799459941_5299">        gst_sample_unref(sample);<br id="yui_3_16_0_ym19_1_1504799459941_5300">        gst_buffer_unref(buffer);</b></div><div id="yui_3_16_0_ym19_1_1504799459941_5672" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_5316"><br></b></div><div id="yui_3_16_0_ym19_1_1504799459941_5842" dir="ltr"><b id="yui_3_16_0_ym19_1_1504799459941_8240">        //</b><b id="yui_3_16_0_ym19_1_1504799459941_5316"><b id="yui_3_16_0_ym19_1_1504799459941_8241">buffCntr</b> = 0;<br id="yui_3_16_0_ym19_1_1504799459941_5302">    }<br id="yui_3_16_0_ym19_1_1504799459941_5303">}</b><br id="yui_3_16_0_ym19_1_1504799459941_5304"></div><div id="yui_3_16_0_ym19_1_1504799459941_5849" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1504799459941_6779" dir="ltr">But the execution of the function dataProbe is so critical that if I set buffCntr<b id="yui_3_16_0_ym19_1_1504799459941_5968"> </b>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.. <br></div><div id="yui_3_16_0_ym19_1_1504799459941_7237" dir="ltr">But I need both raw-data and mp4 video.<br></div><div id="yui_3_16_0_ym19_1_1504799459941_9446" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1504799459941_7008" dir="ltr">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 ?</div><div id="yui_3_16_0_ym19_1_1504799459941_7238" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1504799459941_7357" dir="ltr">The device which run the application is an embedded board with a quad core CPU.</div><div id="yui_3_16_0_ym19_1_1504799459941_7360" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1504799459941_7477" dir="ltr">Thank you in advance.</div><div id="yui_3_16_0_ym19_1_1504799459941_7478" dir="ltr">Regards,</div><div id="yui_3_16_0_ym19_1_1504799459941_9563" dir="ltr">Simon<br></div></div></body></html>