From 9ed74d4028de9e351d03fc737ce088747460dfca Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Thu, 2 Sep 2021 19:59:00 +0300 Subject: [PATCH] allow not transcoding of video files --- cms/settings.py | 3 +++ files/models.py | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cms/settings.py b/cms/settings.py index e0c0b5220..1c69706d8 100644 --- a/cms/settings.py +++ b/cms/settings.py @@ -479,3 +479,6 @@ r'/accounts/logout/$', r'/accounts/signup/$', ] + +# if True, only show original, don't perform any action on videos +DO_NOT_TRANSCODE_VIDEO = False diff --git a/files/models.py b/files/models.py index 3339d4d4e..1992da7f9 100644 --- a/files/models.py +++ b/files/models.py @@ -431,8 +431,14 @@ def media_init(self): self.set_media_type() if self.media_type == "video": self.set_thumbnail(force=True) - self.produce_sprite_from_video() - self.encode() + if settings.DO_NOT_TRANSCODE_VIDEO: + self.encoding_status = "success" + if self.state == "public" and self.encoding_status == "success" and self.is_reviewed is True: + self.listable = True + self.save(update_fields=['encoding_status', 'listable']) + else: + self.produce_sprite_from_video() + self.encode() elif self.media_type == "image": self.set_thumbnail(force=True) return True @@ -661,6 +667,11 @@ def encodings_info(self, full=False): return ret for key in ENCODE_RESOLUTIONS_KEYS: ret[key] = {} + + if settings.DO_NOT_TRANSCODE_VIDEO: + ret['720'] = {"h264": {"url": helpers.url_from_path(self.media_file.path), "status": "success", "progress": 100}} + return ret + for encoding in self.encodings.select_related("profile").filter(chunk=False): if encoding.profile.extension == "gif": continue