AWS Thinkbox Discussion Forums

Default Draft Template and Changing Gamma

I am a bit new to python and Draft scripting, so it would really be helpful if someone could point me in the right direction for applying a gamma correction to a sequence of images before encoding them.

First - I am using the default Draft Samples. ([repository]\draft\Samples)

Specifically this script “[repository]\draft\Samples\Encode\encode_to_MOV_MJPEG_1080p.py”

This is fine when compiling jpgs, but when i try to compile .exr’s, i need to correct the gamma to 2.2.

What would be the best way to insert code to apply a 2.2 gamma correction to the .exrs before encoding them as a MJPEG?

Thanks.

Sorry for not responding to this earlier… for some reason it appears I’m not getting all of the forum notifications I should be.

There are two methods to apply a gamma correction: currFrame.ApplyGamma( 2.2 ) and lut = Draft.LUT.CreateGamma( 2.2 ) lut.Apply( currFrame ) In either case, you’d apply the gamma just before encoding the frame. For the case where you’re creating the lut, you only need to do that once, so place that code before the loop over the frames. I would need to look at the Draft source code to see if there’s an efficiency difference between the two methods for the case of multiple frames, or you can try them both and see if it makes a noticeable difference.

If you’re using the same script for both jpegs and exrs, you’ll want to put the application of the gamma in a conditional that checks that the input file extension is exr. Before the loop (around line 53):( root, ext ) = os.path.splitext( inFilePattern ) correctGamma = ( ext == '.exr' ) then, before encoding the frame (around line 63): if correctGamma: currFrame.ApplyGamma( 2.2 )

Privacy | Site terms | Cookie preferences