Skip to content

Commit

Permalink
Blender 2.8 update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoomTen committed Jul 31, 2019
1 parent e80dbd6 commit ffe5036
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 126 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Cinebars
This add-on provides a drawer in the properties pane of Blender's Video Sequence Editor, that lets you add a letterboxing effect ("cinematic bars") to the project. Also useful for preview cropping in various aspect ratios. Please note - while many people may desire this effect, it is somewhat discouraged in favor of using *actual* video resolutions respective of a target aspect ratio.

Besides simply adding "cinematic bars", another use case would be to quickly make a starting point to animate them, giving the impression of changing aspect ratios
(useful for filmmakers desiring a specific focus on a character, or as a storytelling device)

Unlike the [Letterbox](http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Sequencer/Letterbox) add-on, it does not scale the video at all. Rather, it adds black bars to the sides of the video (top & bottom or left & right) to "crop" the video to a specified aspect ratio.

## 2.7x Users
This add-on has been updated for Blender 2.8. For 2.79 users, please check the `blender2.7` tag.

## Usage
The "Cinebars" drawer can be easily found in the Tools tab. Simply plug in your desired aspect ratio and click "Generate Cinebars Strip". It will generate 3 strips which you can then move to the top of your timeline.
The "Cinebars" drawer can be easily found in the Misc tab of the Video Sequencer. Simply plug in your desired aspect ratio and click "Generate Cinebars Strip". It will generate 3 strips which you can then move to the top of your timeline: A base color strip, and two transform strips which resizes and overlays the color strips on top
of the footage.

Ex: to generate 2.35:1 (CinemaScope) bars:
* Enter `2.35` in the Horizontal Ratio slider
* Enter `1` in the Vertical Ratio slider
* Click on "Generate Cinebars strips".

## Preview

![Screenshot](screenshot.jpg)
250 changes: 125 additions & 125 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,125 +1,125 @@
import bpy

bl_info = {
"name": "Cinebars",
"description": "Add fake-letterboxing without changing the resolution of your video.",
"author": "ZoomTen",
"version": (0, 0, 2),
"blender": (2, 71, 0),
"wiki_url": "https://github.com/ZoomTen/blender-vse-cinebars",
"tracker_url": "https://github.com/ZoomTen/blender-vse-cinebars/issues",
"location": "Video Sequence Editor > Properties > Cinebars",
"category": "Sequencer"
}

# vars
class cbVals(bpy.types.PropertyGroup):
ratio_x = bpy.props.FloatProperty(
name="ratio_x",
description="Horizontal ratio",
default=16.0
)
ratio_y = bpy.props.FloatProperty(
name="ratio_y",
description="Vertical ratio",
default=9.0
)

# funcs
def msgbox(message = "", title = "info", icon = 'INFO'):
def draw(self, context):
self.layout.label(message)
bpy.context.window_manager.popup_menu(draw, title = title, icon = icon)

def main(context):
# get render resolution
rsx = bpy.context.scene.render.resolution_x
rsy = bpy.context.scene.render.resolution_y
# get target AR
target_rsx = context.scene.cb_ratios.ratio_x
target_rsy = context.scene.cb_ratios.ratio_y
if target_rsx/target_rsy == rsx/rsy:
msgbox("Source AR is the same as destination AR!")
return 0
bpy.ops.sequencer.effect_strip_add(frame_start=bpy.context.scene.frame_start,
frame_end=bpy.context.scene.frame_end,
type="COLOR")
color = context.scene.sequence_editor.active_strip
bpy.ops.sequencer.effect_strip_add(type="TRANSFORM")
bar = context.scene.sequence_editor.active_strip
bar.name = "cinebars "+str('%.2f' % target_rsx)+":"+str('%.2f' % target_rsy)
# wide ratio
if target_rsx/target_rsy > rsx/rsy:
bar.scale_start_y = (1-((rsx/target_rsx*target_rsy)/rsy))/2
bar.translate_start_y= 50 - (bar.scale_start_y*50)
bar.blend_type='ALPHA_OVER'
bpy.ops.sequencer.duplicate_move(
SEQUENCER_OT_duplicate={"mode":'TRANSLATION'},
TRANSFORM_OT_seq_slide={"value":(2,1)}
)
otherbar = context.scene.sequence_editor.active_strip
otherbar.use_flip_y = True
otherbar.blend_type='ALPHA_OVER'
color.mute = True
# i would make them into a metastrip but there isn't a function for
# that apparently
# tall / square ratio
if target_rsx/target_rsy < rsx/rsy:
bar.scale_start_x = (1-((rsy/target_rsy*target_rsx)/rsx))/2
bar.translate_start_x= 50 - (bar.scale_start_x*50)
bar.blend_type='ALPHA_OVER'
bpy.ops.sequencer.duplicate_move(
SEQUENCER_OT_duplicate={"mode":'TRANSLATION'},
TRANSFORM_OT_seq_slide={"value":(2,1)}
)
otherbar = context.scene.sequence_editor.active_strip
otherbar.use_flip_x = True
otherbar.blend_type='ALPHA_OVER'
color.mute = True
# i would make them into a metastrip but there isn't a function for
# that which doesn't require selections apparently

# actions
class cbMake(bpy.types.Operator):
bl_idname = "sequencer.cb_make"
bl_label = "Make Cinebars"

def execute(self, context):
main(context)
return {'FINISHED'}
# ui
class cbPanel(bpy.types.Panel):
bl_space_type = "SEQUENCE_EDITOR"
bl_region_type = "UI"
bl_label = "Cinebars"
bl_idname = "sequencer.cb_panel"
def draw(self, context):
l = self.layout
l.prop(context.scene.cb_ratios, "ratio_x",text="Horizontal ratio")
l.prop(context.scene.cb_ratios, "ratio_y",text="Vertical ratio")
l.operator('sequencer.cb_make',
text='Generate Cinebars Strips',
icon='FILE_TICK')

# addon registry
def register():
bpy.utils.register_class(cbVals)
bpy.utils.register_class(cbMake)
bpy.utils.register_class(cbPanel)
bpy.types.Scene.cb_ratios = bpy.props.PointerProperty(type=cbVals)

def unregister():
del bpy.types.Scene.cb_ratios
bpy.utils.unregister_class(cbMake)
bpy.utils.unregister_class(cbPanel)
bpy.utils.unregister_class(cbVals)

if __name__ == "__main__":
register()
import bpy

bl_info = {
"name": "Cinebars",
"description": "Add fake-letterboxing without changing the resolution of your video.",
"author": "ZoomTen",
"version": (0, 0, 3),
"blender": (2, 80, 0),
"wiki_url": "https://github.com/ZoomTen/blender-vse-cinebars",
"tracker_url": "https://github.com/ZoomTen/blender-vse-cinebars/issues",
"location": "Video Sequencer > Misc > Cinebars",
"category": "Sequencer"
}

# vars
class cbVals(bpy.types.PropertyGroup):
ratio_x: bpy.props.FloatProperty(

This comment has been minimized.

Copy link
@ZoomTen

ZoomTen Jul 31, 2019

Author Owner

Example of annotated property

name="ratio_x",
description="Horizontal ratio",
default=16.0
)
ratio_y: bpy.props.FloatProperty(
name="ratio_y",
description="Vertical ratio",
default=9.0
)

# funcs
def msgbox(message = "", title = "info", icon = 'INFO'):
def draw(self, context):
self.layout.label(text=message)

This comment has been minimized.

Copy link
@ZoomTen

ZoomTen Jul 31, 2019

Author Owner

Parameters must be explicitly declared now

bpy.context.window_manager.popup_menu(draw, title = title, icon = icon)

def main(context):
# get render resolution
rsx = bpy.context.scene.render.resolution_x
rsy = bpy.context.scene.render.resolution_y

# get target AR
target_rsx = context.scene.cb_ratios.ratio_x
target_rsy = context.scene.cb_ratios.ratio_y

if target_rsx/target_rsy == rsx/rsy:
msgbox("Source ratio is the same as destination ratio!")
return 0


bpy.ops.sequencer.effect_strip_add(frame_start=bpy.context.scene.frame_start,
frame_end=bpy.context.scene.frame_end,
type="COLOR")
color = context.scene.sequence_editor.active_strip

bpy.ops.sequencer.effect_strip_add(type="TRANSFORM")
bar = context.scene.sequence_editor.active_strip

bar.name = "cinebars "+str('%.2f' % target_rsx)+":"+str('%.2f' % target_rsy)
# wide ratio
if target_rsx/target_rsy > rsx/rsy:
bar.scale_start_y = (1-((rsx/target_rsx*target_rsy)/rsy))/2
bar.translate_start_y= 50 - (bar.scale_start_y*50)
bar.blend_type='ALPHA_OVER'
bpy.ops.sequencer.duplicate_move(
SEQUENCER_OT_duplicate={"mode":'TRANSLATION'},
TRANSFORM_OT_seq_slide={"value":(2,1)}
)
otherbar = context.scene.sequence_editor.active_strip
otherbar.use_flip_y = True
otherbar.blend_type='ALPHA_OVER'
color.mute = True
# i would make them into a metastrip but there isn't a function for
# that apparently
# tall / square ratio
if target_rsx/target_rsy < rsx/rsy:
bar.scale_start_x = (1-((rsy/target_rsy*target_rsx)/rsx))/2
bar.translate_start_x= 50 - (bar.scale_start_x*50)
bar.blend_type='ALPHA_OVER'
bpy.ops.sequencer.duplicate_move(
SEQUENCER_OT_duplicate={"mode":'TRANSLATION'},
TRANSFORM_OT_seq_slide={"value":(2,1)}
)
otherbar = context.scene.sequence_editor.active_strip
otherbar.use_flip_x = True
otherbar.blend_type='ALPHA_OVER'
color.mute = True
# i would make them into a metastrip but there isn't a function for
# that which doesn't require selections apparently

# actions
class cbMake(bpy.types.Operator):
bl_idname = "sequencer.cb_make"
bl_label = "Make Cinebars"

def execute(self, context):
main(context)
return {'FINISHED'}

# ui
class cbPanel(bpy.types.Panel):
bl_space_type = "SEQUENCE_EDITOR"
bl_region_type = "UI"
bl_label = "Cinebars"
bl_idname = "CNB_PT_cbPanel"

This comment has been minimized.

Copy link
@ZoomTen

ZoomTen Jul 31, 2019

Author Owner

prefixed names in idname are recommended for UI elements

def draw(self, context):
l = self.layout
l.prop(context.scene.cb_ratios, "ratio_x", text="Horizontal ratio")
l.prop(context.scene.cb_ratios, "ratio_y", text="Vertical ratio")
l.operator('sequencer.cb_make',
text='Generate Cinebars Strips',
icon='FILE_TICK')

# addon registry
def register():
bpy.utils.register_class(cbVals)
bpy.utils.register_class(cbMake)
bpy.utils.register_class(cbPanel)
bpy.types.Scene.cb_ratios = bpy.props.PointerProperty(type=cbVals)

def unregister():
del bpy.types.Scene.cb_ratios
bpy.utils.unregister_class(cbPanel)
bpy.utils.unregister_class(cbMake)
bpy.utils.unregister_class(cbVals)

if __name__ == "__main__":
register()
Binary file added screenshot.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ffe5036

Please sign in to comment.