Created by: mildsunrise
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.