Take snapshot from running pipeline in gstreamer with iOS

Ruben Gonzalez rubenrua at teltek.es
Thu Aug 18 21:22:14 UTC 2016


Hi all

I have written a simple snippet in C to take a snapshot from running
pipeline and test gst_video_convert_sample [1]. IMHO take snapshot should
be a must inside GStreamer and a function like
gst_video_write_sample_to_file would be a good idea.

Looking inside gst_video_convert_sample and gst_play_sink_convert_sample,
coding gst_video_write_sample_to_file should be easy using a filesink. If
these feature is useful for the community, let me know it and I could try
to do it.

[1] https://github.com/rubenrua/GstreamerCodeSnippets/blob/
master/C/takepic.c

2016-08-17 12:47 GMT+02:00 Macjon <jonah.hulselmans at flowpilots.com>:

> I've got a peace of code that works. I removed the tee from my pipeline.
> And
> now I have the following objective-c code:
>
> -(UIImage*) takeSnapshot
> {
>     GstSample *videobuffer = NULL;
>     GstCaps *caps;
>     gint width, height;
>     GstMapInfo map;
>
>     g_object_get(G_OBJECT(video_sink), "last-sample", &videobuffer, NULL);
>
>     if (videobuffer)
>     {
>         caps = gst_sample_get_caps(videobuffer);
>
>         if (!caps) {
>             return NULL;
>         }
>
>         GstStructure *s = gst_caps_get_structure(caps, 0);
>         /* we need to get the final caps on the buffer to get the size */
>         gboolean res;
>         res = gst_structure_get_int (s, "width", &width);
>         res |= gst_structure_get_int (s, "height", &height);
>         if (!res) {
>             return NULL;
>         }
>
>         GstBuffer *snapbuffer = gst_sample_get_buffer(videobuffer);
>         if (snapbuffer && gst_buffer_map (snapbuffer, &map, GST_MAP_READ))
>         {
>             CGDataProviderRef provider = CGDataProviderCreateWithData(
> NULL,
>                                                                   map.data,
>                                                                   height *
> width * 4,
>                                                                   NULL);
>
>             CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
>             CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
>             CGColorRenderingIntent renderingIntent =
> kCGRenderingIntentDefault;
>
>             CGImageRef imageRef = CGImageCreate(width,
>                                             height,
>                                             8,
>                                             4 * 8,
>                                             width * 4,
>                                             colorSpaceRef,
>                                             bitmapInfo,
>                                             provider,
>                                             NULL,
>                                             NO,
>                                             renderingIntent);
>
>             UIImage *uiImage = [UIImage imageWithCGImage:imageRef];
>             CGColorSpaceRelease(colorSpaceRef);
>             CGImageRelease(imageRef);
>
>             return uiImage;
>         }
>
>         return NULL;
>     }
>
>     return NULL;
> }
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.
> n4.nabble.com/Take-snapshot-from-running-pipeline-in-gstreamer-with-iOS-
> tp4678410p4679126.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>



-- 
Best regards/Un Saludo

Ruben Gonzalez Gonzalez
TELTEK Video Research
http://teltek.es/




*La información contenida en este mensaje y/o archivo(s) adjunto(s) es
confidencial/privilegiada y está destinada a ser leída sólo por la(s)
persona(s) a la(s) que va dirigida. Si usted lee este mensaje y no es el
destinatario señalado, el empleado o el agente responsable de entregar el
mensaje al destinatario, o ha recibido esta comunicación por error, le
informamos que está totalmente prohibida, y puede ser ilegal, cualquier
divulgación, distribución o reproducción de esta comunicación, y le
rogamos que nos lo notifique inmediatamente y nos devuelva el mensaje
original a la dirección arriba mencionada. Gracias.The **information
contained in this message and/or attached file(s) is
confidential/privileged and is intended to be read only by the person(s) to
whom it is directed. If you are reading this message and you are not the
indicated recipient, or the employee or agent responsible for delivering
the message to the addressee, or you have received this communication by
mistake, please be aware that **any dissemination, distribution or
reproduction of this communication is strictly prohibited and may be
illegal. Please notify us immediately and return the original message to
the aforementioned address. Thank you.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160818/d9452609/attachment.html>


More information about the gstreamer-devel mailing list