Closed tom-bola closed 3 days ago
I don't think this is possible to fix in the general case because nobody has actually bothered to specify what frame.to_ndarray
should actually do and which properties are most important.
Even if the behaviour isn't formally specified: the minimal assumption that PyAV users have is that the default behaviour is matching that of ffmpeg. The src_color_range
and dst_color_range
parameters of frame.to_ndarray
behave in wrong/unexpected ways. IMHO this is an obvious bug and the reference behaviour is well defined (which is: to match ffmpeg). I propose to leave this bug open.
Overview
When decoding a full-range yuv444p video stream and converting to RGB like so
I found that the resulting images are different than what I get when extracting images with ffmpeg:
Expected behavior
The expected behaviour is that the resulting RGB is very close to what is generated by running the above ffmpeg command. For other formats (e.g. limited range yuv420p) this is the case.
Actual behavior
The actual behaviour is that the images differ significantly. It seems like the RGB created with PyAV is scaled incorrectly, using more range than the reference:
Investigation
I found that specifying the
src_color_range
(ordst_color_range
until av 12.0.0) fixes the scaling:Reproduction
To create a video with yuv444p full-range I used the following command
This is the video that I tested with:
https://github.com/PyAV-Org/PyAV/assets/12171321/3a934bab-5c78-4286-82fb-9b8a94edf54b
Versions
Research
I have done the following:
Additional context
Related Issue#1378