diff --git a/src/constants.py b/src/constants.py index 054ddf3..ecb4237 100644 --- a/src/constants.py +++ b/src/constants.py @@ -12,14 +12,15 @@ EPOCH_DATE = datetime.datetime(1970, 1, 1) -MAX_PHOTO_FILESIZE_UPLOAD = int(10E6) # (50 MB) MAX_VIDEO_NOTE_LENGTH = 60 +MAX_VIDEO_NOTE_SIZE = 638 AUDIO_CODEC_NAMES = ['aac', 'mp3'] 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_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) class OutputType: diff --git a/src/main.py b/src/main.py index de85119..5916fd7 100755 --- a/src/main.py +++ b/src/main.py @@ -406,7 +406,7 @@ def message_file_handler(update: telegram.Update, context: telegram.ext.Callback return elif output_type == constants.OutputType.PHOTO: - if not utils.ensure_size_under_limit(output_file_size, constants.MAX_PHOTO_FILESIZE_UPLOAD, update, context, file_reference_text='Converted file'): + if not utils.ensure_size_under_limit(output_file_size, telegram.constants.MAX_PHOTOSIZE_UPLOAD, update, context, file_reference_text='Converted file'): return bot.send_photo( diff --git a/src/utils.py b/src/utils.py index 0f72ca7..4739102 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_OFFSET_PARAMS, - constants.VIDEO_NOTE_CROP_OFFSET_PARAMS, + constants.VIDEO_NOTE_CROP_HORIZONTAL_OFFSET_PARAMS, + constants.VIDEO_NOTE_CROP_VERTICAL_OFFSET_PARAMS, constants.VIDEO_NOTE_CROP_SIZE_PARAMS, constants.VIDEO_NOTE_CROP_SIZE_PARAMS )