JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
126 stars 53 forks source link

Inconsistent color space conversion #318

Open galenlynch opened 3 years ago

galenlynch commented 3 years ago

VideoIO's current behavior with color space conversion is inconsistent. Right now the cases where color space conversion is performed when reading videos is 1) if both the video pixel format and destination format are the same gray format and the user has set allow_vio_gray_transform = true, and 2) if the codec pixel format is different than the destination format (e.g. YUV video and RGB julia array). There are a few use cases where a user might expect color space conversion, but currently none is performed. For example, if users are decoding a gray video with limited color range, no color space conversion is done if allow_vio_gray_transform = false, which is a flag to disallow VideoIO's own grayscale conversion, not a flag to disallow color space conversion. Similarly, if users are reading libx264_rgb videos, then no color space conversion will be done, even if the video's color space is different than Julia's. The same problems also exist in VideoIO's encoding behavior.

All this is made more complicated by the often spotty or missing color space metadata added to video files. Additionally, the two examples given above might be uncommon ones, since one of the biggest differences for interpreting video data is color_range, which as far as I know is only commonly used for YUV pixel formats. I would imagine limited range gray video data, or instead limited range rgb video data, would be very rare "in the wild".

However, the fact remains that our API for controlling when color space conversion is done, and our documentation about when it is done by default, is lacking.