I am writing a gstreamer plugin that modifies the buffer in place. I use GST_VIDEO_FRAME_WIDTH(frame) and GST_VIDEO_FRAME_HEIGHT(frame) to get the width and height of the buffer. However, this does not reflect what actaully appears on the screen.
example pipe with cropping:
xinit /usr/local/usr/bin/gst-launch-1.0 videotestsrc ! videoconvert ! video/x-raw,format=BGRx,width=500,height=500 ! videocrop top=100 left=0 bottom=0 right=100 ! myplugin ! latencydetect debug=1 ! vaapisink sync=false
The output will be 400x400, however the plugin will still see a buffer of 500x500.
How can I find the width, height, xoffset and yoffset so that I can correctly locate pixels in the buffer?
I have tried inspecting the caps, which does provide the correct width and height, but does not include the offsets.
videocrop
most likely does not change the buffer, but adds cropping meta data to it.
See https://gstreamer.freedesktop.org/documentation/video/gstvideometa.html?gi-language=c#GstVideoCropMeta for the meta data structure.
Use https://gstreamer.freedesktop.org/documentation/video/gstvideometa.html#gst_buffer_get_video_crop_meta to get this meta data from a buffer.