![]() ![]() You can achieve this with the force_original_aspect_ratio option. when consolidating material from different sources. Sometimes you need to scale the input image so that it fits into a specified rectangle, e.g. If you have an imput image that is only 240 pixels wide, the result of the min function will be 240 – this will be your target value.įitting into a Rectangle / Statically-sized Player The output width will be evaluated to be the minimum of 320 and the input width. This can be done using min expressions:įfmpeg -i input.jpg -vf "scale='min(320,iw)':'min(240,ih)'" input_not_upscaled.png Sometimes you want to scale an image, but avoid upscaling it if its dimensions are too low. 5 or divide by 2:įfmpeg -i input.jpg -vf "scale=iw*.5:ih*.5" input_half_size.pngįfmpeg -i input.jpg -vf "scale=iw/2:ih/2" input_half_size.pngĪlternatively, you can scale only one component and keep the aspect ratio by setting the other component to -1:įfmpeg -i input.jpg -vf "scale=iw*.5:-1" input_half_size.png If you want to half the size of the picture, just multiply by. There are also some useful variables which can be used instead of numbers, to specify width and height of the output image.įor example, if you want to stretch the image in such a way to only double the width of the input image, you can use something like this ( iw = input width, ih = input height):įfmpeg -i input.jpg -vf "scale=iw*2:ih" input_double_width.png You can achieve this by setting the width or height to -n:įfmpeg -i input.jpg -vf scale=320:-2 output_320.png Some codecs require the size of width and height to be a multiple of n. The resulting image will have a dimension of 320×207 pixels. Will set the width of the output image to 320 pixels and will calculate the height of the output image according to the aspect ratio of the input image. ![]() For example, this command line:įfmpeg -i input.jpg -vf scale=320:-1 output_320.png If we'd like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. If you need to simply resize your video to a specific size (e.g 320×240), you can use the scale filter in its most basic form:įfmpeg -i input.avi -vf scale=320:240 output.aviįfmpeg -i input.jpg -vf scale=320:240 output_320x240.pngĪs you can see, the aspect ratio is not the same as in the original image, so the image appears stretched. In all the examples, the starting image (input.jpg) will be this one (535×346 pixels):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |