Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration to set how many threads each ffmpeg process can use #886

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@

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
Expand Down
2 changes: 2 additions & 0 deletions files/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ def get_base_ffmpeg_command(

base_cmd = [
settings.FFMPEG_COMMAND,
"-threads",
str(settings.FFMPEG_THREADS),
"-y",
"-i",
input_file,
Expand Down
2 changes: 2 additions & 0 deletions files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions files/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -233,6 +235,8 @@ def encode_media(
# -ss 5 start from 5 second. -t 25 until 25 sec
command = [
settings.FFMPEG_COMMAND,
"-threads",
str(settings.FFMPEG_THREADS),
"-y",
"-ss",
"3",
Expand Down
Loading