c_lfill analog for video transformation
Can i get the same result as using c_lfill but for video file instead of image? I want to prevent video file requests larger than the source.
-
Hi Aleksey,
lfill isn't currently supported for videos
If you need a specific sized output for a video that may be smaller than the dimensions you're requesting, the best method at the moment is to set the width and height based on the width and height of the original video. If you don't have this stored locally already, it will be in the response of the upload() API or the 'get resources' method of our Admin API
If you don't need exact dimensions for the output, but only that it's no bigger than the specified height or width, you can use the 'limit' mode, which will keep the video's original aspect ratio while ensuring that it's within the specified width and height
Regards,
Stephen
0 -
Is it possible to get the desired result using conditional transformation?
0 -
Hi Aleksey,
Yes, actually: That's a good idea and one of my colleagues mentioned it to me when I asked about 'lfill' support for videos.
A conditional transformation like this will work similarly to 'lfill' and will give you 500x500 for larger videos, and a maximum of 500x500 if the video is smaller:
For example, this original video is 854 x 480, and the transformation is 500x480:When I checked if we can add 'lfill' support directly in video URLs, the answer was that we should be able to support it, and most likely will add this support, but I don't know how long it will take, so if you need this soon, the conditional workaround (either directly or as a named transformation) is the best solution
Thanks,
Stephen0 -
Can i get if_$w_gt_w is true, then set width to w and height to (w*requested aspect ratio)?
For example if my source 500x500, i request 1000x500, and get 500x250.
0 -
Sure, you can do `h_h_mul_ar`
However, you probably want to divide by the aspect ration `h_h_div_ar`
Please let me know if that works,
0 -
thank you all for your help, this final solution seems to do the same as c_lfill: https://res.cloudinary.com/demo/video/upload/$w_500,$h_500,$ar_$w_div_$h/if_$w_gt_w,$w_w,$h_w_div_$ar/if_$h_gt_h,$h_h,$w_h_mul_$ar/c_fill,w_$w,h_$h/dog.mp4
0 -
Hi Aleksey,
Depending on what exactly you need, you may be able to just use c_limit without any conditional logic because c_limit that preserves the original aspect ratio.
The basic behavior of the three standard options mentioned here is:
c_limit: scales the image down so that it fits within the width and height specified with no cropping or stretching; It won't make any changes if the original image dimensions are both smaller than what you specify in the transformation
c_fill: produce an image that's exactly the specified width and height, upscaling or downscaling if needed, and cropping some fo the original if the aspect ratio doesn't match
c_lfill: Works like c_fill but won't upscale: it may still crop if the image is smaller than the specified dimensions but the aspect ratio doesn't match (e.g. "c_lfill w_500, h_500" on an image that is w:400, h:550 image will give you w_400,h_500 outputIf the conditional option above is what you need, that's good, but it's not so different to c_limit, so that may be a simpler option which also won't have any cropping
Thanks,
Stephen
0
Post is closed for comments.
Comments
7 comments