node-av / lib / avcodecFindBestPixFmtOfList
Function: avcodecFindBestPixFmtOfList()
avcodecFindBestPixFmtOfList(
pixFmtList,srcPixFmt):AVPixelFormat
Defined in: src/lib/utilities.ts:1306
Pick the best-matching pixel format from a list for a given source format.
Chooses the format from pixFmtList that converting srcPixFmt to incurs the least loss (color depth, chroma subsampling, alpha). Useful to select a codec-supported target pixel format that preserves as much of the source as possible (e.g. yuv422p over yuv420p when the input is yuv444p).
Direct mapping to avcodec_find_best_pix_fmt_of_list().
Parameters
pixFmtList
Candidate pixel formats (e.g. a codec's supported formats)
srcPixFmt
Source pixel format to convert from
Returns
The least-loss pixel format from the list
Example
typescript
const target = avcodecFindBestPixFmtOfList(codec.pixelFormats, frame.format);See
avcodec_find_best_pix_fmt_of_list - FFmpeg Doxygen
