~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/op/sequencer.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ##### BEGIN GPL LICENSE BLOCK #####
2
 
#
3
 
#  This program is free software; you can redistribute it and/or
4
 
#  modify it under the terms of the GNU General Public License
5
 
#  as published by the Free Software Foundation; either version 2
6
 
#  of the License, or (at your option) any later version.
7
 
#
8
 
#  This program is distributed in the hope that it will be useful,
9
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
#  GNU General Public License for more details.
12
 
#
13
 
#  You should have received a copy of the GNU General Public License
14
 
#  along with this program; if not, write to the Free Software Foundation,
15
 
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 
#
17
 
# ##### END GPL LICENSE BLOCK #####
18
 
 
19
 
# <pep8 compliant>
20
 
 
21
 
import bpy
22
 
 
23
 
from bpy.props import *
24
 
 
25
 
 
26
 
class SequencerCrossfadeSounds(bpy.types.Operator):
27
 
    '''Do crossfading volume animation of two selected sound strips.'''
28
 
 
29
 
    bl_idname = "sequencer.crossfade_sounds"
30
 
    bl_label = "Crossfade sounds"
31
 
    bl_options = {'REGISTER', 'UNDO'}
32
 
 
33
 
    def poll(self, context):
34
 
        if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
35
 
            return context.scene.sequence_editor.active_strip.type == 'SOUND'
36
 
        else:
37
 
            return False
38
 
 
39
 
    def execute(self, context):
40
 
        seq1 = None
41
 
        seq2 = None
42
 
        for s in context.scene.sequence_editor.sequences:
43
 
            if s.select and s.type == 'SOUND':
44
 
                if seq1 == None:
45
 
                    seq1 = s
46
 
                elif seq2 == None:
47
 
                    seq2 = s
48
 
                else:
49
 
                    seq2 = None
50
 
                    break
51
 
        if seq2 == None:
52
 
            self.report({'ERROR'}, "Select 2 sound strips.")
53
 
            return {'CANCELLED'}
54
 
        if seq1.frame_final_start > seq2.frame_final_start:
55
 
            s = seq1
56
 
            seq1 = seq2
57
 
            seq2 = s
58
 
        if seq1.frame_final_end > seq2.frame_final_start:
59
 
            tempcfra = context.scene.frame_current
60
 
            context.scene.frame_current = seq2.frame_final_start
61
 
            seq1.keyframe_insert('volume')
62
 
            context.scene.frame_current = seq1.frame_final_end
63
 
            seq1.volume = 0
64
 
            seq1.keyframe_insert('volume')
65
 
            seq2.keyframe_insert('volume')
66
 
            context.scene.frame_current = seq2.frame_final_start
67
 
            seq2.volume = 0
68
 
            seq2.keyframe_insert('volume')
69
 
            context.scene.frame_current = tempcfra
70
 
            return {'FINISHED'}
71
 
        else:
72
 
            self.report({'ERROR'}, "The selected strips don't overlap.")
73
 
            return {'CANCELLED'}
74
 
 
75
 
 
76
 
class SequencerCutMulticam(bpy.types.Operator):
77
 
    '''Cut multicam strip and select camera.'''
78
 
 
79
 
    bl_idname = "sequencer.cut_multicam"
80
 
    bl_label = "Cut multicam"
81
 
    bl_options = {'REGISTER', 'UNDO'}
82
 
 
83
 
    camera = IntProperty(name="Camera",
84
 
            default=1, min=1, max=32, soft_min=1, soft_max=32)
85
 
 
86
 
    def poll(self, context):
87
 
        if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
88
 
            return context.scene.sequence_editor.active_strip.type == 'MULTICAM'
89
 
        else:
90
 
            return False
91
 
 
92
 
    def execute(self, context):
93
 
        camera = self.properties.camera
94
 
 
95
 
        s = context.scene.sequence_editor.active_strip
96
 
 
97
 
        if s.multicam_source == camera or camera >= s.channel:
98
 
            return {'FINISHED'}
99
 
 
100
 
        if not s.select:
101
 
            s.select = True
102
 
 
103
 
        cfra = context.scene.frame_current
104
 
        bpy.ops.sequencer.cut(frame=cfra, type='SOFT', side='RIGHT')
105
 
        for s in context.scene.sequence_editor.sequences_all:
106
 
            if s.select and s.type == 'MULTICAM' and s.frame_final_start <= cfra and cfra < s.frame_final_end:
107
 
                context.scene.sequence_editor.active_strip = s
108
 
 
109
 
        context.scene.sequence_editor.active_strip.multicam_source = camera
110
 
        return {'FINISHED'}
111
 
 
112
 
 
113
 
class SequencerDeinterlaceSelectedMovies(bpy.types.Operator):
114
 
    '''Deinterlace all selected movie sources.'''
115
 
 
116
 
    bl_idname = "sequencer.deinterlace_selected_movies"
117
 
    bl_label = "Deinterlace Movies"
118
 
    bl_options = {'REGISTER', 'UNDO'}
119
 
 
120
 
    def poll(self, context):
121
 
        if context.scene and context.scene.sequence_editor:
122
 
            return True
123
 
        else:
124
 
            return False
125
 
 
126
 
    def execute(self, context):
127
 
        for s in context.scene.sequence_editor.sequences_all:
128
 
            if s.select and s.type == 'MOVIE':
129
 
                s.de_interlace = True
130
 
 
131
 
        return {'FINISHED'}
132
 
 
133
 
 
134
 
def register():
135
 
    register = bpy.types.register
136
 
 
137
 
    register(SequencerCrossfadeSounds)
138
 
    register(SequencerCutMulticam)
139
 
    register(SequencerDeinterlaceSelectedMovies)
140
 
 
141
 
 
142
 
def unregister():
143
 
    unregister = bpy.types.unregister
144
 
 
145
 
    unregister(SequencerCrossfadeSounds)
146
 
    unregister(SequencerCutMulticam)
147
 
    unregister(SequencerDeinterlaceSelectedMovies)
148
 
 
149
 
 
150
 
if __name__ == "__main__":
151
 
    register()