Skip to content

Commit

Permalink
Merge pull request #54 from revolter/fix/video-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
revolter authored Dec 20, 2021
2 parents 71c8d82 + da153e7 commit b9606be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit b9606be

Please sign in to comment.