Speeding up a queue

Nicolas Dufresne nicolas at ndufresne.ca
Fri Sep 8 17:21:10 UTC 2017


Le vendredi 08 septembre 2017 à 09:11 +0000, Martin Vachovski a écrit :
> 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

No it "transfer none".

> 
> 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)

This is usually not required with ref-counting in general. Since if
there dependent object will have a ref on the other, which guaranty the
free order for you.

> 
> 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
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170908/b9b2108e/attachment.sig>


More information about the gstreamer-devel mailing list