This repository allows you to work with HDR videos using python.
- Сolour, manipulations with gamma curves
- ffmpeg-python, reading HDR videos
- ffmpeg, writing HDR videos
- skimage
- Numpy
$ pip install numpy skimage ffmpeg-python colour-science
Also you need to install ffmpeg
- Create an instance of the class
import HDRPython
reader = HDRPython(width=1920, height=1080)
- Select the data entry method. It can be an HDR video that can be read by ffmpeg or a folder with *.hdr or *.exr files
reader.read_video('in.mov', gamma='PQ')
reader.read_video('in.mov', gamma='HLG')
reader.read_from_linear_frames('/path', type_of_file='exr')
- Perform the necessary actions in the desired gamma curve
- Applying function to all video frames
reader.apply(func)
- Gamma encoding in case of reading from linear frames
reader.to_gamma('PQ') reader.to_gamma('HLG')
- Gamma decoding in case of HDR video reading
reader.to_linear()
- Use received data
- Writing to disk
reader.write_linear('path/') reader.write('path/', gamma = 'PQ', fps = 25)
- Further processing in python
reader.get_video_generator() ... reader.close()
- Conversion to frames with linear gamut
reader = HDRPython(width=1920, height=1080)
reader.read_video('in.mov', gamma='PQ')
reader.to_linear()
reader.write_linear('frames/')
- Conversion to video (example of use is processing output of a neural network)
reader = HDRPython(1920, 1080)
reader.read_from_linear_frames('frames/')
reader.to_gamma('HLG')
reader.write('videos/out.mov', 'HLG', fps=30)
- When reading from files .exr or .hdr
- their values should be in the Rec.2020 color space. Otherwise, you will get distorted colors. Use the Colour and HDRPython.apply() for changing color space
- the brightness may exceed 1000 nits. Take care of the correct mapping if you want to record in a video with the HLG gamma curve or use PQ. Otherwise, details that are brighter than 1000 nits will be cut off
If you find any bugs, or you have suggestions for improvement, you can write to email