Skip to content

sssqweeeed/HDRPython

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

HDR Python

General

This repository allows you to work with HDR videos using python.

Code specification

$ pip install numpy skimage ffmpeg-python colour-science

Also you need to install ffmpeg

Usage

  1. Create an instance of the class
import HDRPython
reader = HDRPython(width=1920, height=1080)
  1. 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')
  1. Perform the necessary actions in the desired gamma curve
    1. Applying function to all video frames
    reader.apply(func)
    1. Gamma encoding in case of reading from linear frames
    reader.to_gamma('PQ')
    reader.to_gamma('HLG')
    1. Gamma decoding in case of HDR video reading
    reader.to_linear()
  2. Use received data
    1. Writing to disk
    reader.write_linear('path/')
    reader.write('path/', gamma = 'PQ', fps = 25)
    1. Further processing in python
    reader.get_video_generator()
    ...
    reader.close()

Example

  1. 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/')
  1. 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)

Common errors

  1. When reading from files .exr or .hdr
    1. 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
    2. 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

Contact us

If you find any bugs, or you have suggestions for improvement, you can write to email

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%