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

Conversation

KyleMaas
Copy link
Contributor

Description

I was running into issues where, while transcoding, a single server would get a load average of over 4x the number of cores it had. This turned out to be a combination of Celery running as many tasks concurrently as it could and each ffmpeg process using all cores. This would result in a ton of chunks' transcoding processes competing for CPU, which would cause them to time out. This change allows you to at least limit the number of threads that ffmpeg can use concurrently so you can actually tune transcoding CPU usage properly.

Steps

Pre-deploy

Post-deploy

@tobocop2
Copy link

I noticed this as well, I think this should be merged in as well @mgogoulos

@tobocop2
Copy link

tobocop2 commented Sep 29, 2023

@KyleMaas i think this threads setting should also be applied to the

produce_sprite_from_video and produce_thumbnails_from_video functions.

and this block

    if profile.extension == "gif":
        tf = create_temp_file(suffix=".gif")
        # -ss 5 start from 5 second. -t 25 until 25 sec
        command = [
            settings.FFMPEG_COMMAND,
            "-y",
            "-ss",
            "3",
            "-i",
            media.media_file.path,
            "-hide_banner",
            "-vf",
            "scale=344:-1:flags=lanczos,fps=1",
            "-t",
            "25",
            "-f",
            "gif",
            tf,
        ]

in tasks.py

These commands are vulnerable to the same problem.

@KyleMaas
Copy link
Contributor Author

@tobocop2 Good idea. Implemented.

@dogweather
Copy link

Ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants