diff --git a/src/constants.py b/src/constants.py index ecb4237..299f0c5 100644 --- a/src/constants.py +++ b/src/constants.py @@ -18,9 +18,9 @@ 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)' +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 4739102..a1c2d32 100644 --- a/src/utils.py +++ b/src/utils.py @@ -171,11 +171,16 @@ 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 ) + .filter( + 'scale', + constants.VIDEO_NOTE_SCALE_SIZE_PARAMS, + constants.VIDEO_NOTE_SCALE_SIZE_PARAMS + ) ) ffmpeg_output: ffmpeg.nodes.OutputStream