diff --git a/lib/ffmpeg/filters/scale.rb b/lib/ffmpeg/filters/scale.rb index b61daa0..f6b4541 100644 --- a/lib/ffmpeg/filters/scale.rb +++ b/lib/ffmpeg/filters/scale.rb @@ -16,6 +16,9 @@ def scale(width: nil, height: nil, force_original_aspect_ratio: nil, flags: nil) # The Scale class uses the scale filter # to resize a multimedia stream. class Scale < Filter + NEAREST_DIMENSION = -1 + NEAREST_EVEN_DIMENSION = -2 + class << self # Returns a scale filter that fits the specified media # within the specified maximum width and height, @@ -44,11 +47,11 @@ def contained(media, max_width: nil, max_height: nil) return unless max_width || max_height if media.rotated? - width = max_height || -2 - height = max_width || -2 + width = max_height || NEAREST_EVEN_DIMENSION + height = max_width || NEAREST_EVEN_DIMENSION else - width = max_width || -2 - height = max_height || -2 + width = max_width || NEAREST_EVEN_DIMENSION + height = max_height || NEAREST_EVEN_DIMENSION end if width.negative? || height.negative?