Closed skeskinen closed 4 months ago
Excuse me about the linter stuff. I can't run make lint
locally because the flake8 always fails. I think it should work now. Both black and isort are happy
I think the PR is good as it is now.
One thing I changed was inlining def self._recv
and def self._send
to cpdef filter
. This eliminates the overhead in calling Python functions and IMO makes it easier to read. I also add type hints and docstrings.
I'll give you a chance to comment, then it can be merged.
Looks good to me. Thanks!
Loosely based on #565 Additional discussion in #489
This adds bindings for AVBSFContext (BitStreamFilterContext)
I decided against adding binding for AVBitStreamFilter, because it seems like a little bit useless API. You can't do anything with such object besides creating a new BSF context. (except checking which codecs are supported for that BSF, I guess) It makes the code simpler and imo easier to maintain. Let me know if this is a mistake and those bindings should be added as well.
I think it makes sense to force BitstreamFilterContext creation through the string parsing API, since that's the only way I can see how to set filter options and also allows things like filter chains, etc.
Adds tests for 'chomp', 'setts' and 'h264_mp4toannexb' filters. We could also test that filter chains work.
h264_mp4toannexb requires that AVCodecParameters *par_in is set correctly. To that end BitStreamFilterContext takes a Stream as an argument and copies the codec parameters from there.
There are also attributes
time_base_in
,time_base_out
which are probably required for 100% support of setts option constraints. Let me know if those should be hooked up as well. I guess it would require that BitStreamFilterContext takes separate in_stream, out_stream arguments instead of single stream.