When HWAccel(is_hw_owned=False) is used, all color properties such as colorspace become UNSPECIFIED (2 or 0).
import av
from av.codec.hwaccel import HWAccel
from av.datasets import fate as fate_suite
def print_frame_color_props(file_path, hwaccel):
if hwaccel is None:
s = "hwaccel=None"
else:
s = f"hwaccel=HWAccel(is_hw_owned={hwaccel.is_hw_owned})"
print(f"* {s}")
with av.open(file_path, mode="r", hwaccel=hwaccel) as container:
for frame in container.decode(video=0):
print(
" "
f"colorspace={frame.colorspace}, "
f"color_primaries={frame.color_primaries}, "
f"color_trc={frame.color_trc}, "
f"color_range={frame.color_range}"
)
return
file_path = fate_suite("hevc/hdr10_plus_h265_sample.hevc")
print_frame_color_props(file_path, hwaccel=None)
print_frame_color_props(
file_path,
hwaccel=HWAccel(
device_type="cuda", is_hw_owned=True, allow_software_fallback=False
),
)
print_frame_color_props(
file_path,
hwaccel=HWAccel(
device_type="cuda", is_hw_owned=False, allow_software_fallback=False
),
)
* hwaccel=None
colorspace=9, color_primaries=9, color_trc=16, color_range=1
* hwaccel=HWAccel(is_hw_owned=True)
colorspace=9, color_primaries=9, color_trc=16, color_range=1
* hwaccel=HWAccel(is_hw_owned=False)
colorspace=2, color_primaries=2, color_trc=2, color_range=0
The exact conditions are unclear, but this may also be related to #2230.
EDIT: For now, I am considering restoring it from stream.colorspace and similar fields.
When
HWAccel(is_hw_owned=False)is used, all color properties such ascolorspacebecomeUNSPECIFIED(2 or 0).The exact conditions are unclear, but this may also be related to #2230.
EDIT: For now, I am considering restoring it from
stream.colorspaceand similar fields.