Skip to content

Commit b9606be

Browse files
authored
Merge pull request #54 from revolter/fix/video-notes
2 parents 71c8d82 + da153e7 commit b9606be

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/constants.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212

1313
EPOCH_DATE = datetime.datetime(1970, 1, 1)
1414

15-
MAX_PHOTO_FILESIZE_UPLOAD = int(10E6) # (50 MB)
1615
MAX_VIDEO_NOTE_LENGTH = 60
16+
MAX_VIDEO_NOTE_SIZE = 638
1717

1818
AUDIO_CODEC_NAMES = ['aac', 'mp3']
1919

2020
VIDEO_CODEC_NAMES = ['h264', 'hevc', 'mpeg4', 'vp6', 'vp8']
21-
VIDEO_NOTE_CROP_OFFSET_PARAMS = 'abs(in_w-in_h)/2'
22-
VIDEO_NOTE_CROP_SIZE_PARAMS = 'min(in_w,in_h)'
21+
VIDEO_NOTE_CROP_HORIZONTAL_OFFSET_PARAMS = 'abs(in_w - min(min(in_w, in_h), {})) / 2'.format(MAX_VIDEO_NOTE_SIZE)
22+
VIDEO_NOTE_CROP_VERTICAL_OFFSET_PARAMS = 'abs(in_h - min(min(in_w, in_h), {})) / 2'.format(MAX_VIDEO_NOTE_SIZE)
23+
VIDEO_NOTE_CROP_SIZE_PARAMS = 'min(min(in_w, in_h), {})'.format(MAX_VIDEO_NOTE_SIZE)
2324

2425

2526
class OutputType:

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def message_file_handler(update: telegram.Update, context: telegram.ext.Callback
406406

407407
return
408408
elif output_type == constants.OutputType.PHOTO:
409-
if not utils.ensure_size_under_limit(output_file_size, constants.MAX_PHOTO_FILESIZE_UPLOAD, update, context, file_reference_text='Converted file'):
409+
if not utils.ensure_size_under_limit(output_file_size, telegram.constants.MAX_PHOTOSIZE_UPLOAD, update, context, file_reference_text='Converted file'):
410410
return
411411

412412
bot.send_photo(

src/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def convert(output_type: str, input_video_url: typing.Optional[str] = None, inpu
171171
ffmpeg_input
172172
.video
173173
.crop(
174-
constants.VIDEO_NOTE_CROP_OFFSET_PARAMS,
175-
constants.VIDEO_NOTE_CROP_OFFSET_PARAMS,
174+
constants.VIDEO_NOTE_CROP_HORIZONTAL_OFFSET_PARAMS,
175+
constants.VIDEO_NOTE_CROP_VERTICAL_OFFSET_PARAMS,
176176
constants.VIDEO_NOTE_CROP_SIZE_PARAMS,
177177
constants.VIDEO_NOTE_CROP_SIZE_PARAMS
178178
)

0 commit comments

Comments
 (0)