From 9772abacb9fd5dc7d0aa1149781b0a065c44fac8 Mon Sep 17 00:00:00 2001 From: Iulian Onofrei Date: Mon, 20 Dec 2021 23:29:22 +0000 Subject: [PATCH 1/2] Partially reverted "Fixed high resolution video messages not being converted to video notes" Partially reverted from commit da153e7e. --- src/constants.py | 5 ++--- src/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/constants.py b/src/constants.py index ecb4237..8dfd9fa 100644 --- a/src/constants.py +++ b/src/constants.py @@ -18,9 +18,8 @@ AUDIO_CODEC_NAMES = ['aac', 'mp3'] VIDEO_CODEC_NAMES = ['h264', 'hevc', 'mpeg4', 'vp6', 'vp8'] -VIDEO_NOTE_CROP_HORIZONTAL_OFFSET_PARAMS = 'abs(in_w - min(min(in_w, in_h), {})) / 2'.format(MAX_VIDEO_NOTE_SIZE) -VIDEO_NOTE_CROP_VERTICAL_OFFSET_PARAMS = 'abs(in_h - min(min(in_w, in_h), {})) / 2'.format(MAX_VIDEO_NOTE_SIZE) -VIDEO_NOTE_CROP_SIZE_PARAMS = 'min(min(in_w, in_h), {})'.format(MAX_VIDEO_NOTE_SIZE) +VIDEO_NOTE_CROP_OFFSET_PARAMS = 'abs(in_w - in_h) / 2' +VIDEO_NOTE_CROP_SIZE_PARAMS = 'min(in_w, in_h)' class OutputType: diff --git a/src/utils.py b/src/utils.py index 4739102..0f72ca7 100644 --- a/src/utils.py +++ b/src/utils.py @@ -171,8 +171,8 @@ def convert(output_type: str, input_video_url: typing.Optional[str] = None, inpu ffmpeg_input .video .crop( - constants.VIDEO_NOTE_CROP_HORIZONTAL_OFFSET_PARAMS, - constants.VIDEO_NOTE_CROP_VERTICAL_OFFSET_PARAMS, + constants.VIDEO_NOTE_CROP_OFFSET_PARAMS, + constants.VIDEO_NOTE_CROP_OFFSET_PARAMS, constants.VIDEO_NOTE_CROP_SIZE_PARAMS, constants.VIDEO_NOTE_CROP_SIZE_PARAMS ) From a232b6c57079044b6d797c13c6c50d022619ddb9 Mon Sep 17 00:00:00 2001 From: Iulian Onofrei Date: Mon, 20 Dec 2021 23:32:59 +0000 Subject: [PATCH 2/2] Fixed video notes being cropped on the smallest of the dimensions too --- src/constants.py | 1 + src/utils.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/constants.py b/src/constants.py index 8dfd9fa..299f0c5 100644 --- a/src/constants.py +++ b/src/constants.py @@ -20,6 +20,7 @@ VIDEO_CODEC_NAMES = ['h264', 'hevc', 'mpeg4', 'vp6', 'vp8'] VIDEO_NOTE_CROP_OFFSET_PARAMS = 'abs(in_w - in_h) / 2' VIDEO_NOTE_CROP_SIZE_PARAMS = 'min(in_w, in_h)' +VIDEO_NOTE_SCALE_SIZE_PARAMS = 'min(min(in_w, in_h), {})'.format(MAX_VIDEO_NOTE_SIZE) class OutputType: diff --git a/src/utils.py b/src/utils.py index 0f72ca7..a1c2d32 100644 --- a/src/utils.py +++ b/src/utils.py @@ -176,6 +176,11 @@ def convert(output_type: str, input_video_url: typing.Optional[str] = None, inpu constants.VIDEO_NOTE_CROP_SIZE_PARAMS, constants.VIDEO_NOTE_CROP_SIZE_PARAMS ) + .filter( + 'scale', + constants.VIDEO_NOTE_SCALE_SIZE_PARAMS, + constants.VIDEO_NOTE_SCALE_SIZE_PARAMS + ) ) ffmpeg_output: ffmpeg.nodes.OutputStream