Simple overscan script

I decided to share my simple scriptlet to make camera overscan. It saves my life for years since I wrote it. Hope it will help sombody else:

import bpy

#Set overscan value HERE. Can be negative ONLY TO UNDO previous overscan
overscan = 100

#This should not be modified
resX = bpy.context.scene.render.resolution_x
resY = bpy.context.scene.render.resolution_y
activeCamera = bpy.context.scene.camera

activeCamera.data.lens = resX * activeCamera.data.lens / (resX + 2*overscan)
bpy.context.scene.render.resolution_x = resX + int(overscan) * 2
bpy.context.scene.render.resolution_y = resY + int(overscan) * 2
1 Like

Thanks. This script seems to save some math / expression writing if you’re not adding onto a 100% render res. Else one could simply add the overscan value in the render percentage instead.

Increasing precentage does nothing: it’s just scales picture. My method based on simple trigonometry: it changes focal length and picture dimensions (not proportionally, of course!) so you have more area around your original frame. And precentage doesn’t interfere with my script anyhow. Real overscan happens on compositing later when you crop picture to original resolution preserving original data and bounding box.