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

Improve pixel format handling #620

Draft
wants to merge 2 commits into
base: develop
from

Conversation

@mildsunrise
Copy link
Contributor

@mildsunrise mildsunrise commented Apr 13, 2020

Allow user to set preferred format

Expose get_format to allow user to choose decoded pixel format, by adding a VideoCodecContext.preferred_format property. If set and supported by the decoder, that format will be used; otherwise fall back to current behaviour.

We could have exposed the callback directly for better control, but since there's codec.video_formats and PyAV tries to hide these complexities, I thought it was better this way. WDYT?

Handle format overrides, not set

The current code only updates VideoCodecContext.format and VideoCodecContext.pix_fmt when the user modifies them. However, according to the documentation, decoders may override those values too (at open, when decoding frames, etc.). The code now checks for pix_fmt / width / height changes at every access.

Also, when the pixel format is not set, pix_fmt now returns None instead of raising.

mildsunrise added 2 commits Apr 13, 2020
 - According to documentation, decoders may override pix_fmt
   at any time. So, always check for changes.
 - When pixel format is not set, pix_fmt should be None
@mildsunrise mildsunrise changed the title WIP: Improve pixel format handling Improve pixel format handling Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant