-
Notifications
You must be signed in to change notification settings - Fork 430
HDR (10-bit) frames cannot be correctly converted to rgb48le since av==16.0.0 #2192
Copy link
Copy link
Open
Description
Since 16.0.0, frame data cannot be converted to images correctly with code like the following.
import av
import numpy as np
from PIL import Image
input_file = "tmp/test_videos/Hybrid HDR10 with Dolby Vision Sample.mkv" # from https://kodi.wiki/view/Samples
output_file = f"{av.__version__}_out.png"
skip_frame = 10
with av.open(input_file, mode="r") as container:
for packet in container.demux(video=0):
for frame in packet.decode():
skip_frame -= 1
if skip_frame <= 0:
frame = frame.to_ndarray(format="rgb48le")
frame_float = frame / 65535.0
# Save as 8-bit for debugging.
frame_uint8 = np.clip(frame_float * 255.0, 0, 255).astype(np.uint8)
image = Image.fromarray(frame_uint8)
image.save(output_file)
print("save", output_file)
break
if skip_frame <= 0:
breakIf the issue is related to the reformat or to_ndarray, it may already be fixed in the latest code, but I have not tested it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

