Gstreamer crop and maintain aspect ratio

Hi all,

I’m facing some issue where nvvidconv crop would try and force the crop image to maintain the same size of the image, causing it to stretch the image. Is there any way to crop and maintain the aspect ratio of the crop image?

Below is my pipeline (bold text is the crop part):

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! ‘image/jpeg,width=2560,height=960,framerate=60/1’ ! videorate ! ‘image/jpeg,framerate=8/1’ ! nvjpegdec ! ‘video/x-raw’ ! nvvidconv ! ‘video/x-raw(memory:NVMM)’ ! tee name=t ! queue ! nvvidconv ! ‘video/x-raw,width=1280,height=480,format=BGRx’ ! appsink t. ! queue ! nvvidconv top=0 bottom=960 left=0 right=1280 ! ‘video/x-raw(memory:NVMM),width=1280,height=960’ ! nvv4l2h264enc maxperf-enable=1 ! h264parse ! mp4mux ! filesink location=test_final.mp4 -e

Any help would be appreciated. Thanks!

Hi,
We tried with Logitech C615 and the output looks expected. The command is:

$ gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! 'image/jpeg,width=1920,height=1080,framerate=30/1' ! videorate ! 'image/jpeg,framerate=8/1' ! nvjpegdec ! 'video/x-raw' ! nvvidconv ! 'video/x-raw(memory:NVMM),width=1920,height=1080' ! nvvidconv top=0 bottom=540 left=0 right=960 ! 'video/x-raw(memory:NVMM),width=960,height=540' ! nvoverlaysink sync=false

For your case, you may try

v4l2src device=/dev/video0 io-mode=2 ! 'image/jpeg,width=2560,height=960,framerate=60/1' ! videorate ! 'image/jpeg,framerate=8/1' ! nvjpegdec ! 'video/x-raw' ! nvvidconv ! 'video/x-raw(memory:NVMM),width=2560,height=960' ! ...

Yeah it was my bad, everything was working correctly. For some reason VLC change the display aspect ratio causing it to look stretched.

Thanks!