Skip to content

Commit 9b2fc63

Browse files
committed
fix: add proper docstring for find_best_pix_fmt_of_list
1 parent 1ff9813 commit 9b2fc63

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

av/codec/codec.pyi

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,20 @@ def find_best_pix_fmt_of_list(
120120
pix_fmts: Sequence[PixFmtLike],
121121
src_pix_fmt: PixFmtLike,
122122
has_alpha: bool = False,
123-
) -> tuple[VideoFormat | None, int]: ...
123+
) -> tuple[VideoFormat | None, int]:
124+
"""
125+
Find the best pixel format to convert to given a source format.
126+
127+
Wraps :ffmpeg:`avcodec_find_best_pix_fmt_of_list`.
128+
129+
:param pix_fmts: Iterable of pixel formats to choose from (str or VideoFormat).
130+
:param src_pix_fmt: Source pixel format (str or VideoFormat).
131+
:param bool has_alpha: Whether the source alpha channel is used.
132+
:return: (best_format, loss): best_format is the best matching pixel format from
133+
the list, or None if no suitable format was found; loss is Combination of flags informing you what kind of losses will occur.
134+
:rtype: (VideoFormat | None, int)
135+
136+
Note on loss: it is a bitmask of FFmpeg loss flags describing what kinds of information would be lost converting from src_pix_fmt to best_format (e.g. loss of alpha, chroma, colorspace, resolution, bit depth, etc.). Multiple losses can be present at once, so the value is meant to be interpreted with bitwise & against FFmpeg's FF_LOSS_* constants.
137+
For exact behavior see: libavutil/pixdesc.c/get_pix_fmt_score() in ffmpeg source code.
138+
"""
139+
...

0 commit comments

Comments
 (0)