1 # gpl: authors Carlos Padial, Turi Scandurra
5 from bpy
.props
import IntProperty
6 from bpy
.types
import (
10 from . import functions
14 ("1", "25%", ""), ("2", "50%", ""),
15 ("3", "75%", ""), ("4", "100%", ""),
21 def createdatamosh(context
, strip
):
22 preferences
= context
.preferences
23 prefs
= preferences
.addons
[__package__
].preferences
25 fileinput
= bpy
.path
.abspath(strip
.filepath
)
26 fileoutput
= fileinput
.rpartition(".")[0] + "_datamosh.avi"
28 if prefs
.all_keyframes
:
29 command
= "datamosh '{}' -a -o '{}'".format(fileinput
, fileoutput
)
31 command
= "datamosh '{}' -o '{}'".format(fileinput
, fileoutput
)
37 def createavi(context
, strip
):
38 fileinput
= bpy
.path
.abspath(strip
.filepath
)
39 fileoutput
= fileinput
.rpartition(".")[0] + "_.avi"
41 command
= "ffmpeg -i '{}' -vcodec copy '{}'".format(fileinput
, fileoutput
)
49 def createavimjpeg(context
, strip
):
50 fileinput
= bpy
.path
.abspath(strip
.filepath
)
51 fileoutput
= fileinput
.rpartition(".")[0] + "_mjpeg.avi"
53 command
= "ffmpeg -i '{}' -vcodec mjpeg -q:v 1 '{}'".format(fileinput
, fileoutput
)
62 class CreateAvi(Operator
):
63 bl_idname
= "sequencer.createavi"
64 bl_label
= "Create avi file"
65 bl_description
= "Create an avi output file"
66 bl_options
= {'REGISTER', 'UNDO'}
74 def poll(self
, context
):
75 strip
= functions
.act_strip(context
)
77 if scn
and scn
.sequence_editor
and scn
.sequence_editor
.active_strip
:
78 return strip
.type in ('MOVIE')
82 def execute(self
, context
):
83 strips
= functions
.get_selected_strips(context
)
86 # deselect all other strips
89 # select current strip
91 if strip
.type == "MOVIE":
93 fileoutput
= createavi(context
, strip
)
95 fileoutput
= createavimjpeg(context
, strip
)
96 strip
.filepath
= fileoutput
98 # select all strips again
102 except ReferenceError:
105 bpy
.ops
.sequencer
.reload()
110 class CreateDatamosh(Operator
):
111 bl_idname
= "sequencer.createdatamosh"
112 bl_label
= "Create Datamosh"
113 bl_description
= "Create Datamosh"
116 def poll(self
, context
):
117 strip
= functions
.act_strip(context
)
119 if scn
and scn
.sequence_editor
and scn
.sequence_editor
.active_strip
:
120 return strip
.type in ('MOVIE')
124 def execute(self
, context
):
125 preferences
= context
.preferences
126 prefs
= preferences
.addons
[__package__
].preferences
127 strips
= functions
.get_selected_strips(context
)
130 # deselect all other strips
133 # select current strip
135 if strip
.type == "MOVIE":
136 fileoutput
= createdatamosh(context
, strip
)
137 if prefs
.load_glitch
:
138 strip
.filepath
= fileoutput
140 # select all strips again
144 except ReferenceError:
147 bpy
.ops
.sequencer
.reload()
152 class CreateGlitchToolPanel(Panel
):
153 bl_label
= "Glitch Tools"
154 bl_idname
= "OBJECT_PT_GlitchTool"
155 bl_space_type
= 'SEQUENCE_EDITOR'
156 bl_region_type
= 'UI'
159 def poll(self
, context
):
160 if context
.space_data
.view_type
in {'SEQUENCER',
161 'SEQUENCER_PREVIEW'}:
162 strip
= functions
.act_strip(context
)
164 preferences
= context
.preferences
165 prefs
= preferences
.addons
[__package__
].preferences
166 if scn
and scn
.sequence_editor
and scn
.sequence_editor
.active_strip
:
167 if prefs
.use_glitch_panel
:
168 return strip
.type in ('MOVIE')
172 def draw_header(self
, context
):
174 layout
.label(text
="", icon
="GAME")
176 def draw(self
, context
):
178 preferences
= context
.preferences
179 prefs
= preferences
.addons
[__package__
].preferences
183 layout
.operator("sequencer.createavi", text
="Create avi (same codec)")
184 layout
.operator("sequencer.createavi", text
="Create avi (mjpeg)").size
= 2
186 layout
.prop(prefs
, "all_keyframes")
187 layout
.prop(prefs
, "load_glitch")
189 layout
.operator("sequencer.createdatamosh")