Skip to content

Commit

Permalink
allow not transcoding of video files
Browse files Browse the repository at this point in the history
  • Loading branch information
Markos Gogoulos committed Sep 2, 2021
1 parent 2ce8dba commit 9ed74d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 13 additions & 2 deletions files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 9ed74d4

@foeyonghai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still works perfectly. Why this is still not in production?

Please sign in to comment.