Cropping incoming video using imxv4l2sink

I am trying to crop incoming video using imxv4l2sink plugin.
I don’t think the cropping with imxv4l2sink is working.
I am using Linux Image 2.7(toradex_4.1-2.0.x-imx).
When I run “gst-launch-1.0 --gst-debug=“imxv4l2sink:6” v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! vpudec ! imxv4l2sink sync=f
alse crop-left=128”, I got these debug messages.

root@apalis-imx6:/usr/lib/gstreamer-1.0# gst-launch-1.0 --gst-debug="imxv4l2sink:6" v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! vpudec
 ! imxv4l2sink sync=false crop-left=128                                                                                                                                     
[ 4014.034308] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.040615] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.046857] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.097354] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.103297] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.109750] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE

(gst-plugin-scanner:713): GLib-GObject-WARNING **: cannot register existing type 'GstImxV4l2Sink'

(gst-plugin-scanner:713): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(gst-plugin-scanner:713): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

(gst-plugin-scanner:713): GStreamer-CRITICAL **: gst_element_register: assertion 'g_type_is_a (type, GST_TYPE_ELEMENT)' failed
[ 4014.313476] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.319807] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[ 4014.326037] ERROR: v4l2 capture: slave not found! V4L2_CID_HUE
[INFO]  Product Info: i.MX6Q/D/S
====== IMXV4L2SINK: 4.1.4 build on Sep  5 2018 16:48:42. ======
0:00:00.577809925   712   0xcf8500 DEBUG            imxv4l2sink gstimxv4l2sink.c:108:gst_imx_v4l2sink_set_property: set_property (7).
Setting pipeline to PAUSED ...
0:00:00.588466530   712   0xcf8500 DEBUG            imxv4l2sink gstimxv4l2sink.c:239:gst_imx_v4l2sink_change_state: 1 -> 2
display(/dev/fb0) resolution is (1024x768).
0:00:00.594144653   712   0xcf8500 DEBUG            imxv4l2sink gstimxv4l2sink.c:239:gst_imx_v4l2sink_change_state: 2 -> 3
[INFO]  Product Info: i.MX6Q/D/S
====== VPUDEC: 4.1.4 build on Oct  4 2017 23:03:36. ======
        wrapper: 1.0.68 (VPUWRAPPER_ARM_LINUX Build on Oct  4 2017 22:43:46)
        vpulib: 5.4.35
        firmware: 3.1.1.46072
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[INFO]  bitstreamMode 1, chromaInterleave 1, mapType 0, tiled2LinearEnable 0
0:00:01.817682990   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:520:gst_imx_v4l2sink_set_caps: set caps video/x-raw, format=(string)NV12, wid
th=(int)1920, height=(int)1088, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)2:4:7:1, framerate=(fra
ction)30/1
0:00:01.818620955   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:462:gst_imx_v4l2sink_setup_buffer_pool: create buffer pool(0x75713180).
0:00:01.819120937   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:612:gst_imx_v4l2sink_propose_allocation: propose_allocation, pool(0x75713180)
.
0:00:02.149670691   712 0x75702550 DEBUG            imxv4l2sink gstimxv4l2sink.c:239:gst_imx_v4l2sink_change_state: 3 -> 4
0:00:02.149951014   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:689:gst_imx_v4l2sink_show_frame: not v4l2 allocated buffer.
0:00:02.150019345   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:736:gst_imx_v4l2sink_show_frame: physical memory meta x_padding: 0 y_padding:
 0
0:00:02.150321334   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:397:gst_imx_v4l2_allocator_cb: pool has alignment (0, 0) , (0, 0)
0:00:02.150392664   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:401:gst_imx_v4l2_allocator_cb: need allocate 3 buffers.

v4l2sink need allocate 3 buffers.
0:00:02.150547325   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:370:gst_imx_v4l2sink_configure_input: crop: (0,0) -> (1920, 1088)
0:00:02.150608656   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:372:gst_imx_v4l2sink_configure_input: cropmeta: (0,0) -> (1920, 1088)
0:00:02.150662321   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:375:gst_imx_v4l2sink_configure_input: padding: (0,0), (0, 0)
0:00:02.150831981   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:780:gst_imx_v4l2sink_show_frame: not v4l2 allocated buffer. put physical addr
ess
0:00:02.150893646   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:370:gst_imx_v4l2sink_configure_input: crop: (0,0) -> (1920, 1088)
0:00:02.150953644   712   0xd2fac0 DEBUG            imxv4l2sink gstimxv4l2sink.c:372:gst_imx_v4l2sink_configure_input: cropmeta: (0,0) -> (1920, 1080)

As you can see, crop-left is 0.
Is there a bug on imxv4l2sink plugin regarding cropping?
Thank you.

hi @Yoontaek

What device/input are you using to capture the video? What is your application?

Could you use the provide the output of this command: uname -r?
Are you using a regular Bsp or did you change anything?

Thanks and best regards,
Jaski

I am using usb camera for capturing.
I am using a gstreamer.
And I didn’t change anything for bsp.
The result of uname -r is “4.1.44-2.7.4+gb1555bf”.
Thank you.

Thanks for this Information. Perfect that it works.

I am sorry to bother.
The cropping doesn’t work when I run “gst-launch-1.0 --gst-debug=“imxv4l2sink:6” v4l2src device=/dev/video1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! vpudec
! imxv4l2sink sync=false crop-left=128” in the command line.
But in my application, if I set the pipeline state to GST_STATE_READY before I set the property of crop, then it works.

ret = gst_element_set_state(pipeline, GST_STATE_READY); /* added for cropping */
g_object_set(G_OBJECT(sink),“crop-left”,384,“crop-top”,216,“crop-height”,648,“crop-width”,1152,NULL);
ret = gst_element_set_state(pipeline, GST_STATE_PLAYING);