Get Frame Size from GstSample in new-sample callback
Michiel Konstapel
michiel at aanmelder.nl
Wed Sep 28 07:45:34 UTC 2022
You can get the caps from the sample, which have the width and height.
Python example:
caps = sample.get_caps()
width = caps.get_structure(0).get_value("width")
height = caps.get_structure(0).get_value("height")
Just a guess: the 1088 pixel height might be because it comes from a
source that only deals with 16x16 pixel blocks?
https://stackoverflow.com/questions/9259044/h264-stream-incorrect-height-8-pixels-taller
Cheers,
Michiel
On 26-09-2022 18:16, Dwight Kulkarni via gstreamer-devel wrote:
> 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/20220928/c56f50c8/attachment-0001.htm>
More information about the gstreamer-devel
mailing list