From 3e7b1064821e621b9aa28856abc8e3929704c03d Mon Sep 17 00:00:00 2001 From: DecaTec Date: Wed, 1 Jun 2022 12:42:35 +0200 Subject: [PATCH] Vp9 fixes (#438) * Fix fo ffprobe appending pipe * Fix media remains pending when only encoding to webm --- files/helpers.py | 3 ++- files/models.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/files/helpers.py b/files/helpers.py index 1926f28..5726df2 100644 --- a/files/helpers.py +++ b/files/helpers.py @@ -443,7 +443,8 @@ def media_file_info(input_file): input_file, ] stdout = run_command(cmd).get("out") - stream_size = sum([int(line) for line in stdout.split("\n") if line != ""]) + # ffprobe appends a pipe at the end of the output, thus we have to remove it + stream_size = sum([int(line.replace("|", "")) for line in stdout.split("\n") if line != ""]) audio_bitrate = round((stream_size * 8 / 1024.0) / audio_duration, 2) ret.update( diff --git a/files/models.py b/files/models.py index d6a4174..b2d8ce1 100644 --- a/files/models.py +++ b/files/models.py @@ -637,15 +637,16 @@ class Media(models.Model): def set_encoding_status(self): """Set encoding_status for videos - Set success if at least one mp4 exists + Set success if at least one mp4 or webm exists """ mp4_statuses = set(encoding.status for encoding in self.encodings.filter(profile__extension="mp4", chunk=False)) + webm_statuses = set(encoding.status for encoding in self.encodings.filter(profile__extension="webm", chunk=False)) - if not mp4_statuses: + if not mp4_statuses and not webm_statuses: encoding_status = "pending" - elif "success" in mp4_statuses: + elif "success" in mp4_statuses or "success" in webm_statuses: encoding_status = "success" - elif "running" in mp4_statuses: + elif "running" in mp4_statuses or "running" in webm_statuses: encoding_status = "running" else: encoding_status = "fail"