Scaling a video on command line

If you have a video that's in 1280×720 (i.e. 1280 pixels wide, and 720 pixels tall), you can scale this down a bit using gstreamer. You can convert that to any size you want.

Here is a sample gst-launch command pipeline (the basics are covered in playing video on command line):

gst-launch filesrc ! decodebin ! videoscale ! video/x-raw-yuv,width=640,height=340 ! autovideosin

The basics are the same, filesrc and decodebin to read & decode the video and autovideosink to play it on your screen.


The videoscale element does the actual scaling. It takes in a video stream and will scale things down to match what further down the pipeline thinks it should be.


The video/x-raw-yuv,width=640,height=340 is the part that 'filters' the incoming video stream and the output of that element is a video stream that's that width and height. Make sure you don't have any spaces between the commas (,'s) and the width/height.

To get proper scaling you'll need to specify both the width and height. If you only specify the width, then the height is left the same, so in the exampel above you would have a width of 640 and height of 720. It'll have the same aspect ratio, but the horizontal pixels will be wider.

This entry is tagged: