You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reading HDR video with VideoCapture results in complete different colors. Also combining frames back to HDR video with ffmpeg results in visible artefacts.
import cv2
import os
# Input video file path
video_path = 'example.mov'
# Output directory to save frames
output_directory = 'frames/'
# Create output directory if it doesn't exist
os.makedirs(output_directory, exist_ok=True)
# Open the video file
cap = cv2.VideoCapture(video_path)
frame_number = 0
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
frame_number += 1
frame_filename = os.path.join(output_directory, f'frame_{frame_number:04d}.png')
# Save the frame as an image file
cv2.imwrite(frame_filename, frame)
print(f"Saved {frame_filename}")
# Release the video capture
cap.release()
The result frames have visible color shift:
Combine back with ffmpeg: ffmpeg -i frames/frame_%04d.png -c:v hevc -pix_fmt yuv420p10le -color_range tv -colorspace bt2020nc -color_primaries bt2020 -color_trc arib-std-b67 -b:v 12231190 -tag:v hvc1 out.mov
out.mov
The result video has visible artifacts:
Issue submission checklist
I report the issue, it's not a question
I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
I updated to the latest OpenCV version and the issue is still there
There is reproducer code and related data files (videos, images, onnx, etc)
The text was updated successfully, but these errors were encountered:
@Kepnu4 Thanks a lot for the issue report. I investigated OpenCV decoding pipeline with FFmpeg and made some experiments. Decoding pipeline detects color space and other options correctly, but does not apply any filters. I'm looking on a proper way to take colorspace in account and return back, when have some solution for it.
@Kepnu4 Could you build OpenCV with PR above and report status to the issue? The patch shifts colors on my side and makes frames very close to what I get with console FFmpeg. The patch also affects existing code behaviour and I need to investigate possible side effects.
System Information
OpenCV version: 4.8.0.76
Operating System / Platform: Ubuntu 18.04
Python version: 3.9.16
Detailed description
Reading HDR video with VideoCapture results in complete different colors. Also combining frames back to HDR video with ffmpeg results in visible artefacts.
Steps to reproduce
Example HDR video
example.mov
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,pix_fmt,color_range,color_space,color_primaries,color_transfer,bit_rate -of json example.mov
:script for reading frames:
The result frames have visible color shift:
Combine back with ffmpeg:
ffmpeg -i frames/frame_%04d.png -c:v hevc -pix_fmt yuv420p10le -color_range tv -colorspace bt2020nc -color_primaries bt2020 -color_trc arib-std-b67 -b:v 12231190 -tag:v hvc1 out.mov
out.mov
The result video has visible artifacts:
Issue submission checklist
The text was updated successfully, but these errors were encountered: