From ed13f53060631c5ca990e5d95030365be17e21a6 Mon Sep 17 00:00:00 2001 From: Kyle Maas Date: Wed, 20 Sep 2023 14:11:11 +0000 Subject: [PATCH] Add configuration to set how many threads each ffmpeg process can use --- cms/settings.py | 1 + files/helpers.py | 2 ++ files/models.py | 2 ++ files/tasks.py | 2 ++ 4 files changed, 7 insertions(+) diff --git a/cms/settings.py b/cms/settings.py index 7945215..21983c4 100644 --- a/cms/settings.py +++ b/cms/settings.py @@ -160,6 +160,7 @@ HLS_DIR = os.path.join(MEDIA_ROOT, "hls/") FFMPEG_COMMAND = "ffmpeg" # this is the path FFPROBE_COMMAND = "ffprobe" # this is the path +FFMPEG_THREADS = 0 # default - use optimal number of threads MP4HLS = "mp4hls" MASK_IPS_FOR_ACTIONS = True diff --git a/files/helpers.py b/files/helpers.py index 948c525..7706b0c 100644 --- a/files/helpers.py +++ b/files/helpers.py @@ -554,6 +554,8 @@ def get_base_ffmpeg_command( base_cmd = [ settings.FFMPEG_COMMAND, + "-threads", + str(settings.FFMPEG_THREADS), "-y", "-i", input_file, diff --git a/files/models.py b/files/models.py index 1d539cc..f6785e9 100644 --- a/files/models.py +++ b/files/models.py @@ -1482,6 +1482,8 @@ def encoding_file_save(sender, instance, created, **kwargs): ff.write("file {}\n".format(f)) cmd = [ settings.FFMPEG_COMMAND, + "-threads", + str(settings.FFMPEG_THREADS), "-y", "-f", "concat", diff --git a/files/tasks.py b/files/tasks.py index aee5b67..c3ce802 100644 --- a/files/tasks.py +++ b/files/tasks.py @@ -62,6 +62,8 @@ def chunkize_media(self, friendly_token, profiles, force=True): chunks_file_name += ".mkv" cmd = [ settings.FFMPEG_COMMAND, + "-threads", + str(settings.FFMPEG_THREADS), "-y", "-i", media.media_file.path,