Skip to content

Expose thread_type and nb_threads in filter graph#2211

Open
lgeiger wants to merge 1 commit intoPyAV-Org:mainfrom
lgeiger:filtergraph-threading
Open

Expose thread_type and nb_threads in filter graph#2211
lgeiger wants to merge 1 commit intoPyAV-Org:mainfrom
lgeiger:filtergraph-threading

Conversation

@lgeiger
Copy link
Copy Markdown
Contributor

@lgeiger lgeiger commented Mar 23, 2026

This PR exposes AVFilterGraph.nb_threads and AVFilterGraph.thread_type similar to what's currently done in the codec context.

@WyattBlue
Copy link
Copy Markdown
Member

TheadType is too low level to be worth exposing. nb_threads should just be threads in Python land. nb is not a well known convention there.

@lgeiger
Copy link
Copy Markdown
Contributor Author

lgeiger commented Apr 2, 2026

Makes sense, I'll remove thread type, given that it only has one option at the moment anyway.

nb_threads should just be threads in Python land. nb is not a well known convention there.

Agreed, the nb prefix is not nice. I just named it like this to align with ffmpeg.
How do you feel about using thread_count similar to what's done in the codec context or do you think that's confusing and you prefer to stick with threads because there's no exact match of thread_count in AVFilterGraph?

PyAV/av/codec/context.py

Lines 629 to 642 in 37a6ece

@property
def thread_count(self):
"""How many threads to use; 0 means auto.
Wraps :ffmpeg:`AVCodecContext.thread_count`.
"""
return self.ptr.thread_count
@thread_count.setter
def thread_count(self, value: cython.int):
if self.is_open:
raise RuntimeError("Cannot change thread_count after codec is open.")
self.ptr.thread_count = value

@WyattBlue
Copy link
Copy Markdown
Member

I prefer threads because thread_count is not a C field.

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