Skip to content

Commit da153e7

Browse files
committed
Fixed high resolution video messages not being converted to video notes
Did this by adding a workaround, where video files are downscaled to a maximum resolution of 638 x 638, where the 638 value was found by downloading some random video notes, and noticing that none had a width or height bigger than 638.
1 parent b746b98 commit da153e7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/constants.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
EPOCH_DATE = datetime.datetime(1970, 1, 1)
1414

1515
MAX_VIDEO_NOTE_LENGTH = 60
16+
MAX_VIDEO_NOTE_SIZE = 638
1617

1718
AUDIO_CODEC_NAMES = ['aac', 'mp3']
1819

1920
VIDEO_CODEC_NAMES = ['h264', 'hevc', 'mpeg4', 'vp6', 'vp8']
20-
VIDEO_NOTE_CROP_OFFSET_PARAMS = 'abs(in_w - in_h) / 2'
21-
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)
2224

2325

2426
class OutputType:

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)