fakesink captured image size
nirbheek.chauhan at gmail.com
Wed Dec 14 17:59:33 UTC 2022
On Wed, Dec 14, 2022 at 9:43 PM Scot Zarkiewicz <scotzark at gmail.com> wrote:
> caps = gst_caps_new_simple ("image/bmp",
> "pixel-aspect-ratio", GST_TYPE_FRACTION, 4, 3,
> "width", G_TYPE_INT, 1440,
> "height", G_TYPE_INT, 1080,
> to_sample = gst_video_convert_sample (from_sample, caps, GST_CLOCK_TIME_NONE, &err);
> I have verified the width and height are 1920 x 1080 as they are set in the camera, so I am asking gst_video_convert_sample to crop it to 1440 x 1080
That is not what that code does. You are telling it to convert from
1920x1080 with PAR 1 to 1440x1080 with PAR 4/3, which yields the same
image but with a different aspect ratio for each pixel (instead of
Are you sure you intended to do that?
Did you perhaps change PAR because without it the pipeline failed with
a not-negotiated error?
gst_video_convert_sample() cannot crop to a specified width / height.
Even if it could, you aren't providing it enough information: do you
want to crop from both left and right, or only from the left, only
from the right? Etc.
> But when I render this frame in Android it is 1024x768:
I would suspect that Android's BMP decoder is getting confused by the PAR.
You can do something simpler here:
decodebin ! videocrop left=120 right=120 ! fakesink name=sink
Then continue to use gst_video_convert_sample() as per usual.
You may also consider using appsink instead of fakesink, since that is
built for this purpose. You'd connect to the "new-sample" property
with a callback, and inside that callback you'd call:
g_signal_emit_by_name (appsink, "pull-sample", &sample);
Then process it from another thread (so you're not blocking the
streaming thread with your processing).
More information about the gstreamer-devel