Repository navigation
Add VideoFrame.solid() - #2482
Merged
Merged
Conversation
The color goes through swscale on a 16x16 RGBA block, then av_image_fill_color copies the resulting components across the frame, so the result matches reformat() without converting every pixel. Paletted and Bayer formats are rejected because a single component value cannot describe them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
VideoFrame.solid(width, height, color="black", format="yuv420p")to create a frame filled with one color. Today that takes a numpy array andfrom_ndarray, or writing bytes into planes by hand while accounting forline_sizepadding.coloris either a stringav_parse_colorunderstands ("red","#ff8000","white@0.5") or an(r, g, b)/(r, g, b, a)tuple of 0–255 ints.Swscale converts a 16x16 RGBA block to the target format.
av_read_image_line2reads that block's components, andav_image_fill_colorwrites them across the whole frame. The result matchesreformat(), including its colorspace and range tags, and only the small block goes through swscale. This works for packed, planar, semi-planar, subsampled, alpha, and high-bit-depth formats. Paletted and Bayer formats raiseValueErrorbecause a single component value can't describe them.Tests cover several formats at an odd size (33x17), equality with
reformat(), alpha, and invalid input.