mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-21 15:53:21 +01:00
Disable encoding and show only original file (#829)
Disable encoding and show only original file #829
This commit is contained in:
parent
15d217453b
commit
e8d3ff25be
@ -59,7 +59,7 @@ def login():
|
||||
file.writelines(f'USERNAME={json.loads(response.text)["username"]}\n')
|
||||
print(f"Welcome to MediaCMS [bold blue]{username}[/bold blue]. Your auth creds have been suceesfully stored in the .env file", ":v:")
|
||||
else:
|
||||
print(f'Error: {"non_field_errors":["User not found."]}')
|
||||
print(f'Error: {"non_field_errors": ["User not found."]}')
|
||||
|
||||
|
||||
@apis.command()
|
||||
|
@ -467,7 +467,7 @@ except ImportError:
|
||||
|
||||
if "http" not in FRONTEND_HOST:
|
||||
# FRONTEND_HOST needs a http:// preffix
|
||||
FRONTEND_HOST = f"http://{FRONTEND_HOST}"
|
||||
FRONTEND_HOST = f"http://{FRONTEND_HOST}" # noqa
|
||||
|
||||
if LOCAL_INSTALL:
|
||||
SSL_FRONTEND_HOST = FRONTEND_HOST.replace("http", "https")
|
||||
@ -486,4 +486,7 @@ if GLOBAL_LOGIN_REQUIRED:
|
||||
r'/api/v[0-9]+/',
|
||||
]
|
||||
|
||||
# if True, only show original, don't perform any action on videos
|
||||
DO_NOT_TRANSCODE_VIDEO = False
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
@ -18,7 +18,7 @@
|
||||
- [15. Debugging email issues](#15-debugging-email-issues)
|
||||
- [16. Frequently Asked Questions](#16-frequently-asked-questions)
|
||||
- [17. Cookie consent code](#17-cookie-consent-code)
|
||||
|
||||
- [18. Disable encoding and show only original file](#18-disable-encoding-and-show-only-original-file)
|
||||
|
||||
## 1. Welcome
|
||||
This page is created for MediaCMS administrators that are responsible for setting up the software, maintaining it and making modifications.
|
||||
@ -762,3 +762,12 @@ this will re-create the sprites for videos that the task failed.
|
||||
On file `templates/components/header.html` you can find a simple cookie consent code. It is commented, so you have to remove the `{% comment %}` and `{% endcomment %}` lines in order to enable it. Or you can replace that part with your own code that handles cookie consent banners.
|
||||
|
||||
![Simple Cookie Consent](images/cookie_consent.png)
|
||||
|
||||
## 18. Disable encoding and show only original file
|
||||
When videos are uploaded, they are getting encoded to multiple resolutions, a procedure called transcoding. Sometimes this is not needed and you only need to show the original file, eg when MediaCMS is running on a low capabilities server. To achieve this, edit settings.py and set
|
||||
|
||||
```
|
||||
DO_NOT_TRANSCODE_VIDEO = True
|
||||
```
|
||||
|
||||
This will disable the transcoding process and only the original file will be shown. Note that this will also disable the sprites file creation, so you will not have the preview thumbnails on the video player.
|
@ -538,8 +538,8 @@ def get_base_ffmpeg_command(
|
||||
|
||||
target_width = round(target_height * 16 / 9)
|
||||
scale_filter_opts = [
|
||||
f"if(lt(iw\\,ih)\\,{target_height}\\,{target_width})",
|
||||
f"if(lt(iw\\,ih)\\,{target_width}\\,{target_height})",
|
||||
f"if(lt(iw\\,ih)\\,{target_height}\\,{target_width})", # noqa
|
||||
f"if(lt(iw\\,ih)\\,{target_width}\\,{target_height})", # noqa
|
||||
"force_original_aspect_ratio=decrease",
|
||||
"force_divisible_by=2",
|
||||
"flags=lanczos",
|
||||
|
@ -430,8 +430,13 @@ class Media(models.Model):
|
||||
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"
|
||||
self.save()
|
||||
self.produce_sprite_from_video()
|
||||
else:
|
||||
self.produce_sprite_from_video()
|
||||
self.encode()
|
||||
elif self.media_type == "image":
|
||||
self.set_thumbnail(force=True)
|
||||
return True
|
||||
@ -667,6 +672,13 @@ class Media(models.Model):
|
||||
return ret
|
||||
for key in ENCODE_RESOLUTIONS_KEYS:
|
||||
ret[key] = {}
|
||||
|
||||
# if this is enabled, return original file on a way
|
||||
# that video.js can consume
|
||||
if settings.DO_NOT_TRANSCODE_VIDEO:
|
||||
ret['0-original'] = {"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
|
||||
|
Loading…
Reference in New Issue
Block a user