1 # SPDX-FileCopyrightText: 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
3 # SPDX-License-Identifier: GPL-3.0-or-later
8 from .utils
.global_settings
import SequenceTypes
9 from .utils
.functions
import slice_selection
10 from .utils
.doc
import doc_name
, doc_idname
, doc_brief
, doc_description
13 class POWER_SEQUENCER_OT_speed_up_movie_strip(bpy
.types
.Operator
):
15 *brief* Adds a speed effect to the 2x speed, set frame end, wrap both into META
17 Add 2x speed to strip and set its frame end accordingly. Wraps both the strip and the speed
18 modifier into a META strip.
22 "name": doc_name(__qualname__
),
23 "demo": "https://i.imgur.com/ZyEd0jD.gif",
24 "description": doc_description(__doc__
),
27 {"type": "TWO", "value": "PRESS", "alt": True},
32 {"type": "THREE", "value": "PRESS", "alt": True},
37 {"type": "FOUR", "value": "PRESS", "alt": True},
42 "keymap": "Sequencer",
44 bl_idname
= doc_idname(__qualname__
)
45 bl_label
= doc
["name"]
46 bl_description
= doc_brief(doc
["description"])
47 bl_options
= {"REGISTER", "UNDO"}
49 speed_factor
: bpy
.props
.IntProperty(
50 name
="Speed factor", description
="How many times the footage gets sped up", default
=2, min=0
52 individual_sequences
: bpy
.props
.BoolProperty(
53 name
="Affect individual strips",
54 description
="Speed up every VIDEO strip individually",
59 def poll(cls
, context
):
60 return context
.selected_sequences
62 def execute(self
, context
):
63 sequences
= [s
for s
in context
.selected_sequences
if s
.type in SequenceTypes
.VIDEO
]
67 {"ERROR_INVALID_INPUT"},
68 "No Movie meta_strip or Metastrips selected. Operation cancelled",
73 if self
.individual_sequences
:
74 selection_blocks
= [[s
] for s
in sequences
]
76 selection_blocks
= slice_selection(context
, sequences
)
78 for sequences
in selection_blocks
:
79 self
.speed_effect_add(context
, sequences
)
82 {"INFO"}, "Successfully processed " + str(len(selection_blocks
)) + " selection blocks"
86 def speed_effect_add(self
, context
, sequences
):
90 sequence_editor
= context
.scene
.sequence_editor
91 sequencer
= bpy
.ops
.sequencer
93 sequencer
.select_all(action
="DESELECT")
97 meta_strip
= sequence_editor
.active_strip
99 sequencer
.effect_strip_add(type="SPEED")
100 speed_effect
= sequence_editor
.active_strip
101 speed_effect
.use_default_fade
= False
102 speed_effect
.speed_factor
= self
.speed_factor
104 duration
= ceil(meta_strip
.frame_final_duration
/ speed_effect
.speed_factor
)
105 meta_strip
.frame_final_end
= meta_strip
.frame_final_start
+ duration
107 sequence_editor
.active_strip
= meta_strip
108 speed_effect
.select
= True
109 meta_strip
.select
= True
110 sequencer
.meta_make()
111 sequence_editor
.active_strip
.name
= (
112 meta_strip
.sequences
[0].name
+ " " + str(self
.speed_factor
) + "x"