Get Frame Size from GstSample in new-sample callback

Dwight Kulkarni dwight at realtime-7.com
Mon Sep 26 16:16:56 UTC 2022


Hi all,

Have a gstreamer pipeline with:
v4l2src device=/dev/video3 ! video x-raw, width-1920, height=1080,
framerate=15/1 !  ...

This terminates in an appsink called jpegsink.

I am accessing the new sample like so:
g_signal_connect(G_OBJECT(jpegsink),"new-sample",G_CALLBACK(new_sample_jpeg),NULL);

In the new_sample_jpeg(...)  function I access the sample, segment, and
buffer like so:

GstSample* sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
GstSegment* currsegment = gst_sample_get_segment(sample);
GstBuffer* buffer = gst_sample_get_buffer(sample).
GstMapInfo map;
gst_buffer_map(buffer,&map,GST_MAP_READ);

unsigned char* img = new unsigned char[map.size]

My question is how do I get the size of the image in width and height from
the GstSample. The size property of map given is the length of the array
data but not the actual image size. When I saved the image data to file,
the size of the image is showing 1920 x 1088 even though in the pipeline it
is specified at 1920 x 1080.



-- 
Sincerely,

Dwight Kulkarni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220926/f6f8ad2f/attachment.htm>


More information about the gstreamer-devel mailing list