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

Avoid providing a warning if the requested number of threads is the current number of threads #3618

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

hmaarrfk
Copy link
Contributor

@hmaarrfk hmaarrfk commented Feb 8, 2023

It seems that this thread number parameter is always defined.

When starting multiple contexts, it is seem hard to not specify this.

Therefore, you end up with many warnings.

Thank you for considering

current number of threads

It seems that this thread number parameter is always defined.

When starting multiple contexts, it is seem hard to not specify this.

Therefore, you end up with many warnings.

Thank you for considering
@hmaarrfk hmaarrfk force-pushed the do_not_warn_on_equal_thread_count branch from c56484b to 5bbb388 Compare February 8, 2023 16:56
@huili2
Copy link
Collaborator

huili2 commented Feb 28, 2023

@hmaarrfk This thread initialization should be done only once, and from the code, it seems OK if the return code is NULL (meaning thread pool initialization failed). So In what case would this happen?

@hmaarrfk
Copy link
Contributor Author

I can see a few reasons:

  1. In live applications (i.e. where you can't spawn a new process and start a totally new global context), you may want to tune the number of threads as the desired resolution changes. This can be when a user is changing the resolution of the output video due to encoding a totally different stream, or when changing the resolution of the broadcasting resolution in a streaming sense.
  2. In applications where you are writing multiple videos to disk, you may also want to tune the number of threads to a particular need. Do you have many other steps in your pipeline happening in parallel? Choose "1" thread? If you have fewer expected background processing, you can increase this to "4".

I think FFMPEG will always set this:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libopenh264enc.c#L176

So even if you serially encode, multiple different 1080 p streams in a single application (using libavcodec directly in your program instead of the ffmpeg executable), you will start to see this popup many times.

@hmaarrfk
Copy link
Contributor Author

I was somewhat surprised that the threadpool is global to all different encoding contexts, instead of being local to each encoding context.

I would like for example, to start 5 encoding contexts, and limit each to 2 threads. I couldn't find a good way to do this.

@huili2 huili2 merged commit 6967c09 into cisco:master Apr 20, 2023
@hmaarrfk
Copy link
Contributor Author

Thank you@!

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.

2 participants