Skip to content

Expose threads in filter graph#2211

Merged
WyattBlue merged 3 commits intoPyAV-Org:mainfrom
lgeiger:filtergraph-threading
Apr 7, 2026
Merged

Expose threads in filter graph#2211
WyattBlue merged 3 commits 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.

@lgeiger lgeiger force-pushed the filtergraph-threading branch from 52f11e8 to d4292d6 Compare April 7, 2026 09:58
@lgeiger
Copy link
Copy Markdown
Contributor Author

lgeiger commented Apr 7, 2026

TheadType is too low level to be worth exposing. nb_threads should just be threads in Python land.

Done in b268ae7 and d4292d6

@lgeiger lgeiger changed the title Expose thread_type and nb_threads in filter graph Expose threads in filter graph Apr 7, 2026
@WyattBlue WyattBlue merged commit bcc3cee into PyAV-Org:main Apr 7, 2026
8 checks passed
@lgeiger lgeiger deleted the filtergraph-threading branch April 7, 2026 15:40
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