-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy paththreepoint.py
More file actions
666 lines (596 loc) · 29.2 KB
/
Copy paththreepoint.py
File metadata and controls
666 lines (596 loc) · 29.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
import bpy
import os
from . import timeline
from . import vseqf
def update_import_frame_in(self, fps):
self.import_frame_in = int(round((self.import_minutes_in * 60 * fps) + (self.import_seconds_in * fps) + self.import_frames_in))
def update_import_frame_length(self, fps):
self.import_frame_length = int(round((self.import_minutes_length * 60 * fps) + (self.import_seconds_length * fps) + self.import_frames_length))
def update_import_minutes_in(self, context):
fps = vseqf.get_fps(context.scene)
length = self.full_length
length_timecode = vseqf.timecode_from_frames(length, fps, subsecond_type='frames', mode='list')
max_hours, max_minutes, max_seconds, max_frames = length_timecode
max_minutes = max_minutes + (max_hours * 60)
if self.import_minutes_in + self.import_minutes_length > max_minutes:
if self.import_minutes_length > 0:
self.import_minutes_length = self.import_minutes_length - 1
else:
self.import_minutes_in = self.import_minutes_in - 1
update_import_frame_in(self, fps)
def update_import_minutes_length(self, context):
fps = vseqf.get_fps(context.scene)
length = self.full_length
length_timecode = vseqf.timecode_from_frames(length, fps, subsecond_type='frames', mode='list')
max_hours, max_minutes, max_seconds, max_frames = length_timecode
max_minutes = max_minutes + (max_hours * 60)
if self.import_minutes_in + self.import_minutes_length > max_minutes:
self.import_minutes_length = self.import_minutes_length - 1
update_import_frame_length(self, fps)
def update_import_seconds_in(self, context):
fps = vseqf.get_fps(context.scene)
length = self.full_length
length_timecode = vseqf.timecode_from_frames(length, fps, subsecond_type='frames', mode='list')
max_hours, max_minutes, max_seconds, max_frames = length_timecode
max_minutes = max_minutes + (max_hours * 60)
if self.import_seconds_in >= 60 and self.import_minutes_in < max_minutes:
self.import_seconds_in = 0
self.import_minutes_in = self.import_minutes_in + 1
else:
if self.import_seconds_in + self.import_seconds_length >= 60:
max_minutes = max_minutes - 1
if self.import_minutes_in + self.import_minutes_length >= max_minutes:
if self.import_seconds_length > 0:
self.import_seconds_length = self.import_seconds_length - 1
elif self.import_minutes_length > 0:
self.import_minutes_length = self.import_minutes_length - 1
self.import_seconds_length = 59
elif self.import_seconds_in + self.import_seconds_length >= max_seconds:
self.import_seconds_in = max_seconds
update_import_frame_in(self, fps)
def update_import_seconds_length(self, context):
fps = vseqf.get_fps(context.scene)
length = self.full_length
length_timecode = vseqf.timecode_from_frames(length, fps, subsecond_type='frames', mode='list')
max_hours, max_minutes, max_seconds, max_frames = length_timecode
max_minutes = max_minutes + (max_hours * 60)
if self.import_minutes_in + self.import_minutes_length >= max_minutes:
if self.import_seconds_length + self.import_seconds_in > max_seconds:
self.import_seconds_length = int(round(max_seconds - self.import_seconds_in))
else:
if self.import_seconds_length >= 60:
self.import_seconds_length = 0
self.import_minutes_length = int(round(self.import_minutes_length + 1))
update_import_frame_length(self, fps)
def update_import_frames_in(self, context):
fps = vseqf.get_fps(context.scene)
length = self.full_length
length_timecode = vseqf.timecode_from_frames(length, fps, subsecond_type='frames', mode='list')
max_hours, max_minutes, max_seconds, max_frames = length_timecode
max_minutes = max_minutes + (max_hours * 60)
if self.import_frames_in >= fps and (self.import_seconds_in < max_seconds or self.import_minutes_in < max_minutes):
#this variable is maxed out, and more can be added to next variables, so cycle up the next variable
self.import_frames_in = 0
self.import_seconds_in = self.import_seconds_in + 1
else:
if self.import_frames_in + self.import_frames_length >= fps:
max_seconds = max_seconds - 1
if self.import_seconds_in + self.import_seconds_length >= max_seconds and self.import_minutes_in + self.import_minutes_length >= max_minutes:
#all above variables are maxed out in current setup, this cannot be rolled over unless length is lowered
if self.import_seconds_length > 0 or self.import_minutes_length > 0:
#reduce seconds length, roll frames up to next
self.import_seconds_length = self.import_seconds_length - 1
self.import_frames_length = int(round(fps) - 1)
elif self.import_frames_length > 1:
#reduce frame length
self.import_frames_length = self.import_frames_length - 1
elif self.import_frames_in + self.import_frames_length >= fps - 1:
#everything is maxed out, hold at maximum
self.import_frames_in = max_frames - 1
update_import_frame_in(self, fps)
def update_import_frames_length(self, context):
fps = vseqf.get_fps(context.scene)
length = self.full_length
length_timecode = vseqf.timecode_from_frames(length, fps, subsecond_type='frames', mode='list')
max_hours, max_minutes, max_seconds, max_frames = length_timecode
max_minutes = max_minutes + (max_hours * 60)
if self.import_minutes_in + self.import_minutes_length >= max_minutes and self.import_seconds_in + self.import_seconds_length >= max_seconds:
if self.import_frames_length == 0:
self.import_frames_length = 1
elif self.import_frames_length + self.import_frames_in > max_frames:
self.import_frames_length = max_frames - self.import_frames_in
else:
if self.import_frames_length >= fps:
self.import_frames_length = 0
self.import_seconds_length = self.import_seconds_length + 1
update_import_frame_length(self, fps)
def three_point_draw_callback(self, context):
colorfg = (1.0, 1.0, 1.0, 1.0)
colorbg = (0.1, 0.1, 0.1, 1.0)
colormg = (0.5, 0.5, 0.5, 1.0)
scale = self.scale
half_scale = scale / 2.0
quarter_scale = scale / 4.0
double_scale = scale * 2
width = context.region.width
height = context.region.height
#draw in/out bars
vseqf.draw_rect(0, height - double_scale, width, double_scale, colorbg)
vseqf.draw_rect(0, height - half_scale - 2, width, 4, colormg)
vseqf.draw_rect(0, height - scale - half_scale - 2, width, 4, colormg)
vseqf.draw_rect(0, height - scale - 1, width, 2, colormg)
#draw in/out icons
in_x = self.in_percent * width
vseqf.draw_rect(in_x, height - scale, quarter_scale, scale, colorfg)
vseqf.draw_tri((in_x, height - half_scale), (in_x + half_scale, height), (in_x + half_scale, height - scale), colorfg)
if self.in_percent <= .5:
in_text_x = in_x + scale
else:
in_text_x = 0 + half_scale
vseqf.draw_text(in_text_x, height - scale + 2, scale - 2, "In: "+str(self.in_frame), colorfg)
out_x = self.out_percent * width
vseqf.draw_rect(out_x - quarter_scale, height - double_scale, quarter_scale, scale, colorfg)
vseqf.draw_tri((out_x, height - half_scale - scale), (out_x - half_scale, height - scale), (out_x - half_scale, height - double_scale), colorfg)
if self.out_percent >= .5:
out_text_x = 0 + half_scale
else:
out_text_x = out_x + half_scale
vseqf.draw_text(out_text_x, height - double_scale + 2, scale - 2, "Length: "+str(self.out_frame - self.in_frame), colorfg)
class VSEQF_PT_ThreePointBrowserPanel(bpy.types.Panel):
bl_label = "3Point Edit"
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Quick 3Point"
@classmethod
def poll(cls, context):
prefs = vseqf.get_prefs()
if not prefs.threepoint:
return False
params = context.space_data.params
selected_file = params.filename
if selected_file:
filename, extension = os.path.splitext(selected_file)
if extension.lower() in bpy.path.extensions_movie:
directory = params.directory.decode("utf-8") #uhh... apparently this is now a bytes string?? what.
full_filename = os.path.join(directory, params.filename)
if os.path.exists(full_filename):
return True
return False
def draw(self, context):
del context
layout = self.layout
row = layout.row()
row.operator('vseqf.threepoint_import_to_clip', text='Import To Clip Editor')
class ThreePointSetup:
clip = None
iterations = 0
def threepoint_setup_area(self, *_):
self.iterations += 1
areas = bpy.context.screen.areas
if len(areas) > 1 or areas[0].type != 'FILE_BROWSER':
#check if areas have changed
for area in areas:
if area.type == 'CLIP_EDITOR':
for space in area.spaces:
if space.type == 'CLIP_EDITOR':
space.clip = self.clip
self.remove_handler()
return
if self.iterations > 20:
#prevent infinite loop
self.remove_handler()
def remove_handler(self):
handlers = bpy.app.handlers.depsgraph_update_post
for handler in handlers:
if " threepoint_setup_area " in str(handler):
handlers.remove(handler)
class VSEQFThreePointImportToClip(bpy.types.Operator):
bl_idname = "vseqf.threepoint_import_to_clip"
bl_label = "Import Movie To Clip Editor"
bl_description = 'Creates a movieclip from the selected video file and sets any visible Movie Clip Editor area to display it'
_timer = None
clip = None
tries = 0
def execute(self, context):
self.tries = 0
params = context.space_data.params
directory = params.directory.decode("utf-8") #uhh... apparently this is now a bytes string?? what.
filename = os.path.join(directory, params.filename)
self.clip = bpy.data.movieclips.load(filename, check_existing=True)
if len(context.screen.areas) == 1 and context.screen.areas[0].type == 'FILE_BROWSER':
#User is using the fullscreen file browser, close it
bpy.ops.file.cancel()
clip = self.clip
handlers = bpy.app.handlers.depsgraph_update_post
for handler in handlers:
if " threepoint_setup_area " in str(handler):
handlers.remove(handler)
threepointsetup = ThreePointSetup()
threepointsetup.clip = clip
handlers.append(threepointsetup.threepoint_setup_area)
return {'RUNNING_MODAL'}
return {'FINISHED'}
def cancel(self, context):
context.window_manager.event_timer_remove(self._timer)
class VSEQF_PT_ThreePointPanel(bpy.types.Panel):
bl_label = "3 Point Edit"
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
bl_category = "Footage"
@classmethod
def poll(cls, context):
prefs = vseqf.get_prefs()
if not prefs.threepoint:
return False
clip = context.space_data.clip
if clip:
if os.path.isfile(bpy.path.abspath(clip.filepath)):
return True
return False
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
scene = context.scene
row = layout.row()
row.operator('vseqf.threepoint_modal_operator', text='Set In/Out')
fps = vseqf.get_fps(context.scene)
row = layout.row()
if clip.import_settings.import_frame_in != -1:
row.label(text="In: "+str(clip.import_settings.import_frame_in)+' ('+vseqf.timecode_from_frames(clip.import_settings.import_frame_in, fps)+')')
else:
row.label(text="In: Not Set")
row = layout.row()
col = row.column(align=True)
col.prop(clip.import_settings, 'import_minutes_in', text='Minutes In')
col.prop(clip.import_settings, 'import_seconds_in', text='Seconds In')
col.prop(clip.import_settings, 'import_frames_in', text='Frames In')
row = layout.row()
col = row.column(align=True)
col.prop(clip.import_settings, 'import_minutes_length', text='Minutes Length')
col.prop(clip.import_settings, 'import_seconds_length', text='Seconds Length')
col.prop(clip.import_settings, 'import_frames_length', text='Frames Length')
row = layout.row()
if clip.import_settings.import_frame_length != -1:
row.label(text="Length: "+str(clip.import_settings.import_frame_length)+' ('+vseqf.timecode_from_frames(clip.import_settings.import_frame_length, fps)+')')
else:
row.label(text="Length Not Set")
row = layout.row()
prop = row.operator('vseqf.threepoint_import', text='Import At Cursor')
prop.type = 'cursor'
prop.tooltip = "Import this video into the VSE at frame "+str(scene.frame_current)
row = layout.row()
prop = row.operator('vseqf.threepoint_import', text='Replace Active Strip')
prop.type = 'replace'
prop.tooltip = "Import this video into the VSE and replace the active strip"
row = layout.row()
prop = row.operator('vseqf.threepoint_import', text='Insert At Cursor')
prop.type = 'insert'
prop.tooltip = "Import and insert this video into the VSE at frame "+str(scene.frame_current)
row = layout.row()
prop = row.operator('vseqf.threepoint_import', text='Cut Insert At Cursor')
prop.type = 'cut_insert'
prop.tooltip = "Cut all strips at frame "+str(scene.frame_current)+" and insert this videoe"
row = layout.row()
prop = row.operator('vseqf.threepoint_import', text='Import At End')
prop.type = 'end'
prop.tooltip = "Import this video into the VSE at the end of all strips"
class VSEQFThreePointImport(bpy.types.Operator):
bl_idname = "vseqf.threepoint_import"
bl_label = "Imports a movie clip into the VSE as a movie strip"
type: bpy.props.StringProperty()
tooltip: bpy.props.StringProperty("Import a movie clip into the VSE s a movie strip")
@classmethod
def description(cls, context, properties):
return properties.tooltip
def execute(self, context):
override_area = False
for area in context.screen.areas:
if area.type == 'SEQUENCE_EDITOR':
if not override_area:
override_area = area
if area.spaces[0].view_type != 'PREVIEW':
override_area = area
if override_area:
active_strip = timeline.current_active(context)
sequencer = context.scene.sequence_editor
if not sequencer:
context.scene.sequence_editor_create()
strips = context.scene.sequence_editor.strips_all
for strip in strips:
strip.select = False
strip.select_left_handle = False
strip.select_right_handle = False
clip = context.space_data.clip
filepath = bpy.path.abspath(clip.filepath)
frame_start = timeline.find_strips_start(strips) - clip.frame_duration - 1
with context.temp_override(area=override_area):
bpy.ops.sequencer.movie_strip_add(filepath=filepath, frame_start=frame_start, replace_sel=True, use_framerate=False)
sound_strip = False
movie_strip = False
strips = context.scene.sequence_editor.strips_all
selected = timeline.current_selected(context)
for strip in selected:
if strip.type == 'MOVIE':
movie_strip = strip
if strip.type == 'SOUND':
sound_strip = strip
if not movie_strip:
return {'CANCELLED'}
if movie_strip and sound_strip:
#Attempt to fix a blender bug where it puts the audio strip too low - https://developer.blender.org/T64964
content_start_backup = movie_strip.content_start
sound_channel = movie_strip.channel
movie_strip.channel = movie_strip.channel + 1
movie_strip.content_start = content_start_backup
sound_strip.channel = sound_channel
if clip.import_settings.import_frame_in == -1:
frame_in = 0
else:
frame_in = clip.import_settings.import_frame_in
if clip.import_settings.import_frame_length < 1:
frame_length = clip.frame_duration
else:
frame_length = clip.import_settings.import_frame_length
import_pos = context.scene.frame_current
offset = frame_length - frame_in
if self.type == 'replace':
if not active_strip:
return {'CANCELLED'}
if sound_strip:
sound_strip.channel = active_strip.channel + 1
movie_strip.channel = active_strip.channel
content_start = active_strip.left_handle - frame_in
move_forward = offset - active_strip.duration
if move_forward > 0:
move_frame = active_strip.left_handle
else:
move_frame = active_strip.right_handle
with context.temp_override(area=override_area):
bpy.ops.sequencer.select_all(action='DESELECT')
active_strip.select = True
with context.temp_override(area=override_area):
bpy.ops.sequencer.delete()
if move_forward != 0:
#Have to set the frame_current because for some reason the frame variable in vseqf.cut doesn't work...
old_current = context.scene.frame_current
context.scene.frame_current = move_frame
bpy.ops.vseqf.cut(type='INSERT_ONLY', use_insert=True, insert=move_forward, use_all=True, all=True)
context.scene.frame_current = old_current
elif self.type == 'end':
import_pos = timeline.find_strips_end(strips)
content_start = import_pos - frame_in
elif self.type == 'insert':
bpy.ops.vseqf.cut(type='INSERT_ONLY', use_insert=True, insert=offset, use_all=True, all=True)
content_start = import_pos - frame_in
elif self.type == 'cut_insert':
bpy.ops.vseqf.cut(type='INSERT', use_insert=True, insert=offset, use_all=True, all=True)
content_start = import_pos - frame_in
else:
content_start = import_pos - frame_in
context.scene.sequence_editor.active_strip = movie_strip
movie_strip.left_handle_offset = frame_in #crashing blender in replace mode???
#movie_strip.duration = frame_length
movie_strip.content_start = content_start
movie_strip.right_handle = content_start + frame_length
with context.temp_override(area=override_area):
bpy.ops.sequencer.select_all(action='DESELECT')
movie_strip.select = True
if sound_strip:
sound_strip.select = True
channel = sound_strip.channel
sound_strip.left_handle_offset = frame_in
#sound_strip.right_handle_offset = frame_length
sound_strip.channel = channel
sound_strip.content_start = content_start
if sound_strip.right_handle > movie_strip.right_handle:
sound_strip.right_handle = movie_strip.right_handle
return {'FINISHED'}
else:
return {'CANCELLED'}
class VSEQFThreePointOperator(bpy.types.Operator):
bl_idname = "vseqf.threepoint_modal_operator"
bl_label = "3Point Modal Operator"
bl_description = "Start the realtime 3point editing functionality in the Clip Editor"
_handle = None
scale = 20
mouse_down = False
mouse_x = 0
mouse_y = 0
editing_in = False
editing_length = False
in_percent = 0
out_percent = 1
clip = None
in_frame = 1
out_frame = 2
start_frame = 0
original_scene = None
last_in = -1
last_length = -1
def update_import_values(self, context):
fps = round(vseqf.get_fps(context.scene))
settings = self.clip.import_settings
if settings.import_frame_length != -1:
frame_length = settings.import_frame_length
else:
frame_length = self.clip.frame_duration
if settings.import_frame_in != -1:
frame_in = settings.import_frame_in
else:
frame_in = 0
remainder, frames_in = divmod(frame_in, fps)
minutes_in, seconds_in = divmod(remainder, 60)
remainder, frames_length = divmod(frame_length, fps)
minutes_length, seconds_length = divmod(remainder, 60)
settings.import_frames_in = frames_in
settings.import_seconds_in = seconds_in
settings.import_minutes_in = minutes_in
settings.import_frames_length = frames_length
settings.import_seconds_length = seconds_length
settings.import_minutes_length = minutes_length
def update_pos(self, context, mouse_x, mouse_y):
self.mouse_x = mouse_x
self.mouse_y = mouse_y
clip = self.clip
clip_length = clip.frame_duration
percent = mouse_x / context.region.width
if percent < 0:
percent = 0
if percent > 1:
percent = 1
if self.editing_in:
if percent > self.out_percent:
percent = self.out_percent
self.in_percent = percent
self.in_frame = int(round(clip_length * self.in_percent))
if self.in_frame >= self.out_frame:
self.in_frame = self.out_frame - 1
context.scene.frame_current = self.in_frame + 1
clip.import_settings.import_frame_in = self.in_frame
clip.import_settings.import_frame_length = self.out_frame - self.in_frame
context.scene.frame_start = self.in_frame
elif self.editing_length:
if percent < self.in_percent:
percent = self.in_percent
self.out_percent = percent
self.out_frame = int(round(clip_length * self.out_percent))
if self.out_frame <= self.in_frame:
self.out_frame = self.in_frame + 1
context.scene.frame_current = self.out_frame - 1
clip.import_settings.import_frame_length = self.out_frame - self.in_frame
context.scene.frame_end = self.out_frame
def modal(self, context, event):
context.area.tag_redraw()
if event.type == 'SPACE' and event.value == 'PRESS':
#play/pause
bpy.ops.screen.animation_play()
if event.type == 'MOUSEMOVE':
if self.mouse_down:
self.update_pos(context, event.mouse_region_x, event.mouse_region_y)
self.update_import_values(context)
elif event.type == 'LEFTMOUSE':
if event.mouse_region_y < 20:
#click was at bottom of area on timeline, let the user scrub the timeline
return {'PASS_THROUGH'}
else:
if event.value == 'PRESS':
self.mouse_down = True
height = context.region.height
width = context.region.width
if event.mouse_region_x > 0 and event.mouse_region_x < width:
if event.mouse_region_y < height and event.mouse_region_y > height - self.scale:
self.editing_in = True
self.update_pos(context, event.mouse_region_x, event.mouse_region_y)
elif event.mouse_region_y < height - self.scale and event.mouse_region_y > height - (self.scale * 2):
self.editing_length = True
self.update_pos(context, event.mouse_region_x, event.mouse_region_y)
else:
self.finish_modal(context)
return {'FINISHED'}
else:
self.finish_modal(context)
return {'FINISHED'}
elif event.value == 'RELEASE':
self.mouse_down = False
self.editing_in = False
self.editing_length = False
elif event.type in {'RIGHTMOUSE', 'ESC'}:
self.clip.import_settings.import_frame_in = self.last_in
self.clip.import_settings.import_frame_length = self.last_length
self.finish_modal(context)
return {'FINISHED'}
return {'RUNNING_MODAL'}
def finish_modal(self, context):
if context.screen.is_animation_playing:
bpy.ops.screen.animation_play()
bpy.types.SpaceClipEditor.draw_handler_remove(self._handle, 'WINDOW')
bpy.ops.scene.delete()
self.update_import_values(context)
#context.scene.frame_current = self.start_frame
def invoke(self, context, event):
del event
if context.screen.is_animation_playing:
bpy.ops.screen.animation_play()
space = context.space_data
if space.type == 'CLIP_EDITOR':
self.start_frame = context.scene.frame_current
self.clip = context.space_data.clip
self.last_in = self.clip.import_settings.import_frame_in
self.last_length = self.clip.import_settings.import_frame_length
self.clip.import_settings.full_length = self.clip.frame_duration
if self.clip.import_settings.import_frame_in == -1:
self.in_frame = 0
self.clip.import_settings.import_frame_in = 0
self.in_percent = 0
else:
self.in_frame = self.clip.import_settings.import_frame_in
if self.clip.frame_duration > self.in_frame:
self.in_percent = self.in_frame / self.clip.frame_duration
else:
self.in_percent = 0
if self.clip.import_settings.import_frame_length == -1:
self.out_frame = self.clip.frame_duration
self.clip.import_settings.import_frame_length = self.out_frame - self.in_frame
else:
self.out_frame = self.clip.import_settings.import_frame_length + self.in_frame
if self.clip.frame_duration >= self.out_frame:
self.out_percent = self.out_frame / self.clip.frame_duration
self.update_import_values(context)
self.original_scene = context.scene
bpy.ops.scene.new(type='EMPTY')
context.scene.name = 'ThreePoint Temp'
context.scene.frame_current = 1
clip = context.space_data.clip
filepath = bpy.path.abspath(clip.filepath)
context.scene.sequence_editor_create()
context.scene.sequence_editor.strips.new_movie(name='ThreePoint Temp', filepath=filepath, channel=1, frame_start=1)
context.scene.sequence_editor.strips.new_sound(name='ThreePoint Temp Sound', filepath=filepath, channel=2, frame_start=1)
context.scene.frame_start = self.in_frame
context.scene.frame_end = self.out_frame
context.scene.frame_current = self.in_frame + 1
args = (self, context)
self._handle = bpy.types.SpaceClipEditor.draw_handler_add(three_point_draw_callback, args, 'WINDOW', 'POST_PIXEL')
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
return {'CANCELLED'}
class VSEQFQuick3PointValues(bpy.types.PropertyGroup):
full_length: bpy.props.IntProperty(
default=1,
min=0)
import_frame_in: bpy.props.IntProperty(
default=-1,
min=-1)
import_frame_length: bpy.props.IntProperty(
default=-1,
min=-1)
import_minutes_in: bpy.props.IntProperty(
default=0,
min=0,
update=update_import_minutes_in,
description="Minutes to remove from beginning of video when importing")
import_seconds_in: bpy.props.IntProperty(
default=0,
min=0,
update=update_import_seconds_in,
description="Seconds to remove from beginning of video when importing")
import_frames_in: bpy.props.IntProperty(
default=0,
min=0,
update=update_import_frames_in,
description="Frames to remove from beginning of video when importing")
import_minutes_length: bpy.props.IntProperty(
default=0,
min=0,
update=update_import_minutes_length,
description="Minutes component of imported video length")
import_seconds_length: bpy.props.IntProperty(
default=0,
min=0,
update=update_import_seconds_length,
description="Seconds component of imported video length")
import_frames_length: bpy.props.IntProperty(
default=0,
min=0,
update=update_import_frames_length,
description="Frames component of imported video length")