Skip to content

Conversation

@jlaine
Copy link
Member

@jlaine jlaine commented Apr 1, 2025

The return type of CodecContext.create can be narrowed based on the name of the requested codec, allowing us to know whether we are dealing with an AudioCodecContext or a VideoCodecContext.

As the same logic is used by OutputContainer.add_stream, use a shared list of audio / video codec names. We add the following codec names:

  • audio : libopus, pcm_alaw, pcm_mulaw
  • video : libvpx, libx264

@jlaine jlaine requested a review from WyattBlue April 1, 2025 07:34
@jlaine jlaine force-pushed the codec-typing branch 2 times, most recently from bc3ceca to 8752b44 Compare April 1, 2025 07:36
The return type of `CodecContext.create` can be narrowed based on the
name of the requested codec, allowing us to know whether we are dealing
with an `AudioCodecContext` or a `VideoCodecContext`.

As the same logic is used by `OutputContainer.add_stream`, use a shared
list of audio / video codec names. We add the following codec names:

- audio : libopus, pcm_alaw, pcm_mulaw
- video : libvpx, libx264
@WyattBlue WyattBlue merged commit 4e01ca7 into PyAV-Org:main Apr 1, 2025
5 checks passed
@jlaine jlaine deleted the codec-typing branch April 1, 2025 14:41
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