| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# |
| 3 |
# Copyright (c) 2016 Alexandru Băluț <[email protected]> |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or |
| 6 |
# modify it under the terms of the GNU Lesser General Public |
| 7 |
# License as published by the Free Software Foundation; either |
| 8 |
# version 2.1 of the License, or (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
# Lesser General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU Lesser General Public |
| 16 |
# License along with this program; if not, write to the |
| 17 |
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 18 |
# Boston, MA 02110-1301, USA. |
| 19 |
|
| 20 |
from . import overrides_hack |
| 21 |
|
| 22 |
import tempfile # noqa |
| 23 |
import gi |
| 24 |
|
| 25 |
gi.require_version("Gst", "1.0") |
| 26 |
gi.require_version("GES", "1.0") |
| 27 |
|
| 28 |
from gi.repository import Gst # noqa |
| 29 |
from gi.repository import GES # noqa |
| 30 |
from gi.repository import GLib # noqa |
| 31 |
import unittest # noqa |
| 32 |
from unittest import mock |
| 33 |
|
| 34 |
from . import common # noqa |
| 35 |
|
| 36 |
Gst.init(None) |
| 37 |
GES.init() |
| 38 |
|
| 39 |
|
| 40 |
class TestTimeline(common.GESSimpleTimelineTest): |
| 41 |
|
| 42 |
def test_signals_not_emitted_when_loading(self): |
| 43 |
mainloop = common.create_main_loop() |
| 44 |
timeline = common.create_project(with_group=True, saved=True) |
| 45 |
|
| 46 |
# Reload the project, check the group. |
| 47 |
project = GES.Project.new(uri=timeline.get_asset().props.uri) |
| 48 |
|
| 49 |
loaded_called = False |
| 50 |
def loaded(unused_project, unused_timeline): |
| 51 |
nonlocal loaded_called |
| 52 |
loaded_called = True |
| 53 |
mainloop.quit() |
| 54 |
project.connect("loaded", loaded) |
| 55 |
|
| 56 |
timeline = project.extract() |
| 57 |
|
| 58 |
signals = ["layer-added", "group-added", "track-added"] |
| 59 |
handle = mock.Mock() |
| 60 |
for signal in signals: |
| 61 |
timeline.connect(signal, handle) |
| 62 |
|
| 63 |
mainloop.run() |
| 64 |
self.assertTrue(loaded_called) |
| 65 |
handle.assert_not_called() |
| 66 |
|
| 67 |
def test_deeply_nested_serialization(self): |
| 68 |
deep_timeline = common.create_project(with_group=True, saved="deep") |
| 69 |
deep_project = deep_timeline.get_asset() |
| 70 |
|
| 71 |
deep_asset = GES.UriClipAsset.request_sync(deep_project.props.id) |
| 72 |
|
| 73 |
nested_timeline = common.create_project(with_group=False, saved=False) |
| 74 |
nested_project = nested_timeline.get_asset() |
| 75 |
nested_project.add_asset(deep_project) |
| 76 |
nested_timeline.append_layer().add_asset(deep_asset, 0, 0, 5 * Gst.SECOND, GES.TrackType.UNKNOWN) |
| 77 |
|
| 78 |
uri = "file://%s" % tempfile.NamedTemporaryFile(suffix="-nested.xges").name |
| 79 |
nested_timeline.get_asset().save(nested_timeline, uri, None, overwrite=True) |
| 80 |
|
| 81 |
asset = GES.UriClipAsset.request_sync(nested_project.props.id) |
| 82 |
project = self.timeline.get_asset() |
| 83 |
project.add_asset(nested_project) |
| 84 |
refclip = self.layer.add_asset(asset, 0, 0, 5 * Gst.SECOND, GES.TrackType.VIDEO) |
| 85 |
|
| 86 |
uri = "file://%s" % tempfile.NamedTemporaryFile(suffix=".xges").name |
| 87 |
project.save(self.timeline, uri, None, overwrite=True) |
| 88 |
self.assertEqual(len(project.list_assets(GES.Extractable)), 2) |
| 89 |
|
| 90 |
mainloop = common.create_main_loop() |
| 91 |
def loaded_cb(unused_project, unused_timeline): |
| 92 |
mainloop.quit() |
| 93 |
project.connect("loaded", loaded_cb) |
| 94 |
|
| 95 |
# Extract again the timeline and compare with previous one. |
| 96 |
timeline = project.extract() |
| 97 |
mainloop.run() |
| 98 |
layer, = timeline.get_layers() |
| 99 |
clip, = layer.get_clips() |
| 100 |
self.assertEqual(clip.props.uri, refclip.props.uri) |
| 101 |
self.assertEqual(timeline.props.duration, self.timeline.props.duration) |
| 102 |
|
| 103 |
self.assertEqual(timeline.get_asset(), project) |
| 104 |
self.assertEqual(len(project.list_assets(GES.Extractable)), 2) |
| 105 |
|
| 106 |
def test_iter_timeline(self): |
| 107 |
all_clips = set() |
| 108 |
for l in range(5): |
| 109 |
self.timeline.append_layer() |
| 110 |
for _ in range(5): |
| 111 |
all_clips.add(self.append_clip(l)) |
| 112 |
self.assertEqual(set(self.timeline.iter_clips()), all_clips) |
| 113 |
|
| 114 |
|
| 115 |
def test_nested_serialization(self): |
| 116 |
nested_timeline = common.create_project(with_group=True, saved=True) |
| 117 |
nested_project = nested_timeline.get_asset() |
| 118 |
layer = nested_timeline.append_layer() |
| 119 |
|
| 120 |
asset = GES.UriClipAsset.request_sync(nested_project.props.id) |
| 121 |
refclip = self.layer.add_asset(asset, 0, 0, 110 * Gst.SECOND, GES.TrackType.UNKNOWN) |
| 122 |
nested_project.save(nested_timeline, nested_project.props.id, None, True) |
| 123 |
|
| 124 |
project = self.timeline.get_asset() |
| 125 |
project.add_asset(nested_project) |
| 126 |
uri = "file://%s" % tempfile.NamedTemporaryFile(suffix=".xges").name |
| 127 |
self.assertEqual(len(project.list_assets(GES.Extractable)), 2) |
| 128 |
project.save(self.timeline, uri, None, overwrite=True) |
| 129 |
self.assertEqual(len(project.list_assets(GES.Extractable)), 2) |
| 130 |
|
| 131 |
mainloop = common.create_main_loop() |
| 132 |
def loaded(unused_project, unused_timeline): |
| 133 |
mainloop.quit() |
| 134 |
project.connect("loaded", loaded) |
| 135 |
|
| 136 |
# Extract again the timeline and compare with previous one. |
| 137 |
timeline = project.extract() |
| 138 |
mainloop.run() |
| 139 |
layer, = timeline.get_layers() |
| 140 |
clip, = layer.get_clips() |
| 141 |
self.assertEqual(clip.props.uri, refclip.props.uri) |
| 142 |
self.assertEqual(timeline.props.duration, self.timeline.props.duration) |
| 143 |
|
| 144 |
self.assertEqual(timeline.get_asset(), project) |
| 145 |
self.assertEqual(len(project.list_assets(GES.Extractable)), 2) |
| 146 |
|
| 147 |
def test_timeline_duration(self): |
| 148 |
self.append_clip() |
| 149 |
self.append_clip() |
| 150 |
clips = self.layer.get_clips() |
| 151 |
|
| 152 |
self.assertEqual(self.timeline.props.duration, 20) |
| 153 |
self.layer.remove_clip(clips[1]) |
| 154 |
self.assertEqual(self.timeline.props.duration, 10) |
| 155 |
|
| 156 |
self.append_clip() |
| 157 |
self.append_clip() |
| 158 |
clips = self.layer.get_clips() |
| 159 |
self.assertEqual(self.timeline.props.duration, 30) |
| 160 |
|
| 161 |
group = GES.Container.group(clips[1:]) |
| 162 |
self.assertEqual(self.timeline.props.duration, 30) |
| 163 |
|
| 164 |
group1 = GES.Container.group([]) |
| 165 |
group1.add(group) |
| 166 |
self.assertEqual(self.timeline.props.duration, 30) |
| 167 |
|
| 168 |
def test_spliting_with_auto_transition_on_the_left(self): |
| 169 |
self.track_types = [GES.TrackType.AUDIO] |
| 170 |
super().setUp() |
| 171 |
|
| 172 |
self.timeline.props.auto_transition = True |
| 173 |
clip1 = self.add_clip(0, 0, 100) |
| 174 |
clip2 = self.add_clip(50, 0, 100) |
| 175 |
self.assertTimelineTopology([ |
| 176 |
[ # Unique layer |
| 177 |
(GES.TestClip, 0, 100), |
| 178 |
(GES.TransitionClip, 50, 50), |
| 179 |
(GES.TestClip, 50, 100) |
| 180 |
] |
| 181 |
]) |
| 182 |
|
| 183 |
clip1.split(25) |
| 184 |
self.assertTimelineTopology([ |
| 185 |
[ # Unique layer |
| 186 |
(GES.TestClip, 0, 25), |
| 187 |
(GES.TestClip, 25, 75), |
| 188 |
(GES.TransitionClip, 50, 50), |
| 189 |
(GES.TestClip, 50, 100), |
| 190 |
] |
| 191 |
]) |
| 192 |
|
| 193 |
clip2.split(125) |
| 194 |
self.assertTimelineTopology([ |
| 195 |
[ # Unique layer |
| 196 |
(GES.TestClip, 0, 25), |
| 197 |
(GES.TestClip, 25, 75), |
| 198 |
(GES.TransitionClip, 50, 50), |
| 199 |
(GES.TestClip, 50, 75), |
| 200 |
(GES.TestClip, 125, 25), |
| 201 |
] |
| 202 |
]) |
| 203 |
|
| 204 |
@unittest.skipUnless(*common.can_generate_assets()) |
| 205 |
def test_auto_transition_type_after_setting_proxy_asset(self): |
| 206 |
self.track_types = [GES.TrackType.VIDEO] |
| 207 |
super().setUp() |
| 208 |
|
| 209 |
self.timeline.props.auto_transition = True |
| 210 |
with common.created_video_asset() as uri: |
| 211 |
self.append_clip(asset_type=GES.UriClip, asset_id=uri) |
| 212 |
self.append_clip(asset_type=GES.UriClip, asset_id=uri).props.start = 5 |
| 213 |
clip1, transition, clip2 = self.layer.get_clips() |
| 214 |
video_transition, = transition.get_children(True) |
| 215 |
video_transition.set_transition_type(GES.VideoStandardTransitionType.BAR_WIPE_LR) |
| 216 |
self.assertEqual(video_transition.get_transition_type(), GES.VideoStandardTransitionType.BAR_WIPE_LR) |
| 217 |
|
| 218 |
with common.created_video_asset() as uri2: |
| 219 |
proxy_asset = GES.UriClipAsset.request_sync(uri2) |
| 220 |
clip1.set_asset(proxy_asset) |
| 221 |
clip1, transition1, clip2 = self.layer.get_clips() |
| 222 |
|
| 223 |
video_transition1, = transition1.get_children(True) |
| 224 |
self.assertEqual(video_transition, video_transition1) |
| 225 |
self.assertEqual(video_transition.get_transition_type(), GES.VideoStandardTransitionType.BAR_WIPE_LR) |
| 226 |
|
| 227 |
def test_frame_info(self): |
| 228 |
self.track_types = [GES.TrackType.VIDEO] |
| 229 |
super().setUp() |
| 230 |
|
| 231 |
vtrack, = self.timeline.get_tracks() |
| 232 |
vtrack.update_restriction_caps(Gst.Caps("video/x-raw,framerate=60/1")) |
| 233 |
self.assertEqual(self.timeline.get_frame_time(60), Gst.SECOND) |
| 234 |
|
| 235 |
layer = self.timeline.append_layer() |
| 236 |
asset = GES.Asset.request(GES.TestClip, "framerate=120/1,height=500,width=500,max-duration=f120") |
| 237 |
clip = layer.add_asset( asset, 0, 0, Gst.SECOND, GES.TrackType.UNKNOWN) |
| 238 |
self.assertEqual(clip.get_id(), "GESTestClip, framerate=(fraction)120/1, height=(int)500, width=(int)500, max-duration=(string)f120;") |
| 239 |
|
| 240 |
test_source, = clip.get_children(True) |
| 241 |
self.assertEqual(test_source.get_natural_size(), (True, 500, 500)) |
| 242 |
self.assertEqual(test_source.get_natural_framerate(), (True, 120, 1)) |
| 243 |
self.assertEqual(test_source.props.max_duration, Gst.SECOND) |
| 244 |
self.assertEqual(clip.get_natural_framerate(), (True, 120, 1)) |
| 245 |
|
| 246 |
self.assertEqual(self.timeline.get_frame_at(Gst.SECOND), 60) |
| 247 |
self.assertEqual(clip.props.max_duration, Gst.SECOND) |
| 248 |
|
| 249 |
def test_layer_active(self): |
| 250 |
def check_nle_object_activeness(clip, track_type, active=None, ref_clip=None): |
| 251 |
assert ref_clip is not None or active is not None |
| 252 |
|
| 253 |
if ref_clip: |
| 254 |
ref_elem, = ref_clip.find_track_elements(None, track_type, GES.Source) |
| 255 |
active = ref_elem.get_nleobject().props.active |
| 256 |
|
| 257 |
elem, = clip.find_track_elements(None, track_type, GES.Source) |
| 258 |
self.assertIsNotNone(elem) |
| 259 |
self.assertEqual(elem.get_nleobject().props.active, active) |
| 260 |
|
| 261 |
def get_tracks(timeline): |
| 262 |
for track in self.timeline.get_tracks(): |
| 263 |
if track.props.track_type == GES.TrackType.VIDEO: |
| 264 |
video_track = track |
| 265 |
else: |
| 266 |
audio_track = track |
| 267 |
return video_track, audio_track |
| 268 |
|
| 269 |
|
| 270 |
def check_set_active_for_tracks(layer, active, tracks, expected_changed_tracks): |
| 271 |
callback_called = [] |
| 272 |
def _check_active_changed_cb(layer, active, tracks, expected_tracks, expected_active): |
| 273 |
self.assertEqual(set(tracks), set(expected_tracks)) |
| 274 |
self.assertEqual(active, expected_active) |
| 275 |
callback_called.append(True) |
| 276 |
|
| 277 |
layer.connect("active-changed", _check_active_changed_cb, expected_changed_tracks, active) |
| 278 |
self.assertTrue(layer.set_active_for_tracks(active, tracks)) |
| 279 |
self.layer.disconnect_by_func(_check_active_changed_cb) |
| 280 |
self.assertEqual(callback_called, [True]) |
| 281 |
|
| 282 |
c0 = self.append_clip() |
| 283 |
check_nle_object_activeness(c0, GES.TrackType.VIDEO, True) |
| 284 |
check_nle_object_activeness(c0, GES.TrackType.AUDIO, True) |
| 285 |
|
| 286 |
elem, = c0.find_track_elements(None, GES.TrackType.AUDIO, GES.Source) |
| 287 |
elem.props.active = False |
| 288 |
check_nle_object_activeness(c0, GES.TrackType.VIDEO, True) |
| 289 |
check_nle_object_activeness(c0, GES.TrackType.AUDIO, False) |
| 290 |
self.check_reload_timeline() |
| 291 |
elem.props.active = True |
| 292 |
|
| 293 |
# Muting audio track |
| 294 |
video_track, audio_track = get_tracks(self.timeline) |
| 295 |
|
| 296 |
check_set_active_for_tracks(self.layer, False, [audio_track], [audio_track]) |
| 297 |
|
| 298 |
check_nle_object_activeness(c0, GES.TrackType.VIDEO, True) |
| 299 |
check_nle_object_activeness(c0, GES.TrackType.AUDIO, False) |
| 300 |
self.check_reload_timeline() |
| 301 |
|
| 302 |
c1 = self.append_clip() |
| 303 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 304 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, False) |
| 305 |
|
| 306 |
l1 = self.timeline.append_layer() |
| 307 |
c1.move_to_layer(l1) |
| 308 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 309 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, True) |
| 310 |
|
| 311 |
self.assertTrue(c1.edit([], self.layer.get_priority(), GES.EditMode.EDIT_NORMAL, |
| 312 |
GES.Edge.EDGE_NONE, c1.props.start)) |
| 313 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 314 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, False) |
| 315 |
self.check_reload_timeline() |
| 316 |
|
| 317 |
self.assertTrue(self.layer.remove_clip(c1)) |
| 318 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 319 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, True) |
| 320 |
|
| 321 |
self.assertTrue(self.layer.add_clip(c1)) |
| 322 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 323 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, False) |
| 324 |
|
| 325 |
check_set_active_for_tracks(self.layer, True, None, [audio_track]) |
| 326 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 327 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, True) |
| 328 |
|
| 329 |
elem, = c1.find_track_elements(None, GES.TrackType.AUDIO, GES.Source) |
| 330 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 331 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, True) |
| 332 |
|
| 333 |
# Force deactivating a specific TrackElement |
| 334 |
elem.props.active = False |
| 335 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, True) |
| 336 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, False) |
| 337 |
self.check_reload_timeline() |
| 338 |
|
| 339 |
# Try activating a specific TrackElement, that won't change the |
| 340 |
# underlying nleobject activness |
| 341 |
check_set_active_for_tracks(self.layer, False, None, [audio_track, video_track]) |
| 342 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, False) |
| 343 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, False) |
| 344 |
|
| 345 |
elem.props.active = True |
| 346 |
check_nle_object_activeness(c1, GES.TrackType.VIDEO, False) |
| 347 |
check_nle_object_activeness(c1, GES.TrackType.AUDIO, False) |
| 348 |
self.check_reload_timeline() |
| 349 |
|
| 350 |
|
| 351 |
class TestEditing(common.GESSimpleTimelineTest): |
| 352 |
|
| 353 |
def test_transition_disappears_when_moving_to_another_layer(self): |
| 354 |
self.timeline.props.auto_transition = True |
| 355 |
unused_clip1 = self.add_clip(0, 0, 100) |
| 356 |
clip2 = self.add_clip(50, 0, 100) |
| 357 |
self.assertEqual(len(self.layer.get_clips()), 4) |
| 358 |
|
| 359 |
layer2 = self.timeline.append_layer() |
| 360 |
clip2.edit([], layer2.get_priority(), GES.EditMode.EDIT_NORMAL, |
| 361 |
GES.Edge.EDGE_NONE, clip2.props.start) |
| 362 |
self.assertEqual(len(self.layer.get_clips()), 1) |
| 363 |
self.assertEqual(len(layer2.get_clips()), 1) |
| 364 |
|
| 365 |
def activate_snapping(self): |
| 366 |
self.timeline.set_snapping_distance(5) |
| 367 |
self.snapped_at = [] |
| 368 |
|
| 369 |
def _snapped_cb(timeline, elem1, elem2, position): |
| 370 |
self.snapped_at.append(position) |
| 371 |
|
| 372 |
def _snapped_end_cb(timeline, elem1, elem2, position): |
| 373 |
if self.snapped_at: # Ignoring first snap end. |
| 374 |
self.snapped_at.append(Gst.CLOCK_TIME_NONE) |
| 375 |
|
| 376 |
self.timeline.connect("snapping-started", _snapped_cb) |
| 377 |
self.timeline.connect("snapping-ended", _snapped_end_cb) |
| 378 |
|
| 379 |
def test_snap_start_snap_end(self): |
| 380 |
clip = self.append_clip() |
| 381 |
self.append_clip() |
| 382 |
|
| 383 |
self.activate_snapping() |
| 384 |
self.assertTimelineTopology([ |
| 385 |
[ # Unique layer |
| 386 |
(GES.TestClip, 0, 10), |
| 387 |
(GES.TestClip, 10, 10), |
| 388 |
] |
| 389 |
]) |
| 390 |
|
| 391 |
# snap to 20 |
| 392 |
clip.props.start = 18 |
| 393 |
self.assertTimelineTopology([ |
| 394 |
[ # Unique layer |
| 395 |
(GES.TestClip, 10, 10), |
| 396 |
(GES.TestClip, 20, 10), |
| 397 |
] |
| 398 |
]) |
| 399 |
self.assertEqual(self.snapped_at, [20]) |
| 400 |
|
| 401 |
# no snapping |
| 402 |
clip.props.start = 30 |
| 403 |
self.assertTimelineTopology([ |
| 404 |
[ # Unique layer |
| 405 |
(GES.TestClip, 10, 10), |
| 406 |
(GES.TestClip, 30, 10), |
| 407 |
] |
| 408 |
]) |
| 409 |
self.assertEqual(self.snapped_at, [20, Gst.CLOCK_TIME_NONE]) |
| 410 |
|
| 411 |
# snap to 20 |
| 412 |
clip.props.start = 18 |
| 413 |
self.assertTimelineTopology([ |
| 414 |
[ # Unique layer |
| 415 |
(GES.TestClip, 10, 10), |
| 416 |
(GES.TestClip, 20, 10), |
| 417 |
] |
| 418 |
]) |
| 419 |
self.assertEqual(self.snapped_at, [20, Gst.CLOCK_TIME_NONE, 20]) |
| 420 |
# snap to 20 again |
| 421 |
clip.props.start = 19 |
| 422 |
self.assertTimelineTopology([ |
| 423 |
[ # Unique layer |
| 424 |
(GES.TestClip, 10, 10), |
| 425 |
(GES.TestClip, 20, 10), |
| 426 |
] |
| 427 |
]) |
| 428 |
self.assertEqual( |
| 429 |
self.snapped_at, |
| 430 |
[20, Gst.CLOCK_TIME_NONE, 20, Gst.CLOCK_TIME_NONE, 20]) |
| 431 |
|
| 432 |
def test_rippling_snaps(self): |
| 433 |
self.timeline.props.auto_transition = True |
| 434 |
self.append_clip() |
| 435 |
clip = self.append_clip() |
| 436 |
|
| 437 |
self.activate_snapping() |
| 438 |
self.assertTimelineTopology([ |
| 439 |
[ # Unique layer |
| 440 |
(GES.TestClip, 0, 10), |
| 441 |
(GES.TestClip, 10, 10), |
| 442 |
] |
| 443 |
]) |
| 444 |
|
| 445 |
clip.edit([], 0, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 15) |
| 446 |
self.assertEqual(self.snapped_at, [10]) |
| 447 |
self.assertTimelineTopology([ |
| 448 |
[ # Unique layer |
| 449 |
(GES.TestClip, 0, 10), |
| 450 |
(GES.TestClip, 10, 10), |
| 451 |
] |
| 452 |
]) |
| 453 |
|
| 454 |
clip.edit([], 0, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 20) |
| 455 |
self.assertEqual(self.snapped_at, [10, Gst.CLOCK_TIME_NONE]) |
| 456 |
self.assertTimelineTopology([ |
| 457 |
[ # Unique layer |
| 458 |
(GES.TestClip, 0, 10), |
| 459 |
(GES.TestClip, 20, 10), |
| 460 |
] |
| 461 |
]) |
| 462 |
|
| 463 |
def test_transition_moves_when_rippling_to_another_layer(self): |
| 464 |
self.timeline.props.auto_transition = True |
| 465 |
clip1 = self.add_clip(0, 0, 100) |
| 466 |
clip2 = self.add_clip(50, 0, 100) |
| 467 |
all_clips = self.layer.get_clips() |
| 468 |
self.assertEqual(len(all_clips), 4) |
| 469 |
|
| 470 |
layer2 = self.timeline.append_layer() |
| 471 |
clip1.edit([], layer2.get_priority(), GES.EditMode.EDIT_RIPPLE, |
| 472 |
GES.Edge.EDGE_NONE, clip1.props.start) |
| 473 |
self.assertEqual(self.layer.get_clips(), []) |
| 474 |
self.assertEqual(set(layer2.get_clips()), set(all_clips)) |
| 475 |
|
| 476 |
def test_transition_rippling_after_next_clip_stays(self): |
| 477 |
self.timeline.props.auto_transition = True |
| 478 |
clip1 = self.add_clip(0, 0, 100) |
| 479 |
clip2 = self.add_clip(50, 0, 100) |
| 480 |
all_clips = self.layer.get_clips() |
| 481 |
self.assertEqual(len(all_clips), 4) |
| 482 |
|
| 483 |
clip1.edit([], self.layer.get_priority(), GES.EditMode.EDIT_RIPPLE, |
| 484 |
GES.Edge.EDGE_NONE, clip2.props.start + 1) |
| 485 |
self.assertEqual(set(self.layer.get_clips()), set(all_clips)) |
| 486 |
|
| 487 |
def test_transition_rippling_over_does_not_create_another_transition(self): |
| 488 |
self.timeline.props.auto_transition = True |
| 489 |
|
| 490 |
clip1 = self.add_clip(0, 0, 17 * Gst.SECOND) |
| 491 |
clip2 = clip1.split(7.0 * Gst.SECOND) |
| 492 |
# Make a transition between the two clips |
| 493 |
clip1.edit([], self.layer.get_priority(), |
| 494 |
GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 4.5 * Gst.SECOND) |
| 495 |
|
| 496 |
# Rippl clip1 and check that transitions ar always the sames |
| 497 |
all_clips = self.layer.get_clips() |
| 498 |
self.assertEqual(len(all_clips), 4) |
| 499 |
clip1.edit([], self.layer.get_priority(), GES.EditMode.EDIT_RIPPLE, |
| 500 |
GES.Edge.EDGE_NONE, 41.5 * Gst.SECOND) |
| 501 |
self.assertEqual(len(self.layer.get_clips()), 4) |
| 502 |
clip1.edit([], self.layer.get_priority(), |
| 503 |
GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 35 * Gst.SECOND) |
| 504 |
self.assertEqual(len(self.layer.get_clips()), 4) |
| 505 |
|
| 506 |
def test_trim_transition(self): |
| 507 |
self.track_types = [GES.TrackType.AUDIO] |
| 508 |
super().setUp() |
| 509 |
|
| 510 |
self.timeline.props.auto_transition = True |
| 511 |
self.add_clip(0, 0, 10) |
| 512 |
self.add_clip(5, 0, 10) |
| 513 |
self.assertTimelineTopology([ |
| 514 |
[ # Unique layer |
| 515 |
(GES.TestClip, 0, 10), |
| 516 |
(GES.TransitionClip, 5, 5), |
| 517 |
(GES.TestClip, 5, 10), |
| 518 |
] |
| 519 |
]) |
| 520 |
transition = self.layer.get_clips()[1] |
| 521 |
self.assertTrue(transition.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 7)) |
| 522 |
|
| 523 |
self.assertTimelineTopology([ |
| 524 |
[ # Unique layer |
| 525 |
(GES.TestClip, 0, 10), |
| 526 |
(GES.TransitionClip, 7, 3), |
| 527 |
(GES.TestClip, 7, 8), |
| 528 |
] |
| 529 |
]) |
| 530 |
|
| 531 |
def test_trim_start(self): |
| 532 |
clip = self.append_clip() |
| 533 |
self.assertTrue(clip.edit([], -1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_START, 10)) |
| 534 |
self.assertTimelineTopology([ |
| 535 |
[ # Unique layer |
| 536 |
(GES.TestClip, 10, 10), |
| 537 |
] |
| 538 |
]) |
| 539 |
|
| 540 |
self.assertFalse(clip.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 0)) |
| 541 |
self.assertTimelineTopology([ |
| 542 |
[ # Unique layer |
| 543 |
(GES.TestClip, 10, 10), |
| 544 |
] |
| 545 |
]) |
| 546 |
|
| 547 |
def test_trim_non_core(self): |
| 548 |
clip = self.append_clip() |
| 549 |
self.assertTrue(clip.set_inpoint(12)) |
| 550 |
self.assertTrue(clip.set_max_duration(30)) |
| 551 |
self.assertEqual(clip.get_duration_limit(), 18) |
| 552 |
for child in clip.get_children(False): |
| 553 |
self.assertEqual(child.get_inpoint(), 12) |
| 554 |
self.assertEqual(child.get_max_duration(), 30) |
| 555 |
|
| 556 |
effect0 = GES.Effect.new("textoverlay") |
| 557 |
effect0.set_has_internal_source(True) |
| 558 |
self.assertTrue(effect0.set_inpoint(5)) |
| 559 |
self.assertTrue(effect0.set_max_duration(20)) |
| 560 |
self.assertTrue(clip.add(effect0)) |
| 561 |
self.assertEqual(clip.get_duration_limit(), 15) |
| 562 |
|
| 563 |
effect1 = GES.Effect.new("agingtv") |
| 564 |
effect1.set_has_internal_source(False) |
| 565 |
self.assertTrue(clip.add(effect1)) |
| 566 |
|
| 567 |
effect2 = GES.Effect.new("textoverlay") |
| 568 |
effect2.set_has_internal_source(True) |
| 569 |
self.assertTrue(effect2.set_inpoint(8)) |
| 570 |
self.assertTrue(effect2.set_max_duration(18)) |
| 571 |
self.assertTrue(clip.add(effect2)) |
| 572 |
self.assertEqual(clip.get_duration_limit(), 10) |
| 573 |
|
| 574 |
effect3 = GES.Effect.new("textoverlay") |
| 575 |
effect3.set_has_internal_source(True) |
| 576 |
self.assertTrue(effect3.set_inpoint(20)) |
| 577 |
self.assertTrue(effect3.set_max_duration(22)) |
| 578 |
self.assertTrue(effect3.set_active(False)) |
| 579 |
self.assertTrue(clip.add(effect3)) |
| 580 |
self.assertEqual(clip.get_duration_limit(), 10) |
| 581 |
|
| 582 |
self.assertTrue(clip.set_start(10)) |
| 583 |
self.assertTrue(clip.set_duration(10)) |
| 584 |
|
| 585 |
# cannot trim to a 0 because effect0 would have a negative in-point |
| 586 |
error = None |
| 587 |
try: |
| 588 |
clip.edit_full(-1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 0) |
| 589 |
except GLib.Error as err: |
| 590 |
error = err |
| 591 |
self.assertGESError(error, GES.Error.NEGATIVE_TIME) |
| 592 |
|
| 593 |
self.assertEqual(clip.start, 10) |
| 594 |
self.assertEqual(clip.inpoint, 12) |
| 595 |
self.assertEqual(effect0.inpoint, 5) |
| 596 |
self.assertEqual(effect1.inpoint, 0) |
| 597 |
self.assertEqual(effect2.inpoint, 8) |
| 598 |
self.assertEqual(effect3.inpoint, 20) |
| 599 |
|
| 600 |
self.assertTrue( |
| 601 |
clip.edit_full(-1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 5)) |
| 602 |
|
| 603 |
self.assertEqual(clip.start, 5) |
| 604 |
self.assertEqual(clip.duration, 15) |
| 605 |
self.assertEqual(clip.get_duration_limit(), 15) |
| 606 |
|
| 607 |
for child in clip.get_children(False): |
| 608 |
self.assertEqual(child.start, 5) |
| 609 |
self.assertEqual(child.duration, 15) |
| 610 |
|
| 611 |
self.assertEqual(clip.inpoint, 7) |
| 612 |
self.assertEqual(effect0.inpoint, 0) |
| 613 |
self.assertEqual(effect1.inpoint, 0) |
| 614 |
self.assertEqual(effect2.inpoint, 3) |
| 615 |
self.assertEqual(effect3.inpoint, 20) |
| 616 |
|
| 617 |
self.assertTrue( |
| 618 |
clip.edit_full(-1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 15)) |
| 619 |
|
| 620 |
self.assertEqual(clip.start, 15) |
| 621 |
self.assertEqual(clip.duration, 5) |
| 622 |
self.assertEqual(clip.get_duration_limit(), 5) |
| 623 |
|
| 624 |
for child in clip.get_children(False): |
| 625 |
self.assertEqual(child.start, 15) |
| 626 |
self.assertEqual(child.duration, 5) |
| 627 |
|
| 628 |
self.assertEqual(clip.inpoint, 17) |
| 629 |
self.assertEqual(effect0.inpoint, 10) |
| 630 |
self.assertEqual(effect1.inpoint, 0) |
| 631 |
self.assertEqual(effect2.inpoint, 13) |
| 632 |
self.assertEqual(effect3.inpoint, 20) |
| 633 |
|
| 634 |
def test_trim_time_effects(self): |
| 635 |
self.track_types = [GES.TrackType.VIDEO] |
| 636 |
super().setUp() |
| 637 |
clip = self.append_clip(asset_id="max-duration=30") |
| 638 |
self.assertTrue(clip.set_inpoint(12)) |
| 639 |
self.assertEqual(clip.get_duration_limit(), 18) |
| 640 |
|
| 641 |
children = clip.get_children(False) |
| 642 |
self.assertTrue(children) |
| 643 |
self.assertEqual(len(children), 1) |
| 644 |
|
| 645 |
source = children[0] |
| 646 |
self.assertEqual(source.get_inpoint(), 12) |
| 647 |
self.assertEqual(source.get_max_duration(), 30) |
| 648 |
|
| 649 |
rate0 = GES.Effect.new("videorate rate=0.25") |
| 650 |
|
| 651 |
overlay = GES.Effect.new("textoverlay") |
| 652 |
overlay.set_has_internal_source(True) |
| 653 |
self.assertTrue(overlay.set_inpoint(5)) |
| 654 |
self.assertTrue(overlay.set_max_duration(16)) |
| 655 |
|
| 656 |
rate1 = GES.Effect.new("videorate rate=2.0") |
| 657 |
|
| 658 |
self.assertTrue(clip.add(rate0)) |
| 659 |
self.assertTrue(clip.add(overlay)) |
| 660 |
self.assertTrue(clip.add(rate1)) |
| 661 |
|
| 662 |
# source -> rate1 -> overlay -> rate0 |
| 663 |
# in-point/max-dur 12-30 5-16 |
| 664 |
# internal |
| 665 |
# start/end 12-30 0-9 5-14 0-36 |
| 666 |
self.assertEqual(clip.get_duration_limit(), 36) |
| 667 |
self.assertTrue(clip.set_start(40)) |
| 668 |
self.assertTrue(clip.set_duration(10)) |
| 669 |
self.check_reload_timeline() |
| 670 |
|
| 671 |
# cannot trim to a 16 because overlay would have a negative in-point |
| 672 |
error = None |
| 673 |
try: |
| 674 |
clip.edit_full(-1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 16) |
| 675 |
except GLib.Error as err: |
| 676 |
error = err |
| 677 |
self.assertGESError(error, GES.Error.NEGATIVE_TIME) |
| 678 |
|
| 679 |
self.assertEqual(clip.get_start(), 40) |
| 680 |
self.assertEqual(clip.get_duration(), 10) |
| 681 |
self.assertEqual(source.get_inpoint(), 12) |
| 682 |
self.assertEqual(source.get_max_duration(), 30) |
| 683 |
self.assertEqual(overlay.get_inpoint(), 5) |
| 684 |
self.assertEqual(overlay.get_max_duration(), 16) |
| 685 |
|
| 686 |
self.check_reload_timeline() |
| 687 |
|
| 688 |
# trim backwards to 20 |
| 689 |
self.assertTrue( |
| 690 |
clip.edit_full(-1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 20)) |
| 691 |
|
| 692 |
self.assertEqual(clip.get_start(), 20) |
| 693 |
self.assertEqual(clip.get_duration(), 30) |
| 694 |
# reduced by 10 |
| 695 |
self.assertEqual(source.get_inpoint(), 2) |
| 696 |
self.assertEqual(source.get_max_duration(), 30) |
| 697 |
# reduced by 5 |
| 698 |
self.assertEqual(overlay.get_inpoint(), 0) |
| 699 |
self.assertEqual(overlay.get_max_duration(), 16) |
| 700 |
|
| 701 |
# trim forwards to 28 |
| 702 |
self.assertTrue( |
| 703 |
clip.edit_full(-1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 28)) |
| 704 |
self.assertEqual(clip.get_start(), 28) |
| 705 |
self.assertEqual(clip.get_duration(), 22) |
| 706 |
# increased by 4 |
| 707 |
self.assertEqual(source.get_inpoint(), 6) |
| 708 |
self.assertEqual(source.get_max_duration(), 30) |
| 709 |
# increased by 2 |
| 710 |
self.assertEqual(overlay.get_inpoint(), 2) |
| 711 |
self.assertEqual(overlay.get_max_duration(), 16) |
| 712 |
self.check_reload_timeline() |
| 713 |
|
| 714 |
def test_ripple_end(self): |
| 715 |
clip = self.append_clip() |
| 716 |
clip.set_max_duration(20) |
| 717 |
self.append_clip().set_max_duration(10) |
| 718 |
self.append_clip().set_max_duration(10) |
| 719 |
self.print_timeline() |
| 720 |
self.assertTrue(clip.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_END, 20)) |
| 721 |
self.assertTimelineTopology([ |
| 722 |
[ # Unique layer |
| 723 |
(GES.TestClip, 0, 20), |
| 724 |
(GES.TestClip, 20, 10), |
| 725 |
(GES.TestClip, 30, 10), |
| 726 |
] |
| 727 |
]) |
| 728 |
|
| 729 |
self.assertTrue(clip.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_END, 15)) |
| 730 |
self.assertTimelineTopology([ |
| 731 |
[ # Unique layer |
| 732 |
(GES.TestClip, 0, 15), |
| 733 |
(GES.TestClip, 15, 10), |
| 734 |
(GES.TestClip, 25, 10), |
| 735 |
] |
| 736 |
]) |
| 737 |
|
| 738 |
def test_move_group_full_overlap(self): |
| 739 |
self.track_types = [GES.TrackType.AUDIO] |
| 740 |
super().setUp() |
| 741 |
|
| 742 |
for _ in range(4): |
| 743 |
self.append_clip() |
| 744 |
clips = self.layer.get_clips() |
| 745 |
|
| 746 |
self.assertTrue(clips[0].ripple(20)) |
| 747 |
self.assertTimelineTopology([ |
| 748 |
[ |
| 749 |
(GES.TestClip, 20, 10), |
| 750 |
(GES.TestClip, 30, 10), |
| 751 |
(GES.TestClip, 40, 10), |
| 752 |
(GES.TestClip, 50, 10), |
| 753 |
] |
| 754 |
]) |
| 755 |
group = GES.Container.group(clips[1:]) |
| 756 |
self.print_timeline() |
| 757 |
self.assertFalse(group.edit([], -1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 0)) |
| 758 |
self.print_timeline() |
| 759 |
self.assertTimelineTopology([ |
| 760 |
[ |
| 761 |
(GES.TestClip, 20, 10), |
| 762 |
(GES.TestClip, 30, 10), |
| 763 |
(GES.TestClip, 40, 10), |
| 764 |
(GES.TestClip, 50, 10), |
| 765 |
] |
| 766 |
]) |
| 767 |
|
| 768 |
self.assertFalse(clips[1].edit([], -1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 0)) |
| 769 |
self.print_timeline() |
| 770 |
self.assertTimelineTopology([ |
| 771 |
[ |
| 772 |
(GES.TestClip, 20, 10), |
| 773 |
(GES.TestClip, 30, 10), |
| 774 |
(GES.TestClip, 40, 10), |
| 775 |
(GES.TestClip, 50, 10), |
| 776 |
] |
| 777 |
]) |
| 778 |
|
| 779 |
def test_trim_inside_group(self): |
| 780 |
self.track_types = [GES.TrackType.AUDIO] |
| 781 |
super().setUp() |
| 782 |
|
| 783 |
for _ in range(2): |
| 784 |
self.append_clip() |
| 785 |
clips = self.layer.get_clips() |
| 786 |
group = GES.Container.group(clips) |
| 787 |
self.assertTimelineTopology([ |
| 788 |
[ # Unique layer |
| 789 |
(GES.TestClip, 0, 10), |
| 790 |
(GES.TestClip, 10, 10), |
| 791 |
] |
| 792 |
]) |
| 793 |
self.assertEqual(group.props.start, 0) |
| 794 |
self.assertEqual(group.props.duration, 20) |
| 795 |
|
| 796 |
clips[0].trim(5) |
| 797 |
self.assertTimelineTopology([ |
| 798 |
[ # Unique layer |
| 799 |
(GES.TestClip, 5, 5), |
| 800 |
(GES.TestClip, 10, 10), |
| 801 |
] |
| 802 |
]) |
| 803 |
self.assertEqual(group.props.start, 5) |
| 804 |
self.assertEqual(group.props.duration, 15) |
| 805 |
|
| 806 |
group1 = GES.Group.new () |
| 807 |
group1.add(group) |
| 808 |
clips[0].trim(0) |
| 809 |
self.assertTimelineTopology([ |
| 810 |
[ # Unique layer |
| 811 |
(GES.TestClip, 0, 10), |
| 812 |
(GES.TestClip, 10, 10), |
| 813 |
] |
| 814 |
]) |
| 815 |
self.assertEqual(group.props.start, 0) |
| 816 |
self.assertEqual(group.props.duration, 20) |
| 817 |
self.assertEqual(group1.props.start, 0) |
| 818 |
self.assertEqual(group1.props.duration, 20) |
| 819 |
|
| 820 |
self.assertTrue(clips[1].edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 15)) |
| 821 |
self.assertTimelineTopology([ |
| 822 |
[ # Unique layer |
| 823 |
(GES.TestClip, 0, 10), |
| 824 |
(GES.TestClip, 10, 5), |
| 825 |
] |
| 826 |
]) |
| 827 |
self.assertEqual(group.props.start, 0) |
| 828 |
self.assertEqual(group.props.duration, 15) |
| 829 |
self.assertEqual(group1.props.start, 0) |
| 830 |
self.assertEqual(group1.props.duration, 15) |
| 831 |
|
| 832 |
def test_trim_end_past_max_duration(self): |
| 833 |
clip = self.append_clip() |
| 834 |
max_duration = clip.props.duration |
| 835 |
clip.set_max_duration(max_duration) |
| 836 |
self.assertTrue(clip.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 5)) |
| 837 |
self.assertTimelineTopology([ |
| 838 |
[ # Unique layer |
| 839 |
(GES.TestClip, 5, 5), |
| 840 |
] |
| 841 |
]) |
| 842 |
|
| 843 |
self.assertFalse(clip.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 15)) |
| 844 |
self.assertTimelineTopology([ |
| 845 |
[ # Unique layer |
| 846 |
(GES.TestClip, 5, 5), |
| 847 |
] |
| 848 |
]) |
| 849 |
|
| 850 |
def test_illegal_effect_move(self): |
| 851 |
c0 = self.append_clip() |
| 852 |
self.append_clip() |
| 853 |
self.assertTimelineTopology([ |
| 854 |
[ |
| 855 |
(GES.TestClip, 0, 10), |
| 856 |
(GES.TestClip, 10, 10), |
| 857 |
] |
| 858 |
]) |
| 859 |
|
| 860 |
effect = GES.Effect.new("agingtv") |
| 861 |
c0.add(effect) |
| 862 |
self.assertTimelineTopology([ |
| 863 |
[ |
| 864 |
(GES.TestClip, 0, 10), |
| 865 |
(GES.TestClip, 10, 10), |
| 866 |
] |
| 867 |
]) |
| 868 |
|
| 869 |
self.assertFalse(effect.set_start(10)) |
| 870 |
self.assertEqual(effect.props.start, 0) |
| 871 |
self.assertTimelineTopology([ |
| 872 |
[ |
| 873 |
(GES.TestClip, 0, 10), |
| 874 |
(GES.TestClip, 10, 10), |
| 875 |
] |
| 876 |
]) |
| 877 |
|
| 878 |
|
| 879 |
self.assertFalse(effect.set_duration(20)) |
| 880 |
self.assertEqual(effect.props.duration, 10) |
| 881 |
self.assertTimelineTopology([ |
| 882 |
[ |
| 883 |
(GES.TestClip, 0, 10), |
| 884 |
(GES.TestClip, 10, 10), |
| 885 |
] |
| 886 |
]) |
| 887 |
|
| 888 |
def test_moving_overlay_clip_in_group(self): |
| 889 |
c0 = self.append_clip() |
| 890 |
overlay = self.append_clip(asset_type=GES.TextOverlayClip) |
| 891 |
group = GES.Group.new() |
| 892 |
group.add(c0) |
| 893 |
group.add(overlay) |
| 894 |
|
| 895 |
self.assertTimelineTopology([ |
| 896 |
[ |
| 897 |
(GES.TestClip, 0, 10), |
| 898 |
(GES.TextOverlayClip, 10, 10), |
| 899 |
] |
| 900 |
], groups=[(c0, overlay)]) |
| 901 |
|
| 902 |
self.assertTrue(overlay.set_start(20)) |
| 903 |
self.assertTimelineTopology([ |
| 904 |
[ |
| 905 |
(GES.TestClip, 10, 10), |
| 906 |
(GES.TextOverlayClip, 20, 10), |
| 907 |
] |
| 908 |
], groups=[(c0, overlay)]) |
| 909 |
|
| 910 |
def test_moving_group_in_group(self): |
| 911 |
c0 = self.append_clip() |
| 912 |
overlay = self.append_clip(asset_type=GES.TextOverlayClip) |
| 913 |
group0 = GES.Group.new() |
| 914 |
group0.add(c0) |
| 915 |
group0.add(overlay) |
| 916 |
|
| 917 |
c1 = self.append_clip() |
| 918 |
group1 = GES.Group.new() |
| 919 |
group1.add(group0) |
| 920 |
group1.add(c1) |
| 921 |
|
| 922 |
self.assertTimelineTopology([ |
| 923 |
[ |
| 924 |
(GES.TestClip, 0, 10), |
| 925 |
(GES.TextOverlayClip, 10, 10), |
| 926 |
(GES.TestClip, 20, 10), |
| 927 |
] |
| 928 |
], groups=[(c1, group0), (c0, overlay)]) |
| 929 |
|
| 930 |
self.assertTrue(group0.set_start(10)) |
| 931 |
self.assertTimelineTopology([ |
| 932 |
[ |
| 933 |
(GES.TestClip, 10, 10), |
| 934 |
(GES.TextOverlayClip, 20, 10), |
| 935 |
(GES.TestClip, 30, 10), |
| 936 |
] |
| 937 |
], groups=[(c1, group0), (c0, overlay)]) |
| 938 |
self.check_element_values(group0, 10, 0, 20) |
| 939 |
self.check_element_values(group1, 10, 0, 30) |
| 940 |
|
| 941 |
def test_illegal_group_child_move(self): |
| 942 |
clip0 = self.append_clip() |
| 943 |
_clip1 = self.add_clip(20, 0, 10) |
| 944 |
overlay = self.add_clip(20, 0, 10, asset_type=GES.TextOverlayClip) |
| 945 |
|
| 946 |
group = GES.Group.new() |
| 947 |
group.add(clip0) |
| 948 |
group.add(overlay) |
| 949 |
|
| 950 |
self.assertTimelineTopology([ |
| 951 |
[ |
| 952 |
(GES.TestClip, 0, 10), |
| 953 |
(GES.TextOverlayClip, 20, 10), |
| 954 |
(GES.TestClip, 20, 10), |
| 955 |
] |
| 956 |
], groups=[(clip0, overlay),]) |
| 957 |
|
| 958 |
# Can't move as clip0 and clip1 would fully overlap |
| 959 |
self.assertFalse(overlay.set_start(40)) |
| 960 |
self.assertTimelineTopology([ |
| 961 |
[ |
| 962 |
(GES.TestClip, 0, 10), |
| 963 |
(GES.TextOverlayClip, 20, 10), |
| 964 |
(GES.TestClip, 20, 10), |
| 965 |
] |
| 966 |
], groups=[(clip0, overlay)]) |
| 967 |
|
| 968 |
def test_child_duration_change(self): |
| 969 |
c0 = self.append_clip() |
| 970 |
|
| 971 |
self.assertTimelineTopology([ |
| 972 |
[ |
| 973 |
(GES.TestClip, 0, 10), |
| 974 |
] |
| 975 |
]) |
| 976 |
self.assertTrue(c0.set_duration(40)) |
| 977 |
self.assertTimelineTopology([ |
| 978 |
[ |
| 979 |
(GES.TestClip, 0, 40), |
| 980 |
] |
| 981 |
]) |
| 982 |
|
| 983 |
c0.children[0].set_duration(10) |
| 984 |
self.assertTimelineTopology([ |
| 985 |
[ |
| 986 |
(GES.TestClip, 0, 10), |
| 987 |
] |
| 988 |
]) |
| 989 |
|
| 990 |
self.assertTrue(c0.set_start(40)) |
| 991 |
self.assertTimelineTopology([ |
| 992 |
[ |
| 993 |
(GES.TestClip, 40, 10), |
| 994 |
] |
| 995 |
]) |
| 996 |
|
| 997 |
c0.children[0].set_start(10) |
| 998 |
self.assertTimelineTopology([ |
| 999 |
[ |
| 1000 |
(GES.TestClip, 10, 10), |
| 1001 |
] |
| 1002 |
]) |
| 1003 |
|
| 1004 |
|
| 1005 |
class TestInvalidOverlaps(common.GESSimpleTimelineTest): |
| 1006 |
|
| 1007 |
def test_adding_or_moving(self): |
| 1008 |
clip1 = self.add_clip(start=10, in_point=0, duration=3) |
| 1009 |
self.assertIsNotNone(clip1) |
| 1010 |
|
| 1011 |
def check_add_move_clip(start, duration): |
| 1012 |
self.timeline.props.auto_transition = True |
| 1013 |
self.layer.props.auto_transition = True |
| 1014 |
clip2 = GES.TestClip() |
| 1015 |
clip2.props.start = start |
| 1016 |
clip2.props.duration = duration |
| 1017 |
self.assertFalse(self.layer.add_clip(clip2)) |
| 1018 |
self.assertEqual(len(self.layer.get_clips()), 1) |
| 1019 |
|
| 1020 |
# Add the clip at a different position. |
| 1021 |
clip2.props.start = 25 |
| 1022 |
self.assertTrue(self.layer.add_clip(clip2)) |
| 1023 |
self.assertEqual(clip2.props.start, 25) |
| 1024 |
|
| 1025 |
# Try to move the second clip by editing it. |
| 1026 |
self.assertFalse(clip2.edit([], -1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, start)) |
| 1027 |
self.assertEqual(clip2.props.start, 25) |
| 1028 |
|
| 1029 |
# Try to put it in a group and move the group. |
| 1030 |
clip3 = GES.TestClip() |
| 1031 |
clip3.props.start = 20 |
| 1032 |
clip3.props.duration = 1 |
| 1033 |
self.assertTrue(self.layer.add_clip(clip3)) |
| 1034 |
group = GES.Container.group([clip3, clip2]) |
| 1035 |
self.assertTrue(group.props.start, 20) |
| 1036 |
self.assertFalse(group.edit([], -1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, start - 5)) |
| 1037 |
self.assertEqual(group.props.start, 20) |
| 1038 |
self.assertEqual(clip3.props.start, 20) |
| 1039 |
self.assertEqual(clip2.props.start, 25) |
| 1040 |
|
| 1041 |
for clip in group.ungroup(False): |
| 1042 |
self.assertTrue(self.layer.remove_clip(clip)) |
| 1043 |
|
| 1044 |
# clip1 contains... |
| 1045 |
check_add_move_clip(start=10, duration=1) |
| 1046 |
check_add_move_clip(start=11, duration=1) |
| 1047 |
check_add_move_clip(start=12, duration=1) |
| 1048 |
|
| 1049 |
def test_splitting(self): |
| 1050 |
clip1 = self.add_clip(start=9, in_point=0, duration=3) |
| 1051 |
clip2 = self.add_clip(start=10, in_point=0, duration=4) |
| 1052 |
clip3 = self.add_clip(start=12, in_point=0, duration=3) |
| 1053 |
|
| 1054 |
self.assertIsNone(clip1.split_full(13)) |
| 1055 |
self.assertIsNone(clip1.split_full(8)) |
| 1056 |
self.assertIsNone(clip3.split_full(12)) |
| 1057 |
self.assertIsNone(clip3.split_full(15)) |
| 1058 |
|
| 1059 |
def _fail_split(self, clip, position): |
| 1060 |
split = None |
| 1061 |
error = None |
| 1062 |
try: |
| 1063 |
split = clip.split_full(position) |
| 1064 |
except GLib.Error as err: |
| 1065 |
error = err |
| 1066 |
self.assertGESError(error, GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1067 |
self.assertIsNone(split) |
| 1068 |
|
| 1069 |
def test_split_with_transition(self): |
| 1070 |
self.track_types = [GES.TrackType.AUDIO] |
| 1071 |
super().setUp() |
| 1072 |
self.timeline.set_auto_transition(True) |
| 1073 |
|
| 1074 |
clip0 = self.add_clip(start=0, in_point=0, duration=50) |
| 1075 |
clip1 = self.add_clip(start=20, in_point=0, duration=50) |
| 1076 |
clip2 = self.add_clip(start=60, in_point=0, duration=20) |
| 1077 |
self.assertTimelineTopology([ |
| 1078 |
[ |
| 1079 |
(GES.TestClip, 0, 50), |
| 1080 |
(GES.TransitionClip, 20, 30), |
| 1081 |
(GES.TestClip, 20, 50), |
| 1082 |
(GES.TransitionClip, 60, 10), |
| 1083 |
(GES.TestClip, 60, 20), |
| 1084 |
] |
| 1085 |
]) |
| 1086 |
|
| 1087 |
# Split should fail as the first part of the split |
| 1088 |
# would be fully overlapping clip0 |
| 1089 |
self._fail_split(clip1, 40) |
| 1090 |
|
| 1091 |
self.assertTimelineTopology([ |
| 1092 |
[ |
| 1093 |
(GES.TestClip, 0, 50), |
| 1094 |
(GES.TransitionClip, 20, 30), |
| 1095 |
(GES.TestClip, 20, 50), |
| 1096 |
(GES.TransitionClip, 60, 10), |
| 1097 |
(GES.TestClip, 60, 20), |
| 1098 |
] |
| 1099 |
]) |
| 1100 |
|
| 1101 |
# same with end of the clip |
| 1102 |
self._fail_split(clip1, 65) |
| 1103 |
|
| 1104 |
self.assertTimelineTopology([ |
| 1105 |
[ |
| 1106 |
(GES.TestClip, 0, 50), |
| 1107 |
(GES.TransitionClip, 20, 30), |
| 1108 |
(GES.TestClip, 20, 50), |
| 1109 |
(GES.TransitionClip, 60, 10), |
| 1110 |
(GES.TestClip, 60, 20), |
| 1111 |
] |
| 1112 |
]) |
| 1113 |
|
| 1114 |
def test_changing_duration(self): |
| 1115 |
clip1 = self.add_clip(start=9, in_point=0, duration=2) |
| 1116 |
clip2 = self.add_clip(start=10, in_point=0, duration=2) |
| 1117 |
|
| 1118 |
self.assertFalse(clip1.set_start(10)) |
| 1119 |
self.assertFalse(clip1.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, clip2.props.start + clip2.props.duration)) |
| 1120 |
self.assertFalse(clip1.ripple_end(clip2.props.start + clip2.props.duration)) |
| 1121 |
self.assertFalse(clip1.roll_end(clip2.props.start + clip2.props.duration)) |
| 1122 |
|
| 1123 |
# clip2's end edge to the left, to decrease its duration. |
| 1124 |
self.assertFalse(clip2.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, clip1.props.start + clip1.props.duration)) |
| 1125 |
self.assertFalse(clip2.ripple_end(clip1.props.start + clip1.props.duration)) |
| 1126 |
self.assertFalse(clip2.roll_end(clip1.props.start + clip1.props.duration)) |
| 1127 |
|
| 1128 |
# clip2's start edge to the left, to increase its duration. |
| 1129 |
self.assertFalse(clip2.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, clip1.props.start)) |
| 1130 |
self.assertFalse(clip2.trim(clip1.props.start)) |
| 1131 |
|
| 1132 |
# clip1's start edge to the right, to decrease its duration. |
| 1133 |
self.assertFalse(clip1.edit([], -1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, clip2.props.start)) |
| 1134 |
self.assertFalse(clip1.trim(clip2.props.start)) |
| 1135 |
|
| 1136 |
def test_rippling_backward(self): |
| 1137 |
self.track_types = [GES.TrackType.AUDIO] |
| 1138 |
super().setUp() |
| 1139 |
self.maxDiff = None |
| 1140 |
for i in range(4): |
| 1141 |
self.append_clip() |
| 1142 |
self.assertTimelineTopology([ |
| 1143 |
[ # Unique layer |
| 1144 |
(GES.TestClip, 0, 10), |
| 1145 |
(GES.TestClip, 10, 10), |
| 1146 |
(GES.TestClip, 20, 10), |
| 1147 |
(GES.TestClip, 30, 10), |
| 1148 |
] |
| 1149 |
]) |
| 1150 |
|
| 1151 |
clip = self.layer.get_clips()[2] |
| 1152 |
self.assertFalse(clip.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, clip.props.start - 20)) |
| 1153 |
self.assertTimelineTopology([ |
| 1154 |
[ # Unique layer |
| 1155 |
(GES.TestClip, 0, 10), |
| 1156 |
(GES.TestClip, 10, 10), |
| 1157 |
(GES.TestClip, 20, 10), |
| 1158 |
(GES.TestClip, 30, 10), |
| 1159 |
] |
| 1160 |
]) |
| 1161 |
self.assertTrue(clip.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, clip.props.start + 10)) |
| 1162 |
|
| 1163 |
self.assertTimelineTopology([ |
| 1164 |
[ # Unique layer |
| 1165 |
(GES.TestClip, 0, 10), |
| 1166 |
(GES.TestClip, 10, 10), |
| 1167 |
(GES.TestClip, 30, 10), |
| 1168 |
(GES.TestClip, 40, 10), |
| 1169 |
] |
| 1170 |
]) |
| 1171 |
|
| 1172 |
self.assertFalse(clip.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, clip.props.start -20)) |
| 1173 |
self.assertTimelineTopology([ |
| 1174 |
[ # Unique layer |
| 1175 |
(GES.TestClip, 0, 10), |
| 1176 |
(GES.TestClip, 10, 10), |
| 1177 |
(GES.TestClip, 30, 10), |
| 1178 |
(GES.TestClip, 40, 10), |
| 1179 |
] |
| 1180 |
]) |
| 1181 |
|
| 1182 |
def test_rolling(self): |
| 1183 |
clip1 = self.add_clip(start=9, in_point=0, duration=2) |
| 1184 |
clip2 = self.add_clip(start=10, in_point=0, duration=2) |
| 1185 |
clip3 = self.add_clip(start=11, in_point=0, duration=2) |
| 1186 |
|
| 1187 |
# Rolling clip1's end -1 would lead to clip3 to overlap 100% with clip2. |
| 1188 |
self.assertTimelineTopology([ |
| 1189 |
[ # Unique layer |
| 1190 |
(GES.TestClip, 9, 2), |
| 1191 |
(GES.TestClip, 10, 2), |
| 1192 |
(GES.TestClip, 11, 2) |
| 1193 |
] |
| 1194 |
]) |
| 1195 |
self.assertFalse(clip1.edit([], -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, clip1.props.start + clip1.props.duration - 1)) |
| 1196 |
self.assertFalse(clip1.roll_end(13)) |
| 1197 |
self.assertTimelineTopology([ |
| 1198 |
[ # Unique layer |
| 1199 |
(GES.TestClip, 9, 2), |
| 1200 |
(GES.TestClip, 10, 2), |
| 1201 |
(GES.TestClip, 11, 2) |
| 1202 |
] |
| 1203 |
]) |
| 1204 |
|
| 1205 |
# Rolling clip3's start +1 would lead to clip1 to overlap 100% with clip2. |
| 1206 |
self.assertFalse(clip3.edit([], -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 12)) |
| 1207 |
self.assertTimelineTopology([ |
| 1208 |
[ # Unique layer |
| 1209 |
(GES.TestClip, 9, 2), |
| 1210 |
(GES.TestClip, 10, 2), |
| 1211 |
(GES.TestClip, 11, 2) |
| 1212 |
] |
| 1213 |
]) |
| 1214 |
|
| 1215 |
def test_layers(self): |
| 1216 |
self.track_types = [GES.TrackType.AUDIO] |
| 1217 |
super().setUp() |
| 1218 |
self.maxDiff = None |
| 1219 |
self.timeline.append_layer() |
| 1220 |
|
| 1221 |
for i in range(2): |
| 1222 |
self.append_clip() |
| 1223 |
self.append_clip(1) |
| 1224 |
|
| 1225 |
self.assertTimelineTopology([ |
| 1226 |
[ |
| 1227 |
(GES.TestClip, 0, 10), |
| 1228 |
(GES.TestClip, 10, 10), |
| 1229 |
], |
| 1230 |
[ |
| 1231 |
(GES.TestClip, 0, 10), |
| 1232 |
(GES.TestClip, 10, 10), |
| 1233 |
] |
| 1234 |
]) |
| 1235 |
|
| 1236 |
clip = self.layer.get_clips()[0] |
| 1237 |
self.assertFalse(clip.edit([], 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 0)) |
| 1238 |
self.assertTimelineTopology([ |
| 1239 |
[ |
| 1240 |
(GES.TestClip, 0, 10), |
| 1241 |
(GES.TestClip, 10, 10), |
| 1242 |
], |
| 1243 |
[ |
| 1244 |
(GES.TestClip, 0, 10), |
| 1245 |
(GES.TestClip, 10, 10), |
| 1246 |
] |
| 1247 |
]) |
| 1248 |
|
| 1249 |
def test_rippling(self): |
| 1250 |
self.timeline.remove_track(self.timeline.get_tracks()[0]) |
| 1251 |
clip1 = self.add_clip(start=9, in_point=0, duration=2) |
| 1252 |
clip2 = self.add_clip(start=10, in_point=0, duration=2) |
| 1253 |
clip3 = self.add_clip(start=11, in_point=0, duration=2) |
| 1254 |
|
| 1255 |
# Rippling clip2's start -2 would bring clip3 exactly on top of clip1. |
| 1256 |
self.assertFalse(clip2.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 8)) |
| 1257 |
self.assertFalse(clip2.ripple(8)) |
| 1258 |
|
| 1259 |
# Rippling clip1's end -1 would bring clip3 exactly on top of clip2. |
| 1260 |
self.assertFalse(clip1.edit([], -1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_END, 8)) |
| 1261 |
self.assertFalse(clip1.ripple_end(8)) |
| 1262 |
|
| 1263 |
def test_move_group_to_layer(self): |
| 1264 |
self.track_types = [GES.TrackType.AUDIO] |
| 1265 |
super().setUp() |
| 1266 |
self.append_clip() |
| 1267 |
self.append_clip() |
| 1268 |
self.append_clip() |
| 1269 |
|
| 1270 |
clips = self.layer.get_clips() |
| 1271 |
|
| 1272 |
clips[1].props.start += 2 |
| 1273 |
group = GES.Container.group(clips[1:]) |
| 1274 |
self.assertTrue(clips[1].edit([], 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, |
| 1275 |
group.props.start)) |
| 1276 |
|
| 1277 |
self.assertTimelineTopology([ |
| 1278 |
[ |
| 1279 |
(GES.TestClip, 0, 10), |
| 1280 |
], |
| 1281 |
[ |
| 1282 |
(GES.TestClip, 12, 10), |
| 1283 |
(GES.TestClip, 20, 10), |
| 1284 |
] |
| 1285 |
]) |
| 1286 |
|
| 1287 |
clips[0].props.start = 15 |
| 1288 |
self.assertTimelineTopology([ |
| 1289 |
[ |
| 1290 |
(GES.TestClip, 15, 10), |
| 1291 |
], |
| 1292 |
[ |
| 1293 |
(GES.TestClip, 12, 10), |
| 1294 |
(GES.TestClip, 20, 10), |
| 1295 |
] |
| 1296 |
]) |
| 1297 |
|
| 1298 |
self.assertFalse(clips[1].edit([], 0, GES.EditMode.EDIT_NORMAL, |
| 1299 |
GES.Edge.EDGE_NONE, group.props.start)) |
| 1300 |
self.assertTimelineTopology([ |
| 1301 |
[ |
| 1302 |
(GES.TestClip, 15, 10), |
| 1303 |
], |
| 1304 |
[ |
| 1305 |
(GES.TestClip, 12, 10), |
| 1306 |
(GES.TestClip, 20, 10), |
| 1307 |
] |
| 1308 |
]) |
| 1309 |
|
| 1310 |
def test_copy_paste_overlapping(self): |
| 1311 |
self.track_types = [GES.TrackType.AUDIO] |
| 1312 |
super().setUp() |
| 1313 |
clip = self.append_clip() |
| 1314 |
|
| 1315 |
copy = clip.copy(True) |
| 1316 |
self.assertIsNone(copy.paste(copy.props.start)) |
| 1317 |
self.assertTimelineTopology([ |
| 1318 |
[ |
| 1319 |
(GES.TestClip, 0, 10), |
| 1320 |
|
| 1321 |
] |
| 1322 |
]) |
| 1323 |
copy = clip.copy(True) |
| 1324 |
pasted = copy.paste(copy.props.start + 1) |
| 1325 |
self.assertTimelineTopology([ |
| 1326 |
[ |
| 1327 |
(GES.TestClip, 0, 10), |
| 1328 |
(GES.TestClip, 1, 10), |
| 1329 |
] |
| 1330 |
]) |
| 1331 |
|
| 1332 |
pasted.move_to_layer(self.timeline.append_layer()) |
| 1333 |
self.assertTimelineTopology([ |
| 1334 |
[ |
| 1335 |
(GES.TestClip, 0, 10), |
| 1336 |
], |
| 1337 |
[ |
| 1338 |
(GES.TestClip, 1, 10), |
| 1339 |
] |
| 1340 |
]) |
| 1341 |
|
| 1342 |
copy = pasted.copy(True) |
| 1343 |
self.assertIsNotNone(copy.paste(pasted.props.start - 1)) |
| 1344 |
self.assertTimelineTopology([ |
| 1345 |
[ |
| 1346 |
(GES.TestClip, 0, 10), |
| 1347 |
], |
| 1348 |
[ |
| 1349 |
(GES.TestClip, 0, 10), |
| 1350 |
(GES.TestClip, 1, 10), |
| 1351 |
], |
| 1352 |
]) |
| 1353 |
|
| 1354 |
group = GES.Group.new() |
| 1355 |
group.add(clip) |
| 1356 |
|
| 1357 |
copied_group = group.copy(True) |
| 1358 |
self.assertFalse(copied_group.paste(group.props.start)) |
| 1359 |
self.assertTimelineTopology([ |
| 1360 |
[ |
| 1361 |
(GES.TestClip, 0, 10), |
| 1362 |
], |
| 1363 |
[ |
| 1364 |
(GES.TestClip, 0, 10), |
| 1365 |
(GES.TestClip, 1, 10), |
| 1366 |
], |
| 1367 |
]) |
| 1368 |
|
| 1369 |
def test_move_group_with_overlaping_clips(self): |
| 1370 |
self.track_types = [GES.TrackType.AUDIO] |
| 1371 |
super().setUp() |
| 1372 |
self.append_clip() |
| 1373 |
self.append_clip() |
| 1374 |
self.append_clip() |
| 1375 |
|
| 1376 |
self.timeline.props.auto_transition = True |
| 1377 |
clips = self.layer.get_clips() |
| 1378 |
|
| 1379 |
clips[1].props.start += 5 |
| 1380 |
group = GES.Container.group(clips[1:]) |
| 1381 |
self.assertTimelineTopology([ |
| 1382 |
[ |
| 1383 |
(GES.TestClip, 0, 10), |
| 1384 |
(GES.TestClip, 15, 10), |
| 1385 |
(GES.TransitionClip, 20, 5), |
| 1386 |
(GES.TestClip, 20, 10), |
| 1387 |
] |
| 1388 |
]) |
| 1389 |
|
| 1390 |
clips[0].props.start = 30 |
| 1391 |
self.assertTimelineTopology([ |
| 1392 |
[ |
| 1393 |
(GES.TestClip, 15, 10), |
| 1394 |
(GES.TransitionClip, 20, 5), |
| 1395 |
(GES.TestClip, 20, 10), |
| 1396 |
(GES.TestClip, 30, 10), |
| 1397 |
] |
| 1398 |
]) |
| 1399 |
|
| 1400 |
# the 3 clips would overlap |
| 1401 |
self.assertFalse(clips[1].edit([], 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 25)) |
| 1402 |
self.assertTimelineTopology([ |
| 1403 |
[ |
| 1404 |
(GES.TestClip, 15, 10), |
| 1405 |
(GES.TransitionClip, 20, 5), |
| 1406 |
(GES.TestClip, 20, 10), |
| 1407 |
(GES.TestClip, 30, 10), |
| 1408 |
] |
| 1409 |
]) |
| 1410 |
|
| 1411 |
|
| 1412 |
class TestConfigurationRules(common.GESSimpleTimelineTest): |
| 1413 |
|
| 1414 |
def _try_add_clip(self, start, duration, layer=None, error=None): |
| 1415 |
if layer is None: |
| 1416 |
layer = self.layer |
| 1417 |
asset = GES.Asset.request(GES.TestClip, None) |
| 1418 |
found_err = None |
| 1419 |
clip = None |
| 1420 |
# large inpoint to allow trims |
| 1421 |
try: |
| 1422 |
clip = layer.add_asset_full( |
| 1423 |
asset, start, 1000, duration, GES.TrackType.UNKNOWN) |
| 1424 |
except GLib.Error as err: |
| 1425 |
found_err = err |
| 1426 |
if error is None: |
| 1427 |
self.assertIsNotNone(clip) |
| 1428 |
else: |
| 1429 |
self.assertIsNone(clip) |
| 1430 |
self.assertGESError(found_err, error) |
| 1431 |
return clip |
| 1432 |
|
| 1433 |
def test_full_overlap_add(self): |
| 1434 |
clip1 = self._try_add_clip(50, 50) |
| 1435 |
self._try_add_clip(50, 50, error=GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1436 |
self._try_add_clip(49, 51, error=GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1437 |
self._try_add_clip(51, 49, error=GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1438 |
|
| 1439 |
def test_triple_overlap_add(self): |
| 1440 |
clip1 = self._try_add_clip(0, 50) |
| 1441 |
clip2 = self._try_add_clip(40, 50) |
| 1442 |
self._try_add_clip(39, 12, error=GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1443 |
self._try_add_clip(30, 30, error=GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1444 |
self._try_add_clip(1, 88, error=GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1445 |
|
| 1446 |
def test_full_overlap_move(self): |
| 1447 |
clip1 = self._try_add_clip(0, 50) |
| 1448 |
clip2 = self._try_add_clip(50, 50) |
| 1449 |
self.assertFalse(clip2.set_start(0)) |
| 1450 |
|
| 1451 |
def test_triple_overlap_move(self): |
| 1452 |
clip1 = self._try_add_clip(0, 50) |
| 1453 |
clip2 = self._try_add_clip(40, 50) |
| 1454 |
clip3 = self._try_add_clip(100, 60) |
| 1455 |
self.assertFalse(clip3.set_start(30)) |
| 1456 |
|
| 1457 |
def test_full_overlap_move_into_layer(self): |
| 1458 |
clip1 = self._try_add_clip(0, 50) |
| 1459 |
layer2 = self.timeline.append_layer() |
| 1460 |
clip2 = self._try_add_clip(0, 50, layer2) |
| 1461 |
res = None |
| 1462 |
try: |
| 1463 |
res = clip2.move_to_layer_full(self.layer) |
| 1464 |
except GLib.Error as error: |
| 1465 |
self.assertGESError(error, GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1466 |
self.assertIsNone(res) |
| 1467 |
|
| 1468 |
def test_triple_overlap_move_into_layer(self): |
| 1469 |
clip1 = self._try_add_clip(0, 50) |
| 1470 |
clip2 = self._try_add_clip(40, 50) |
| 1471 |
layer2 = self.timeline.append_layer() |
| 1472 |
clip3 = self._try_add_clip(30, 30, layer2) |
| 1473 |
res = None |
| 1474 |
try: |
| 1475 |
res = clip3.move_to_layer_full(self.layer) |
| 1476 |
except GLib.Error as error: |
| 1477 |
self.assertGESError(error, GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1478 |
self.assertIsNone(res) |
| 1479 |
|
| 1480 |
def test_full_overlap_trim(self): |
| 1481 |
clip1 = self._try_add_clip(0, 50) |
| 1482 |
clip2 = self._try_add_clip(50, 50) |
| 1483 |
self.assertFalse(clip2.trim(0)) |
| 1484 |
self.assertFalse(clip1.set_duration(100)) |
| 1485 |
|
| 1486 |
def test_triple_overlap_trim(self): |
| 1487 |
clip1 = self._try_add_clip(0, 20) |
| 1488 |
clip2 = self._try_add_clip(10, 30) |
| 1489 |
clip3 = self._try_add_clip(30, 20) |
| 1490 |
self.assertFalse(clip3.trim(19)) |
| 1491 |
self.assertFalse(clip1.set_duration(31)) |
| 1492 |
|
| 1493 |
class TestSnapping(common.GESSimpleTimelineTest): |
| 1494 |
|
| 1495 |
def test_snapping(self): |
| 1496 |
self.timeline.props.auto_transition = True |
| 1497 |
self.timeline.set_snapping_distance(1) |
| 1498 |
clip1 = self.add_clip(0, 0, 100) |
| 1499 |
|
| 1500 |
# Split clip1. |
| 1501 |
split_position = 50 |
| 1502 |
clip2 = clip1.split(split_position) |
| 1503 |
self.assertEqual(len(self.layer.get_clips()), 2) |
| 1504 |
self.assertEqual(clip1.props.duration, split_position) |
| 1505 |
self.assertEqual(clip2.props.start, split_position) |
| 1506 |
|
| 1507 |
# Make sure snapping prevents clip2 to be moved to the left. |
| 1508 |
clip2.edit([], self.layer.get_priority(), GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, |
| 1509 |
clip2.props.start - 1) |
| 1510 |
self.assertEqual(clip2.props.start, split_position) |
| 1511 |
|
| 1512 |
def test_trim_snapps_inside_group(self): |
| 1513 |
self.track_types = [GES.TrackType.AUDIO] |
| 1514 |
super().setUp() |
| 1515 |
|
| 1516 |
self.timeline.props.auto_transition = True |
| 1517 |
self.timeline.set_snapping_distance(5) |
| 1518 |
|
| 1519 |
snaps = [] |
| 1520 |
def snapping_started_cb(timeline, element1, element2, dist, self): |
| 1521 |
snaps.append(set([element1, element2])) |
| 1522 |
|
| 1523 |
self.timeline.connect('snapping-started', snapping_started_cb, self) |
| 1524 |
clip = self.append_clip() |
| 1525 |
clip1 = self.append_clip() |
| 1526 |
|
| 1527 |
self.assertTimelineTopology([ |
| 1528 |
[ # Unique layer |
| 1529 |
(GES.TestClip, 0, 10), |
| 1530 |
(GES.TestClip, 10, 10), |
| 1531 |
] |
| 1532 |
]) |
| 1533 |
|
| 1534 |
clip1.edit([], self.layer.get_priority(), GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 15) |
| 1535 |
self.assertTimelineTopology([ |
| 1536 |
[ # Unique layer |
| 1537 |
(GES.TestClip, 0, 10), |
| 1538 |
(GES.TestClip, 10, 10), |
| 1539 |
] |
| 1540 |
]) |
| 1541 |
self.assertEqual(snaps[0], set([clip.get_children(False)[0], clip1.get_children(False)[0]])) |
| 1542 |
|
| 1543 |
clip1.edit([], self.layer.get_priority(), GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 16) |
| 1544 |
self.assertTimelineTopology([ |
| 1545 |
[ # Unique layer |
| 1546 |
(GES.TestClip, 0, 10), |
| 1547 |
(GES.TestClip, 16, 4), |
| 1548 |
] |
| 1549 |
]) |
| 1550 |
|
| 1551 |
def test_trim_no_snapping_on_same_clip(self): |
| 1552 |
self.timeline.props.auto_transition = True |
| 1553 |
self.timeline.set_snapping_distance(1) |
| 1554 |
|
| 1555 |
not_called = [] |
| 1556 |
def snapping_started_cb(timeline, element1, element2, dist, self): |
| 1557 |
not_called.append("No snapping should happen") |
| 1558 |
|
| 1559 |
self.timeline.connect('snapping-started', snapping_started_cb, self) |
| 1560 |
clip = self.append_clip() |
| 1561 |
clip.edit([], self.layer.get_priority(), GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 5) |
| 1562 |
self.assertEqual(not_called, []) |
| 1563 |
self.assertTimelineTopology([ |
| 1564 |
[ # Unique layer |
| 1565 |
(GES.TestClip, 5, 5), |
| 1566 |
] |
| 1567 |
]) |
| 1568 |
|
| 1569 |
clip.edit([], self.layer.get_priority(), GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 4) |
| 1570 |
self.assertEqual(not_called, []) |
| 1571 |
self.assertTimelineTopology([ |
| 1572 |
[ # Unique layer |
| 1573 |
(GES.TestClip, 4, 6), |
| 1574 |
] |
| 1575 |
]) |
| 1576 |
|
| 1577 |
def test_no_snapping_on_split(self): |
| 1578 |
self.timeline.props.auto_transition = True |
| 1579 |
self.timeline.set_snapping_distance(1) |
| 1580 |
|
| 1581 |
not_called = [] |
| 1582 |
def snapping_started_cb(timeline, element1, element2, dist, self): |
| 1583 |
not_called.append("No snapping should happen") |
| 1584 |
|
| 1585 |
self.timeline.connect('snapping-started', snapping_started_cb, self) |
| 1586 |
clip1 = self.add_clip(0, 0, 100) |
| 1587 |
|
| 1588 |
# Split clip1. |
| 1589 |
split_position = 50 |
| 1590 |
clip2 = clip1.split(split_position) |
| 1591 |
self.assertEqual(not_called, []) |
| 1592 |
self.assertEqual(len(self.layer.get_clips()), 2) |
| 1593 |
self.assertEqual(clip1.props.duration, split_position) |
| 1594 |
self.assertEqual(clip2.props.start, split_position) |
| 1595 |
|
| 1596 |
class TestComplexEditing(common.GESTimelineConfigTest): |
| 1597 |
|
| 1598 |
def test_normal_move(self): |
| 1599 |
""" |
| 1600 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1601 |
0 5 10 15 20 25 30 |
| 1602 |
_____________________________________________________________ |
| 1603 |
layer0_______________________________________________________ |
| 1604 |
|
| 1605 |
.................g1.................. |
| 1606 |
: : |
| 1607 |
: *=========* |
| 1608 |
: | c0 | |
| 1609 |
: *=========* |
| 1610 |
____________________:___________________________________:____ |
| 1611 |
layer1______________:___________________________________:____ |
| 1612 |
: : |
| 1613 |
..............g0............... : |
| 1614 |
: : : |
| 1615 |
*=======================* : : |
| 1616 |
| c1 | : : |
| 1617 |
*=========*=============*=====* : |
| 1618 |
: | c2 | : |
| 1619 |
: *===================* : |
| 1620 |
:.............................: : |
| 1621 |
: : |
| 1622 |
:...................................: |
| 1623 |
_____________________________________________________________ |
| 1624 |
layer2_______________________________________________________ |
| 1625 |
|
| 1626 |
*=============================* |
| 1627 |
| c3 | |
| 1628 |
*=============================* |
| 1629 |
""" |
| 1630 |
track = self.add_video_track() |
| 1631 |
c0 = self.add_clip("c0", 0, [track], 23, 5) |
| 1632 |
c1 = self.add_clip("c1", 1, [track], 10, 12) |
| 1633 |
c2 = self.add_clip("c2", 1, [track], 15, 10) |
| 1634 |
self.register_auto_transition(c1, c2, track) |
| 1635 |
c3 = self.add_clip("c3", 2, [track], 2, 15) |
| 1636 |
g0 = self.add_group("g0", [c1, c2]) |
| 1637 |
g1 = self.add_group("g1", [c0, g0]) |
| 1638 |
|
| 1639 |
self.assertTimelineConfig() |
| 1640 |
|
| 1641 |
# test invalid edits |
| 1642 |
|
| 1643 |
# cannot move c0 up one layer because it would cause a triple |
| 1644 |
# overlap between c1, c2 and c3 when g0 moves |
| 1645 |
self.assertFailEdit( |
| 1646 |
c0, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 23, |
| 1647 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1648 |
|
| 1649 |
# cannot move c0, without moving g1, to 21 layer 1 because it |
| 1650 |
# would be completely overlapped by c2 |
| 1651 |
self.assertFailEdit( |
| 1652 |
c0, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_START, 20, |
| 1653 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1654 |
|
| 1655 |
# cannot move c1, without moving g1, with end 25 because it |
| 1656 |
# would be completely overlapped by c2 |
| 1657 |
self.assertFailEdit( |
| 1658 |
c0, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_END, 25, |
| 1659 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1660 |
|
| 1661 |
# cannot move g0 to layer 0 because it would make c0 go to a |
| 1662 |
# negative layer |
| 1663 |
self.assertFailEdit( |
| 1664 |
g0, 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 10, |
| 1665 |
GES.Error.NEGATIVE_LAYER) |
| 1666 |
|
| 1667 |
# cannot move c1 for same reason |
| 1668 |
error = None |
| 1669 |
try: |
| 1670 |
c1.move_to_layer_full(self.timeline.get_layer(0)) |
| 1671 |
except GLib.Error as err: |
| 1672 |
error = err |
| 1673 |
self.assertGESError(error, GES.Error.NEGATIVE_LAYER) |
| 1674 |
self.assertTimelineConfig({}, []) |
| 1675 |
|
| 1676 |
# failure with snapping |
| 1677 |
self.timeline.set_snapping_distance(1) |
| 1678 |
|
| 1679 |
# cannot move to 0 because end edge of c0 would snap with end of |
| 1680 |
# c3, making the new start become negative |
| 1681 |
self.assertFailEdit( |
| 1682 |
g0, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 0, |
| 1683 |
GES.Error.NEGATIVE_TIME) |
| 1684 |
|
| 1685 |
# cannot move start of c1 to 14 because snapping causes a full |
| 1686 |
# overlap with c0 |
| 1687 |
self.assertFailEdit( |
| 1688 |
c1, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_START, 14, |
| 1689 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1690 |
|
| 1691 |
# cannot move end of c2 to 21 because snapping causes a full |
| 1692 |
# overlap with c0 |
| 1693 |
self.assertFailEdit( |
| 1694 |
c2, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_END, 21, |
| 1695 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1696 |
|
| 1697 |
# successes |
| 1698 |
self.timeline.set_snapping_distance(3) |
| 1699 |
# moving c0 also moves g1, along with g0 |
| 1700 |
# with no snapping, this would result in a triple overlap between |
| 1701 |
# c1, c2 and c3, but c2's start edge will snap to the end of c3 |
| 1702 |
# at a distance of 3 allowing the edit to succeed |
| 1703 |
# |
| 1704 |
# c1 and c3 have a new transition |
| 1705 |
# transition between c1 and c2 is not lost |
| 1706 |
# |
| 1707 |
# NOTE: there is no snapping between c0, c1 or c2 even though |
| 1708 |
# their edges are within distance 2 of each other because they are |
| 1709 |
# all moving |
| 1710 |
self.assertEdit( |
| 1711 |
c0, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 22, 17, |
| 1712 |
[c2], [c3], |
| 1713 |
{ |
| 1714 |
c0 : {"start": 25, "layer": 1}, |
| 1715 |
c1 : {"start": 12, "layer": 2}, |
| 1716 |
c2 : {"start": 17, "layer": 2}, |
| 1717 |
g0 : {"start": 12, "layer": 2}, |
| 1718 |
g1 : {"start": 12, "layer": 1} |
| 1719 |
}, [(c3, c1, track)], []) |
| 1720 |
|
| 1721 |
""" |
| 1722 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1723 |
0 5 10 15 20 25 30 |
| 1724 |
_____________________________________________________________ |
| 1725 |
layer0_______________________________________________________ |
| 1726 |
|
| 1727 |
_____________________________________________________________ |
| 1728 |
layer1_______________________________________________________ |
| 1729 |
|
| 1730 |
.................g1.................. |
| 1731 |
: : |
| 1732 |
: *=========* |
| 1733 |
: | c0 | |
| 1734 |
: *=========* |
| 1735 |
________________________:___________________________________: |
| 1736 |
layer2__________________:___________________________________: |
| 1737 |
: : |
| 1738 |
..............g0............... : |
| 1739 |
: : : |
| 1740 |
*=======================* : : |
| 1741 |
| c1 | : : |
| 1742 |
*===================*=========*=============*=====* : |
| 1743 |
| c3 | c2 | : |
| 1744 |
*=============================*===================* : |
| 1745 |
:.............................: : |
| 1746 |
: : |
| 1747 |
:...................................: |
| 1748 |
""" |
| 1749 |
# using EDGE_START we can move without moving parent |
| 1750 |
# snap at same position 17 but with c1's end edge to c3's end |
| 1751 |
# edge |
| 1752 |
# loose transition between c1 and c3 |
| 1753 |
self.assertEdit( |
| 1754 |
g0, 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_START, 5, 17, |
| 1755 |
[c1], [c3], |
| 1756 |
{ |
| 1757 |
c1 : {"start": 5, "layer": 0}, |
| 1758 |
c2 : {"start": 10, "layer": 0}, |
| 1759 |
g0 : {"start": 5, "layer": 0}, |
| 1760 |
g1 : {"start": 5, "duration": 25, "layer": 0}, |
| 1761 |
}, [], [(c3, c1, track)]) |
| 1762 |
|
| 1763 |
""" |
| 1764 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1765 |
0 5 10 15 20 25 30 |
| 1766 |
_____________________________________________________________ |
| 1767 |
layer0_______________________________________________________ |
| 1768 |
|
| 1769 |
.........................g1........................ |
| 1770 |
: : |
| 1771 |
...............g0.............. : |
| 1772 |
: : : |
| 1773 |
*=======================* : : |
| 1774 |
| c1 | : : |
| 1775 |
*=========*=============*=====* : |
| 1776 |
: | c2 | : |
| 1777 |
: *===================* : |
| 1778 |
:.............................: : |
| 1779 |
__________:_________________________________________________: |
| 1780 |
layer1____:_________________________________________________: |
| 1781 |
: : |
| 1782 |
: *=========* |
| 1783 |
: | c0 | |
| 1784 |
: *=========* |
| 1785 |
:.................................................: |
| 1786 |
_____________________________________________________________ |
| 1787 |
layer2_______________________________________________________ |
| 1788 |
|
| 1789 |
*=============================* |
| 1790 |
| c3 | |
| 1791 |
*=============================* |
| 1792 |
""" |
| 1793 |
# using EDGE_END we can move without moving parent |
| 1794 |
# no snap |
| 1795 |
# loose transition between c1 and c2 |
| 1796 |
self.assertEdit( |
| 1797 |
c2, 1, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_END, 21, None, |
| 1798 |
[], [], |
| 1799 |
{ |
| 1800 |
c2 : {"duration": 11, "layer": 1}, |
| 1801 |
g0 : {"duration": 16}, |
| 1802 |
}, [], [(c1, c2, track)]) |
| 1803 |
|
| 1804 |
# no snapping when we use move layer |
| 1805 |
self.timeline.set_snapping_distance(10) |
| 1806 |
self.assertTrue( |
| 1807 |
c3.move_to_layer(self.timeline.get_layer(1))) |
| 1808 |
self.assertTimelineConfig( |
| 1809 |
new_props={c3 : {"layer": 1}}, new_transitions=[(c3, c2, track)]) |
| 1810 |
|
| 1811 |
def test_ripple(self): |
| 1812 |
""" |
| 1813 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1814 |
0 5 10 15 20 25 30 |
| 1815 |
_____________________________________________________________ |
| 1816 |
layer0_______________________________________________________ |
| 1817 |
|
| 1818 |
......................g0................. |
| 1819 |
: : |
| 1820 |
*=========* : |
| 1821 |
| c0 | : |
| 1822 |
*=========* : |
| 1823 |
______________:_______________________________________:______ |
| 1824 |
layer1________:_______________________________________:______ |
| 1825 |
: : |
| 1826 |
: *=============* |
| 1827 |
: | c3 | |
| 1828 |
: *=============* |
| 1829 |
:.......................................: |
| 1830 |
*===================* |
| 1831 |
| c2 | |
| 1832 |
*=========*=========*=========* |
| 1833 |
| c1 | |
| 1834 |
*===================* |
| 1835 |
""" |
| 1836 |
track = self.add_video_track() |
| 1837 |
c0 = self.add_clip("c0", 0, [track], 7, 5) |
| 1838 |
c1 = self.add_clip("c1", 1, [track], 5, 10) |
| 1839 |
c2 = self.add_clip("c2", 1, [track], 10, 10) |
| 1840 |
c3 = self.add_clip("c3", 1, [track], 20, 7) |
| 1841 |
self.register_auto_transition(c1, c2, track) |
| 1842 |
g0 = self.add_group("g0", [c0, c3]) |
| 1843 |
|
| 1844 |
self.assertTimelineConfig() |
| 1845 |
|
| 1846 |
# test failures |
| 1847 |
|
| 1848 |
self.timeline.set_snapping_distance(2) |
| 1849 |
|
| 1850 |
# would cause negative layer priority for c0 |
| 1851 |
self.assertFailEdit( |
| 1852 |
c1, 0, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 5, |
| 1853 |
GES.Error.NEGATIVE_LAYER) |
| 1854 |
|
| 1855 |
# would lead to c2 fully overlapping c3 since c2 does ripple |
| 1856 |
# but c3 does not(c3 shares a toplevel with c0, and |
| 1857 |
# GES_EDGE_START, same as NORMAL mode, does not move the |
| 1858 |
# toplevel |
| 1859 |
self.assertFailEdit( |
| 1860 |
c2, 1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_END, 25, |
| 1861 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1862 |
|
| 1863 |
# would lead to c2 fully overlapping c3 since c2 does not |
| 1864 |
# ripple but c3 does |
| 1865 |
self.assertFailEdit( |
| 1866 |
c0, 0, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_START, 13, |
| 1867 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 1868 |
|
| 1869 |
# add two more clips |
| 1870 |
|
| 1871 |
c4 = self.add_clip("c4", 2, [track], 17, 8) |
| 1872 |
c5 = self.add_clip("c5", 2, [track], 21, 8) |
| 1873 |
self.register_auto_transition(c4, c5, track) |
| 1874 |
|
| 1875 |
self.assertTimelineConfig() |
| 1876 |
|
| 1877 |
""" |
| 1878 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1879 |
0 5 10 15 20 25 30 |
| 1880 |
_____________________________________________________________ |
| 1881 |
layer0_______________________________________________________ |
| 1882 |
|
| 1883 |
......................g0................. |
| 1884 |
: : |
| 1885 |
*=========* : |
| 1886 |
| c0 | : |
| 1887 |
*=========* : |
| 1888 |
______________:_______________________________________:______ |
| 1889 |
layer1________:_______________________________________:______ |
| 1890 |
: : |
| 1891 |
: *=============* |
| 1892 |
: | c3 | |
| 1893 |
: *=============* |
| 1894 |
:.......................................: |
| 1895 |
*===================* |
| 1896 |
| c2 | |
| 1897 |
*=========*=========*=========* |
| 1898 |
| c1 | |
| 1899 |
*===================* |
| 1900 |
_____________________________________________________________ |
| 1901 |
layer2_______________________________________________________ |
| 1902 |
|
| 1903 |
*===============* |
| 1904 |
| c4 | |
| 1905 |
*=======*=======*=======* |
| 1906 |
| c5 | |
| 1907 |
*===============* |
| 1908 |
""" |
| 1909 |
|
| 1910 |
# rippling start of c2 only moves c4 and c5 because c3 is part |
| 1911 |
# of a toplevel with an earlier start |
| 1912 |
# NOTE: snapping only occurs for the edges of c2, in particular |
| 1913 |
# start of c4 does not snap to end of c1 |
| 1914 |
self.assertEdit( |
| 1915 |
c2, 1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 8, 7, |
| 1916 |
[c2], [c0], |
| 1917 |
{ |
| 1918 |
c2 : {"start": 7}, |
| 1919 |
c4 : {"start": 14}, |
| 1920 |
c5 : {"start": 18}, |
| 1921 |
}, [], []) |
| 1922 |
|
| 1923 |
""" |
| 1924 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1925 |
0 5 10 15 20 25 30 |
| 1926 |
_____________________________________________________________ |
| 1927 |
layer0_______________________________________________________ |
| 1928 |
|
| 1929 |
......................g0................. |
| 1930 |
: : |
| 1931 |
*=========* : |
| 1932 |
| c0 | : |
| 1933 |
*=========* : |
| 1934 |
______________:_______________________________________:______ |
| 1935 |
layer1________:_______________________________________:______ |
| 1936 |
: : |
| 1937 |
: *=============* |
| 1938 |
: | c3 | |
| 1939 |
: *=============* |
| 1940 |
:.......................................: |
| 1941 |
*===================* |
| 1942 |
| c2 | |
| 1943 |
*===*===============*===* |
| 1944 |
| c1 | |
| 1945 |
*===================* |
| 1946 |
_____________________________________________________________ |
| 1947 |
layer2_______________________________________________________ |
| 1948 |
|
| 1949 |
*===============* |
| 1950 |
| c4 | |
| 1951 |
*=======*=======*=======* |
| 1952 |
| c5 | |
| 1953 |
*===============* |
| 1954 |
""" |
| 1955 |
|
| 1956 |
# rippling end of c2, only c5 moves |
| 1957 |
# NOTE: start edge of c2 does not snap! |
| 1958 |
self.assertEdit( |
| 1959 |
c2, 1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_END, 19, 20, |
| 1960 |
[c2], [c3], |
| 1961 |
{ |
| 1962 |
c2 : {"duration": 13}, |
| 1963 |
c5 : {"start": 21}, |
| 1964 |
}, [], []) |
| 1965 |
|
| 1966 |
""" |
| 1967 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 1968 |
0 5 10 15 20 25 30 |
| 1969 |
_____________________________________________________________ |
| 1970 |
layer0_______________________________________________________ |
| 1971 |
|
| 1972 |
......................g0................. |
| 1973 |
: : |
| 1974 |
*=========* : |
| 1975 |
| c0 | : |
| 1976 |
*=========* : |
| 1977 |
______________:_______________________________________:______ |
| 1978 |
layer1________:_______________________________________:______ |
| 1979 |
: : |
| 1980 |
: *=============* |
| 1981 |
: | c3 | |
| 1982 |
: *=============* |
| 1983 |
:.......................................: |
| 1984 |
*=========================* |
| 1985 |
| c2 | |
| 1986 |
*===*===============*=========* |
| 1987 |
| c1 | |
| 1988 |
*===================* |
| 1989 |
_____________________________________________________________ |
| 1990 |
layer2_______________________________________________________ |
| 1991 |
|
| 1992 |
*===============* |
| 1993 |
| c4 | |
| 1994 |
*=============*=*=============* |
| 1995 |
| c5 | |
| 1996 |
*===============* |
| 1997 |
""" |
| 1998 |
|
| 1999 |
# everything except c1 moves, and to the next layer |
| 2000 |
# end edge of c2 snaps to end of c1 |
| 2001 |
# NOTE: does not snap to edges of rippled clips |
| 2002 |
# NOTE: c4 and c5 do not loose their transition when moving |
| 2003 |
# to the new layer |
| 2004 |
self.assertEdit( |
| 2005 |
c2, 2, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 0, 15, |
| 2006 |
[c2], [c1], |
| 2007 |
{ |
| 2008 |
c0 : {"start": 2, "layer": 1}, |
| 2009 |
c2 : {"start": 2, "layer": 2}, |
| 2010 |
c3 : {"start": 15, "layer": 2}, |
| 2011 |
c4 : {"start": 9, "layer": 3}, |
| 2012 |
c5 : {"start": 16, "layer": 3}, |
| 2013 |
g0 : {"start": 2, "layer": 1}, |
| 2014 |
}, [(c0, c1, track)], [(c1, c2, track)]) |
| 2015 |
|
| 2016 |
""" |
| 2017 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2018 |
0 5 10 15 20 25 30 |
| 2019 |
_____________________________________________________________ |
| 2020 |
layer0_______________________________________________________ |
| 2021 |
|
| 2022 |
_____________________________________________________________ |
| 2023 |
layer1_______________________________________________________ |
| 2024 |
|
| 2025 |
*===================* |
| 2026 |
| c1 | |
| 2027 |
*===================* |
| 2028 |
...................g0.................... |
| 2029 |
*=========* : |
| 2030 |
| c0 | : |
| 2031 |
*=========* : |
| 2032 |
____:_______________________________________:________________ |
| 2033 |
layer2______________________________________:________________ |
| 2034 |
: : |
| 2035 |
: *=============* |
| 2036 |
: | c3 | |
| 2037 |
: *=============* |
| 2038 |
:.......................................: |
| 2039 |
*=========================* |
| 2040 |
| c2 | |
| 2041 |
*=========================* |
| 2042 |
_____________________________________________________________ |
| 2043 |
layer3_______________________________________________________ |
| 2044 |
|
| 2045 |
*===============* |
| 2046 |
| c4 | |
| 2047 |
*=============*=*=============* |
| 2048 |
| c5 | |
| 2049 |
*===============* |
| 2050 |
""" |
| 2051 |
|
| 2052 |
# group c1 and c5, and g0 and c2 |
| 2053 |
g1 = self.add_group("g1", [c1, c5]) |
| 2054 |
g2 = self.add_group("g2", [g0, c2]) |
| 2055 |
self.assertTimelineConfig() |
| 2056 |
|
| 2057 |
# moving end edge of c0 does not move anything else in the same |
| 2058 |
# toplevel g2 |
| 2059 |
# c5 does not move because it is grouped with c1, which starts |
| 2060 |
# earlier than the end edge of c0 |
| 2061 |
# only c4 moves |
| 2062 |
# c0 does not snap to c4's start edge |
| 2063 |
self.assertEdit( |
| 2064 |
c0, 1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_END, 10, None, |
| 2065 |
[], [], |
| 2066 |
{ |
| 2067 |
c0 : {"duration": 8}, |
| 2068 |
c4 : {"start": 12}, |
| 2069 |
}, [], []) |
| 2070 |
|
| 2071 |
""" |
| 2072 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2073 |
0 5 10 15 20 25 30 |
| 2074 |
_____________________________________________________________ |
| 2075 |
layer0_______________________________________________________ |
| 2076 |
|
| 2077 |
_____________________________________________________________ |
| 2078 |
layer1_______________________________________________________ |
| 2079 |
|
| 2080 |
..................g1..................... |
| 2081 |
*===================* : |
| 2082 |
| c1 | : |
| 2083 |
*===================* : |
| 2084 |
:...................................... : |
| 2085 |
...................g2.................... : : |
| 2086 |
:..................g0...................: : : |
| 2087 |
*===============* : : : |
| 2088 |
| c0 | : : : |
| 2089 |
*===============* : : : |
| 2090 |
____:_______________________________________:___:_:__________ |
| 2091 |
layer2______________________________________:___:_:__________ |
| 2092 |
: : : : |
| 2093 |
: *=============* : : |
| 2094 |
: | c3 | : : |
| 2095 |
: *=============* : : |
| 2096 |
:.......................................: : : |
| 2097 |
*=========================* : : : |
| 2098 |
| c2 | : : : |
| 2099 |
*=========================* : : : |
| 2100 |
:.......................................: : : |
| 2101 |
________________________________________________:_:__________ |
| 2102 |
layer3__________________________________________:_:__________ |
| 2103 |
................: : |
| 2104 |
*===============* : |
| 2105 |
| c5 | : |
| 2106 |
*===============* : |
| 2107 |
:.................: |
| 2108 |
*===============* |
| 2109 |
| c4 | |
| 2110 |
*===============* |
| 2111 |
""" |
| 2112 |
|
| 2113 |
# rippling start of c5 does not move anything else |
| 2114 |
# end edge snaps to start of c4 |
| 2115 |
self.timeline.set_snapping_distance(1) |
| 2116 |
self.assertEdit( |
| 2117 |
c5, 0, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_START, 18, None, |
| 2118 |
[], [], |
| 2119 |
{ |
| 2120 |
c5 : {"start": 18, "layer": 0}, |
| 2121 |
g1 : {"layer": 0, "duration": 21}, |
| 2122 |
}, [], [(c4, c5, track)]) |
| 2123 |
|
| 2124 |
""" |
| 2125 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2126 |
0 5 10 15 20 25 30 |
| 2127 |
_____________________________________________________________ |
| 2128 |
layer0_______________________________________________________ |
| 2129 |
|
| 2130 |
....................g1..................... |
| 2131 |
: *===============* |
| 2132 |
: | c5 | |
| 2133 |
: *===============* |
| 2134 |
__________:_________________________________________:________ |
| 2135 |
layer1____:_________________________________________:________ |
| 2136 |
: : |
| 2137 |
*===================* : |
| 2138 |
| c1 | : |
| 2139 |
*===================* : |
| 2140 |
:.........................................: |
| 2141 |
...................g2.................... |
| 2142 |
:..................g0...................: |
| 2143 |
*===============* : |
| 2144 |
| c0 | : |
| 2145 |
*===============* : |
| 2146 |
____:_______________________________________:________________ |
| 2147 |
layer2______________________________________:________________ |
| 2148 |
: : |
| 2149 |
: *=============* |
| 2150 |
: | c3 | |
| 2151 |
: *=============* |
| 2152 |
:.......................................: |
| 2153 |
*=========================* : |
| 2154 |
| c2 | : |
| 2155 |
*=========================* : |
| 2156 |
:.......................................: |
| 2157 |
_____________________________________________________________ |
| 2158 |
layer3_______________________________________________________ |
| 2159 |
|
| 2160 |
*===============* |
| 2161 |
| c4 | |
| 2162 |
*===============* |
| 2163 |
""" |
| 2164 |
|
| 2165 |
# rippling g1 using c5 |
| 2166 |
# initial position would make c1 go negative, but end edge of c1 |
| 2167 |
# will snap to end of c0, allowing the edit to succeed |
| 2168 |
# c4 also moves because it is after the start of g1 |
| 2169 |
self.timeline.set_snapping_distance(3) |
| 2170 |
self.assertEdit( |
| 2171 |
c5, 1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 12, 10, |
| 2172 |
[c1], [c0], |
| 2173 |
{ |
| 2174 |
c5 : {"start": 13, "layer": 1}, |
| 2175 |
c1 : {"start": 0, "layer": 2}, |
| 2176 |
g1 : {"start": 0, "layer": 1}, |
| 2177 |
c4 : {"start": 7, "layer": 4}, |
| 2178 |
}, [(c1, c2, track)], [(c0, c1, track)]) |
| 2179 |
|
| 2180 |
""" |
| 2181 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2182 |
0 5 10 15 20 25 30 |
| 2183 |
_____________________________________________________________ |
| 2184 |
layer0_______________________________________________________ |
| 2185 |
_____________________________________________________________ |
| 2186 |
layer1_______________________________________________________ |
| 2187 |
|
| 2188 |
....................g1..................... |
| 2189 |
: *===============* |
| 2190 |
: | c5 | |
| 2191 |
: *===============* |
| 2192 |
: ...................g2.................:.. |
| 2193 |
: :..................g0.................:.: |
| 2194 |
: *===============* : : |
| 2195 |
: | c0 | : : |
| 2196 |
: *===============* : : |
| 2197 |
:___:_____________________________________:_:________________ |
| 2198 |
layer2____________________________________:_:________________ |
| 2199 |
: : : : |
| 2200 |
*===================* : : |
| 2201 |
| c1 | : : |
| 2202 |
*===================* : : |
| 2203 |
:...:.....................................: : |
| 2204 |
: *=============* |
| 2205 |
: | c3 | |
| 2206 |
: *=============* |
| 2207 |
:.......................................: |
| 2208 |
*=========================* : |
| 2209 |
| c2 | : |
| 2210 |
*=========================* : |
| 2211 |
:.......................................: |
| 2212 |
_____________________________________________________________ |
| 2213 |
layer3_______________________________________________________ |
| 2214 |
_____________________________________________________________ |
| 2215 |
layer4_______________________________________________________ |
| 2216 |
|
| 2217 |
*===============* |
| 2218 |
| c4 | |
| 2219 |
*===============* |
| 2220 |
""" |
| 2221 |
# moving start of c1 will move everything expect c5 because they |
| 2222 |
# can snap to c5 since it is not moving |
| 2223 |
# c1 and c2 keep transition |
| 2224 |
self.assertEdit( |
| 2225 |
c1, 1, GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_START, 20, 21, |
| 2226 |
[c1], [c5], |
| 2227 |
{ |
| 2228 |
c1 : {"start": 21, "layer": 1}, |
| 2229 |
g1 : {"start": 13, "duration": 18}, |
| 2230 |
c0 : {"start": 23, "layer": 0}, |
| 2231 |
c2 : {"start": 23, "layer": 1}, |
| 2232 |
c3 : {"start": 36, "layer": 1}, |
| 2233 |
g0 : {"start": 23, "layer": 0}, |
| 2234 |
g2 : {"start": 23, "layer": 0}, |
| 2235 |
c4 : {"start": 28, "layer": 3}, |
| 2236 |
}, [], []) |
| 2237 |
|
| 2238 |
def test_trim(self): |
| 2239 |
""" |
| 2240 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2241 |
0 5 10 15 20 25 30 |
| 2242 |
_____________________________________________________________ |
| 2243 |
layer0_______________________________________________________ |
| 2244 |
|
| 2245 |
..................g2................... |
| 2246 |
: : |
| 2247 |
:...............g0............. : |
| 2248 |
: *===============* : |
| 2249 |
: | a0 | : |
| 2250 |
: *===*=====*=========* : |
| 2251 |
: | a1 | : : |
| 2252 |
: *=========* : : |
| 2253 |
*===================* : : |
| 2254 |
| v0 | : : |
| 2255 |
*===================* : : |
| 2256 |
:.............................: : |
| 2257 |
__________:_____________________________________:____________ |
| 2258 |
layer1____:_____________________________________:____________ |
| 2259 |
: : |
| 2260 |
: ............g1..............: |
| 2261 |
: : *=================* |
| 2262 |
: : | a2 | |
| 2263 |
: : *=================* |
| 2264 |
: *===========================* |
| 2265 |
: | v1 | |
| 2266 |
: *===========================* |
| 2267 |
__________:_________:___________________________:____________ |
| 2268 |
layer2____:_________:___________________________:____________ |
| 2269 |
*=============* *=================* |
| 2270 |
| a3 | | a4 | |
| 2271 |
*=============* *=================* |
| 2272 |
: :...........................: |
| 2273 |
*=========================* : |
| 2274 |
| v2 | : |
| 2275 |
*=============*===========*===========* |
| 2276 |
: | v3 | |
| 2277 |
: *=======================* |
| 2278 |
:.....................................: |
| 2279 |
_____________________________________________________________ |
| 2280 |
layer3_______________________________________________________ |
| 2281 |
|
| 2282 |
*===========================* *===============* |
| 2283 |
| v4 | | v5 | |
| 2284 |
*===========================* *===============* |
| 2285 |
""" |
| 2286 |
audio_track = self.add_audio_track() |
| 2287 |
video_track = self.add_video_track() |
| 2288 |
a0 = self.add_clip("a0", 0, [audio_track], 12, 8, 5, 15) |
| 2289 |
a1 = self.add_clip("a1", 0, [audio_track], 10, 5) |
| 2290 |
self.register_auto_transition(a1, a0, audio_track) |
| 2291 |
a2 = self.add_clip("a2", 1, [audio_track], 15, 9, 7, 19) |
| 2292 |
a3 = self.add_clip("a3", 2, [audio_track], 5, 7, 10) |
| 2293 |
a4 = self.add_clip("a4", 2, [audio_track], 15, 9) |
| 2294 |
|
| 2295 |
v0 = self.add_clip("v0", 0, [video_track], 5, 10, 5) |
| 2296 |
v1 = self.add_clip("v1", 1, [video_track], 10, 14) |
| 2297 |
v2 = self.add_clip("v2", 2, [video_track], 5, 13, 4) |
| 2298 |
v3 = self.add_clip("v3", 2, [video_track], 12, 12) |
| 2299 |
self.register_auto_transition(v2, v3, video_track) |
| 2300 |
v4 = self.add_clip("v4", 3, [video_track], 0, 13) |
| 2301 |
v5 = self.add_clip("v5", 3, [video_track], 18, 8) |
| 2302 |
|
| 2303 |
g0 = self.add_group("g0", [a0, a1, v0]) |
| 2304 |
g1 = self.add_group("g1", [v1, a2, a4]) |
| 2305 |
g2 = self.add_group("g2", [a3, v2, v3, g0, g1]) |
| 2306 |
|
| 2307 |
self.assertTimelineConfig() |
| 2308 |
|
| 2309 |
# edit failures |
| 2310 |
|
| 2311 |
# cannot trim end of g0 to 16 because a0 and a1 would fully |
| 2312 |
# overlap |
| 2313 |
self.assertFailEdit( |
| 2314 |
g0, 1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 15, |
| 2315 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 2316 |
|
| 2317 |
# cannot edit to new layer because there would be triple overlaps |
| 2318 |
# between v2, v3, v4 and v5 |
| 2319 |
self.assertFailEdit( |
| 2320 |
g2, 1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 20, |
| 2321 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 2322 |
|
| 2323 |
# cannot trim g1 end to 14 because it would result in a negative |
| 2324 |
# duration for a2 and a4 |
| 2325 |
self.assertFailEdit( |
| 2326 |
g1, 1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 14, |
| 2327 |
GES.Error.NEGATIVE_TIME) |
| 2328 |
|
| 2329 |
# cannot trim end of v2 below its start |
| 2330 |
self.assertFailEdit( |
| 2331 |
v2, 2, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 2, |
| 2332 |
GES.Error.NEGATIVE_TIME) |
| 2333 |
|
| 2334 |
# cannot trim end of g0 because a0's duration-limit would be |
| 2335 |
# exceeded |
| 2336 |
self.assertFailEdit( |
| 2337 |
g0, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 23, |
| 2338 |
GES.Error.NOT_ENOUGH_INTERNAL_CONTENT) |
| 2339 |
|
| 2340 |
# cannot trim g0 to 12 because a0 and a1 would fully overlap |
| 2341 |
self.assertFailEdit( |
| 2342 |
g0, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 12, |
| 2343 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 2344 |
|
| 2345 |
# cannot trim start of v2 beyond its end point |
| 2346 |
self.assertFailEdit( |
| 2347 |
v2, 2, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 20, |
| 2348 |
GES.Error.NEGATIVE_TIME) |
| 2349 |
|
| 2350 |
# with snapping |
| 2351 |
self.timeline.set_snapping_distance(4) |
| 2352 |
|
| 2353 |
# cannot trim end of g2 to 19 because v1 and v2 would fully |
| 2354 |
# overlap after snapping to v5 start edge(18) |
| 2355 |
self.assertFailEdit( |
| 2356 |
g2, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 19, |
| 2357 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 2358 |
|
| 2359 |
# cannot trim g2 to 3 because it would snap to start edge of |
| 2360 |
# v4(0), causing v2's in-point to be negative |
| 2361 |
self.assertFailEdit( |
| 2362 |
g2, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 3, |
| 2363 |
GES.Error.NEGATIVE_TIME) |
| 2364 |
|
| 2365 |
# success |
| 2366 |
|
| 2367 |
self.timeline.set_snapping_distance(2) |
| 2368 |
|
| 2369 |
# first trim v4 start |
| 2370 |
self.assertEdit( |
| 2371 |
v4, 3, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 1, None, [], [], |
| 2372 |
{ |
| 2373 |
v4 : {"start": 1, "in-point": 1, "duration": 12}, |
| 2374 |
}, [], []) |
| 2375 |
|
| 2376 |
# and trim v5 end |
| 2377 |
self.assertEdit( |
| 2378 |
v5, 3, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 25, 24, |
| 2379 |
[v5], [a2, a4, v1, v3], |
| 2380 |
{ |
| 2381 |
v5 : {"duration": 6}, |
| 2382 |
}, [], []) |
| 2383 |
|
| 2384 |
""" |
| 2385 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2386 |
0 5 10 15 20 25 30 |
| 2387 |
_____________________________________________________________ |
| 2388 |
layer0_______________________________________________________ |
| 2389 |
|
| 2390 |
..................g2................... |
| 2391 |
: : |
| 2392 |
:...............g0............. : |
| 2393 |
: *===============* : |
| 2394 |
: | a0 | : |
| 2395 |
: *===*=====*=========* : |
| 2396 |
: | a1 | : : |
| 2397 |
: *=========* : : |
| 2398 |
*===================* : : |
| 2399 |
| v0 | : : |
| 2400 |
*===================* : : |
| 2401 |
:.............................: : |
| 2402 |
__________:_____________________________________:____________ |
| 2403 |
layer1____:_____________________________________:____________ |
| 2404 |
: : |
| 2405 |
: ............g1..............: |
| 2406 |
: : *=================* |
| 2407 |
: : | a2 | |
| 2408 |
: : *=================* |
| 2409 |
: *===========================* |
| 2410 |
: | v1 | |
| 2411 |
: *===========================* |
| 2412 |
__________:_________:___________________________:____________ |
| 2413 |
layer2____:_________:___________________________:____________ |
| 2414 |
*=============* *=================* |
| 2415 |
| a3 | | a4 | |
| 2416 |
*=============* *=================* |
| 2417 |
: :...........................: |
| 2418 |
*=========================* : |
| 2419 |
| v2 | : |
| 2420 |
*=============*===========*===========* |
| 2421 |
: | v3 | |
| 2422 |
: *=======================* |
| 2423 |
:.....................................: |
| 2424 |
_____________________________________________________________ |
| 2425 |
layer3_______________________________________________________ |
| 2426 |
|
| 2427 |
*=========================* *===========* |
| 2428 |
| v4 | | v5 | |
| 2429 |
*=========================* *===========* |
| 2430 |
""" |
| 2431 |
|
| 2432 |
# can trim g2 to 0 even though in-point of v2 is 4 because it will |
| 2433 |
# snap to 1. Note, there is only snapping on the start edge |
| 2434 |
# everything at the start edge is stretched back |
| 2435 |
self.assertEdit( |
| 2436 |
g2, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 0, 1, |
| 2437 |
[v0, v2, a3], [v4], |
| 2438 |
{ |
| 2439 |
v0 : {"start": 1, "in-point": 1, "duration": 14}, |
| 2440 |
a3 : {"start": 1, "in-point": 6, "duration": 11}, |
| 2441 |
v2 : {"start": 1, "in-point": 0, "duration": 17}, |
| 2442 |
g0 : {"start": 1, "duration": 19}, |
| 2443 |
g2 : {"start": 1, "duration": 23}, |
| 2444 |
}, [], []) |
| 2445 |
|
| 2446 |
self.timeline.set_snapping_distance(0) |
| 2447 |
|
| 2448 |
# trim end to use as a snapping point |
| 2449 |
self.assertEdit( |
| 2450 |
v4, 3, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 11, None, [], [], |
| 2451 |
{ |
| 2452 |
v4 : {"duration": 10}, |
| 2453 |
}, [], []) |
| 2454 |
|
| 2455 |
self.timeline.set_snapping_distance(2) |
| 2456 |
""" |
| 2457 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2458 |
0 5 10 15 20 25 30 |
| 2459 |
_____________________________________________________________ |
| 2460 |
layer0_______________________________________________________ |
| 2461 |
|
| 2462 |
......................g2....................... |
| 2463 |
: : |
| 2464 |
:................g0.................... : |
| 2465 |
: *===============* : |
| 2466 |
: | a0 | : |
| 2467 |
: *===*=====*=========* : |
| 2468 |
: | a1 | : : |
| 2469 |
: *=========* : : |
| 2470 |
*===========================* : : |
| 2471 |
| v0 | : : |
| 2472 |
*===========================* : : |
| 2473 |
:.....................................: : |
| 2474 |
__:_____________________________________________:____________ |
| 2475 |
layer1__________________________________________:____________ |
| 2476 |
: : |
| 2477 |
: ............g1..............: |
| 2478 |
: : *=================* |
| 2479 |
: : | a2 | |
| 2480 |
: : *=================* |
| 2481 |
: *===========================* |
| 2482 |
: | v1 | |
| 2483 |
: *===========================* |
| 2484 |
__:_________________:___________________________:____________ |
| 2485 |
layer2______________:___________________________:____________ |
| 2486 |
*=====================* *=================* |
| 2487 |
| a3 | | a4 | |
| 2488 |
*=====================* *=================* |
| 2489 |
: :...........................: |
| 2490 |
*=================================* : |
| 2491 |
| v2 | : |
| 2492 |
*=====================*===========*===========* |
| 2493 |
: | v3 | |
| 2494 |
: *=======================* |
| 2495 |
:.............................................: |
| 2496 |
_____________________________________________________________ |
| 2497 |
layer3_______________________________________________________ |
| 2498 |
|
| 2499 |
*===================* *===========* |
| 2500 |
| v4 | | v5 | |
| 2501 |
*===================* *===========* |
| 2502 |
""" |
| 2503 |
|
| 2504 |
# can trim g2 to 12 even though it would cause a0 and a1 to fully |
| 2505 |
# overlap because the snapping allows it to succeed |
| 2506 |
self.assertEdit( |
| 2507 |
g2, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 12, 11, |
| 2508 |
[a3, v0, v2], [v4], |
| 2509 |
{ |
| 2510 |
v0 : {"start": 11, "in-point": 11, "duration": 4}, |
| 2511 |
a1 : {"start": 11, "in-point": 1, "duration": 4}, |
| 2512 |
v1 : {"start": 11, "in-point": 1, "duration": 13}, |
| 2513 |
a3 : {"start": 11, "in-point": 16, "duration": 1}, |
| 2514 |
v2 : {"start": 11, "in-point": 10, "duration": 7}, |
| 2515 |
g0 : {"start": 11, "duration": 9}, |
| 2516 |
g1 : {"start": 11, "duration": 13}, |
| 2517 |
g2 : {"start": 11, "duration": 13}, |
| 2518 |
}, [], []) |
| 2519 |
|
| 2520 |
# trim end to use as a snapping point |
| 2521 |
self.assertEdit( |
| 2522 |
v5, 4, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 27, None, [], [], |
| 2523 |
{ |
| 2524 |
v5 : {"duration": 9, "layer": 4}, |
| 2525 |
}, [], []) |
| 2526 |
|
| 2527 |
""" |
| 2528 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2529 |
0 5 10 15 20 25 30 |
| 2530 |
_____________________________________________________________ |
| 2531 |
layer0_______________________________________________________ |
| 2532 |
|
| 2533 |
.............g2............ |
| 2534 |
: : |
| 2535 |
:.......g0......... : |
| 2536 |
: *===============* : |
| 2537 |
: | a0 | : |
| 2538 |
*=*=====*=========* : |
| 2539 |
| a1 | : : |
| 2540 |
*=======* : : |
| 2541 |
*=======* : : |
| 2542 |
| v0 | : : |
| 2543 |
*=======* : : |
| 2544 |
:.................: : |
| 2545 |
______________________:_________________________:____________ |
| 2546 |
layer1________________:_________________________:____________ |
| 2547 |
: : |
| 2548 |
:.........g1..............: |
| 2549 |
: *=================* |
| 2550 |
: | a2 | |
| 2551 |
: *=================* |
| 2552 |
*=========================* |
| 2553 |
| v1 | |
| 2554 |
*=========================* |
| 2555 |
______________________:_________________________:____________ |
| 2556 |
layer2________________:_________________________:____________ |
| 2557 |
*=* *=================* |
| 2558 |
a3| | a4 | |
| 2559 |
*=* *=================* |
| 2560 |
:.........................: |
| 2561 |
*=============* : |
| 2562 |
| v2 | : |
| 2563 |
*=*===========*===========* |
| 2564 |
: | v3 | |
| 2565 |
: *=======================* |
| 2566 |
:.........................: |
| 2567 |
_____________________________________________________________ |
| 2568 |
layer3_______________________________________________________ |
| 2569 |
|
| 2570 |
*===================* |
| 2571 |
| v4 | |
| 2572 |
*===================* |
| 2573 |
_____________________________________________________________ |
| 2574 |
layer4_______________________________________________________ |
| 2575 |
|
| 2576 |
*=================* |
| 2577 |
| v5 | |
| 2578 |
*=================* |
| 2579 |
""" |
| 2580 |
|
| 2581 |
# trim end of g2 and move layer. Without the snap, would fail since |
| 2582 |
# a2's duration-limit is 12. |
| 2583 |
# Even elements not being trimmed will still move layer |
| 2584 |
# a0 and a1 keep transition |
| 2585 |
# v2 and v3 keep transition |
| 2586 |
self.assertEdit( |
| 2587 |
g2, 1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 29, 27, |
| 2588 |
[a2, a4, v1, v3], [v5], |
| 2589 |
{ |
| 2590 |
a2 : {"duration": 12, "layer": 2}, |
| 2591 |
v1 : {"duration": 16, "layer": 2}, |
| 2592 |
a4 : {"duration": 12, "layer": 3}, |
| 2593 |
v3 : {"duration": 15, "layer": 3}, |
| 2594 |
g1 : {"duration": 16, "layer": 2}, |
| 2595 |
g2 : {"duration": 16, "layer": 1}, |
| 2596 |
a0 : {"layer": 1}, |
| 2597 |
a1 : {"layer": 1}, |
| 2598 |
v0 : {"layer": 1}, |
| 2599 |
a3 : {"layer": 3}, |
| 2600 |
v2 : {"layer": 3}, |
| 2601 |
g0 : {"layer": 1}, |
| 2602 |
}, [], []) |
| 2603 |
|
| 2604 |
# trim start to use as a snapping point |
| 2605 |
self.timeline.set_snapping_distance(0) |
| 2606 |
self.assertEdit( |
| 2607 |
v5, 4, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 19, None, |
| 2608 |
[], [], |
| 2609 |
{ |
| 2610 |
v5 : {"start": 19, "in-point": 1, "duration": 8}, |
| 2611 |
}, [], []) |
| 2612 |
|
| 2613 |
self.timeline.set_snapping_distance(2) |
| 2614 |
""" |
| 2615 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2616 |
0 5 10 15 20 25 30 |
| 2617 |
_____________________________________________________________ |
| 2618 |
layer0_______________________________________________________ |
| 2619 |
_____________________________________________________________ |
| 2620 |
layer1_______________________________________________________ |
| 2621 |
|
| 2622 |
.............g2.................. |
| 2623 |
: : |
| 2624 |
:.......g0......... : |
| 2625 |
: *===============* : |
| 2626 |
: | a0 | : |
| 2627 |
*=*=====*=========* : |
| 2628 |
| a1 | : : |
| 2629 |
*=======* : : |
| 2630 |
*=======* : : |
| 2631 |
| v0 | : : |
| 2632 |
*=======* : : |
| 2633 |
:.................: : |
| 2634 |
______________________:_______________________________:______ |
| 2635 |
layer2________________:_______________________________:______ |
| 2636 |
: : |
| 2637 |
:.........g1....................: |
| 2638 |
: *=======================* |
| 2639 |
: | a2 | |
| 2640 |
: *=======================* |
| 2641 |
*===============================* |
| 2642 |
| v1 | |
| 2643 |
*===============================* |
| 2644 |
______________________:_______________________________:______ |
| 2645 |
layer3________________:_______________________________:______ |
| 2646 |
*=* *=======================* |
| 2647 |
a3| | a4 | |
| 2648 |
*=* *=======================* |
| 2649 |
:...............................: |
| 2650 |
*===================*=============* : |
| 2651 |
| v4 | v2 | : |
| 2652 |
*===================*=*===========*=================* |
| 2653 |
: | v3 | |
| 2654 |
: *=============================* |
| 2655 |
:...............................: |
| 2656 |
_____________________________________________________________ |
| 2657 |
layer4_______________________________________________________ |
| 2658 |
|
| 2659 |
*===============* |
| 2660 |
| v5 | |
| 2661 |
*===============* |
| 2662 |
""" |
| 2663 |
|
| 2664 |
# trim end of g2 and move layer. Trim at 17 would lead to |
| 2665 |
# v3 being fully overlapped by v2, but snap to 19 makes it work |
| 2666 |
self.assertEdit( |
| 2667 |
g2, 1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 17, 19, |
| 2668 |
[a2, a4, v1, v3], [v5], |
| 2669 |
{ |
| 2670 |
a0 : {"duration": 7}, |
| 2671 |
a2 : {"duration": 4}, |
| 2672 |
v1 : {"duration": 8}, |
| 2673 |
a4 : {"duration": 4}, |
| 2674 |
v3 : {"duration": 7}, |
| 2675 |
g0 : {"duration": 8}, |
| 2676 |
g1 : {"duration": 8}, |
| 2677 |
g2 : {"duration": 8}, |
| 2678 |
}, [], []) |
| 2679 |
|
| 2680 |
""" |
| 2681 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2682 |
0 5 10 15 20 25 30 |
| 2683 |
_____________________________________________________________ |
| 2684 |
layer0_______________________________________________________ |
| 2685 |
_____________________________________________________________ |
| 2686 |
layer1_______________________________________________________ |
| 2687 |
|
| 2688 |
........g2....... |
| 2689 |
: : |
| 2690 |
:.......g0......: |
| 2691 |
: *=============* |
| 2692 |
: | a0 | |
| 2693 |
*=*=====*=======* |
| 2694 |
| a1 | : |
| 2695 |
*=======* : |
| 2696 |
*=======* : |
| 2697 |
| v0 | : |
| 2698 |
*=======* : |
| 2699 |
:...............: |
| 2700 |
______________________:_______________:______________________ |
| 2701 |
layer2________________:_______________:______________________ |
| 2702 |
: : |
| 2703 |
:.......g1......: |
| 2704 |
: *=======* |
| 2705 |
: | a2 | |
| 2706 |
: *=======* |
| 2707 |
*===============* |
| 2708 |
| v1 | |
| 2709 |
*===============* |
| 2710 |
______________________:_______________:______________________ |
| 2711 |
layer3________________:_______________:______________________ |
| 2712 |
*=* *=======* |
| 2713 |
a3| | a4 | |
| 2714 |
*=* *=======* |
| 2715 |
:...............: |
| 2716 |
*===================*=============* : |
| 2717 |
| v4 | v2 | : |
| 2718 |
*===================*=*===========*=* |
| 2719 |
: | v3 | |
| 2720 |
: *=============* |
| 2721 |
:...............: |
| 2722 |
_____________________________________________________________ |
| 2723 |
layer4_______________________________________________________ |
| 2724 |
|
| 2725 |
*===============* |
| 2726 |
| v5 | |
| 2727 |
*===============* |
| 2728 |
""" |
| 2729 |
|
| 2730 |
# can trim without trimming parent |
| 2731 |
self.assertEdit( |
| 2732 |
v0, 1, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 5, None, [], [], |
| 2733 |
{ |
| 2734 |
v0 : {"start": 5, "in-point": 5, "duration": 10}, |
| 2735 |
g0 : {"start": 5, "duration": 14}, |
| 2736 |
g2 : {"start": 5, "duration": 14}, |
| 2737 |
}, [], []) |
| 2738 |
|
| 2739 |
self.assertEdit( |
| 2740 |
a2, 2, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 23, None, [], [], |
| 2741 |
{ |
| 2742 |
a2 : {"duration": 8}, |
| 2743 |
g1 : {"duration": 12}, |
| 2744 |
g2 : {"duration": 18}, |
| 2745 |
}, [], []) |
| 2746 |
""" |
| 2747 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2748 |
0 5 10 15 20 25 30 |
| 2749 |
_____________________________________________________________ |
| 2750 |
layer0_______________________________________________________ |
| 2751 |
_____________________________________________________________ |
| 2752 |
layer1_______________________________________________________ |
| 2753 |
|
| 2754 |
...................g2................ |
| 2755 |
: : |
| 2756 |
:...........g0............... : |
| 2757 |
: *=============* : |
| 2758 |
: | a0 | : |
| 2759 |
: *=*=====*=======* : |
| 2760 |
: | a1 | : : |
| 2761 |
: *=======* : : |
| 2762 |
*===================* : : |
| 2763 |
| v0 | : : |
| 2764 |
*===================* : : |
| 2765 |
:...........................: : |
| 2766 |
__________:___________________________________:______________ |
| 2767 |
layer2____:___________________________________:______________ |
| 2768 |
: : |
| 2769 |
: ............g1..........: |
| 2770 |
: : *===============* |
| 2771 |
: : | a2 | |
| 2772 |
: : *===============* |
| 2773 |
: *===============* : |
| 2774 |
: | v1 | : |
| 2775 |
: *===============* : |
| 2776 |
__________:___________:_______________________:______________ |
| 2777 |
layer3____:___________:_______________________:______________ |
| 2778 |
: *=* *=======* : |
| 2779 |
: a3| | a4 | : |
| 2780 |
: *=* *=======* : |
| 2781 |
: :.......................: |
| 2782 |
*===================*=============* : |
| 2783 |
| v4 | v2 | : |
| 2784 |
*===================*=*===========*=* : |
| 2785 |
: | v3 | : |
| 2786 |
: *=============* : |
| 2787 |
:...................................: |
| 2788 |
_____________________________________________________________ |
| 2789 |
layer4_______________________________________________________ |
| 2790 |
|
| 2791 |
*===============* |
| 2792 |
| v5 | |
| 2793 |
*===============* |
| 2794 |
""" |
| 2795 |
# same with group within a group |
| 2796 |
self.assertEdit( |
| 2797 |
g0, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_START, 9, 11, |
| 2798 |
[v0], [v1, v2, v4, a3], |
| 2799 |
{ |
| 2800 |
v0 : {"start": 11, "in-point": 11, "duration": 4, "layer": 0}, |
| 2801 |
a0 : {"layer": 0}, |
| 2802 |
a1 : {"layer": 0}, |
| 2803 |
g0 : {"start": 11, "duration": 8, "layer": 0}, |
| 2804 |
g2 : {"start": 11, "duration": 12, "layer": 0}, |
| 2805 |
}, [], []) |
| 2806 |
|
| 2807 |
self.assertEdit( |
| 2808 |
g0, 0, GES.EditMode.EDIT_TRIM, GES.Edge.EDGE_END, 17, 18, |
| 2809 |
[a0], [v2], |
| 2810 |
{ |
| 2811 |
a0 : {"duration": 6}, |
| 2812 |
g0 : {"duration": 7}, |
| 2813 |
}, [], []) |
| 2814 |
|
| 2815 |
|
| 2816 |
def test_roll(self): |
| 2817 |
""" |
| 2818 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 2819 |
0 5 10 15 20 25 30 |
| 2820 |
_____________________________________________________________ |
| 2821 |
layer0_______________________________________________________ |
| 2822 |
|
| 2823 |
*===============================* ] |
| 2824 |
| c0 | ] |
| 2825 |
*=============*=====*===================*=====*=============* ]>video |
| 2826 |
| c1 | | c2 | ] |
| 2827 |
*===================* *===================* ] |
| 2828 |
..........g0......... |
| 2829 |
*===========* : ] |
| 2830 |
| c3 | : ]>audio0 |
| 2831 |
*===*=======*===* : ] |
| 2832 |
: | c4 | : ] ] |
| 2833 |
: *===*=======*===* ] |
| 2834 |
: | c5 | ]>audio1 |
| 2835 |
: *===========* ] |
| 2836 |
____________________:___________________:____________________ |
| 2837 |
layer1______________:___________________:____________________ |
| 2838 |
: : |
| 2839 |
.............g3.....:.... : |
| 2840 |
: *=================* : ] |
| 2841 |
: | c12 | ....:...g4............... ] |
| 2842 |
: *=================* : : : ] |
| 2843 |
:........g1.........: : : :.........g2........: ]>audio0 |
| 2844 |
*=============* : : : *=============* : ] |
| 2845 |
| c8 | : : : | c10 | : ] |
| 2846 |
*=============* : : *=========*=============* : ] |
| 2847 |
: : : | c7 | : ] ] |
| 2848 |
: *=========*=========* : ]>video |
| 2849 |
: | c6 | : : : ] ] |
| 2850 |
: *=============*=========* : : *=============* ] |
| 2851 |
: | c9 |...:...........:...: | c11 | ] |
| 2852 |
: *=============* : : : *=============* ] |
| 2853 |
:...................: : : :...................: ]>audio1 |
| 2854 |
:.......................: *=================* : ] |
| 2855 |
| c13 | : ] |
| 2856 |
*=================* : ] |
| 2857 |
:.......................: |
| 2858 |
""" |
| 2859 |
video = self.add_video_track() |
| 2860 |
audio0 = self.add_audio_track() |
| 2861 |
audio1 = self.add_audio_track() |
| 2862 |
|
| 2863 |
c0 = self.add_clip("c0", 0, [video], 7, 16) |
| 2864 |
c1 = self.add_clip("c1", 0, [video], 0, 10) |
| 2865 |
c2 = self.add_clip("c2", 0, [video], 20, 10, 20) |
| 2866 |
self.register_auto_transition(c1, c0, video) |
| 2867 |
self.register_auto_transition(c0, c2, video) |
| 2868 |
|
| 2869 |
c3 = self.add_clip("c3", 0, [audio0], 10, 6, 2, 38) |
| 2870 |
c4 = self.add_clip("c4", 0, [audio0, audio1], 12, 6, 15) |
| 2871 |
self.register_auto_transition(c3, c4, audio0) |
| 2872 |
c5 = self.add_clip("c5", 0, [audio1], 14, 6, 30, 38) |
| 2873 |
self.register_auto_transition(c4, c5, audio1) |
| 2874 |
c6 = self.add_clip("c6", 1, [audio1, video], 10, 5, 7) |
| 2875 |
c7 = self.add_clip("c7", 1, [audio0, video], 15, 5, 1, 15) |
| 2876 |
g0 = self.add_group("g0", [c3, c4, c5, c6, c7]) |
| 2877 |
|
| 2878 |
c8 = self.add_clip("c8", 1, [audio0], 0, 7, 3, 13) |
| 2879 |
c9 = self.add_clip("c9", 1, [audio1], 3, 7) |
| 2880 |
g1 = self.add_group("g1", [c8, c9]) |
| 2881 |
c10 = self.add_clip("c10", 1, [audio0], 20, 7, 1) |
| 2882 |
c11 = self.add_clip("c11", 1, [audio1], 23, 7, 3, 10) |
| 2883 |
g2 = self.add_group("g2", [c10, c11]) |
| 2884 |
|
| 2885 |
c12 = self.add_clip("c12", 1, [audio0], 3, 9) |
| 2886 |
self.register_auto_transition(c8, c12, audio0) |
| 2887 |
g3 = self.add_group("g3", [g1, c12]) |
| 2888 |
c13 = self.add_clip("c13", 1, [audio1], 18, 9) |
| 2889 |
self.register_auto_transition(c13, c11, audio1) |
| 2890 |
g4 = self.add_group("g4", [g2, c13]) |
| 2891 |
|
| 2892 |
self.assertTimelineConfig() |
| 2893 |
|
| 2894 |
# edit failures |
| 2895 |
self.timeline.set_snapping_distance(2) |
| 2896 |
|
| 2897 |
# cannot roll c10 to 22, which snaps to 23, because it will |
| 2898 |
# extend c5 beyond its duration limit of 8 |
| 2899 |
self.assertFailEdit( |
| 2900 |
c10, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 22, |
| 2901 |
GES.Error.NOT_ENOUGH_INTERNAL_CONTENT) |
| 2902 |
|
| 2903 |
# same with g2 |
| 2904 |
self.assertFailEdit( |
| 2905 |
g2, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 22, |
| 2906 |
GES.Error.NOT_ENOUGH_INTERNAL_CONTENT) |
| 2907 |
|
| 2908 |
# cannot roll end c9 to 8, which snaps to 7, because it would |
| 2909 |
# cause c3's in-point to become negative |
| 2910 |
self.assertFailEdit( |
| 2911 |
c9, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 8, |
| 2912 |
GES.Error.NEGATIVE_TIME) |
| 2913 |
|
| 2914 |
# same with g1 |
| 2915 |
self.assertFailEdit( |
| 2916 |
g1, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 8, |
| 2917 |
GES.Error.NEGATIVE_TIME) |
| 2918 |
|
| 2919 |
# cannot roll c13 to 19, snap to 20, because it would cause |
| 2920 |
# c4 to fully overlap c5 |
| 2921 |
self.assertFailEdit( |
| 2922 |
c13, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 19, |
| 2923 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 2924 |
|
| 2925 |
# cannot roll c12 to 11, snap to 10, because it would cause |
| 2926 |
# c3 to fully overlap c4 |
| 2927 |
self.assertFailEdit( |
| 2928 |
c12, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 11, |
| 2929 |
GES.Error.INVALID_OVERLAP_IN_TRACK) |
| 2930 |
|
| 2931 |
# give c6 a bit more allowed duration so we can focus on c9 |
| 2932 |
self.assertTrue(c6.set_inpoint(10)) |
| 2933 |
self.assertTimelineConfig({ c6 : {"in-point": 10}}) |
| 2934 |
# cannot roll c6 to 0 because it would cause c9 to be trimmed |
| 2935 |
# below its start |
| 2936 |
self.assertFailEdit( |
| 2937 |
c6, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 0, |
| 2938 |
GES.Error.NEGATIVE_TIME) |
| 2939 |
# set back |
| 2940 |
self.assertTrue(c6.set_inpoint(7)) |
| 2941 |
self.assertTimelineConfig({ c6 : {"in-point": 7}}) |
| 2942 |
|
| 2943 |
# give c7 a bit more allowed duration so we can focus on c10 |
| 2944 |
self.assertTrue(c7.set_inpoint(0)) |
| 2945 |
self.assertTimelineConfig({ c7 : {"in-point": 0}}) |
| 2946 |
# cannot roll end c7 to 30 because it would cause c10 to be |
| 2947 |
# trimmed beyond its end |
| 2948 |
self.assertFailEdit( |
| 2949 |
c7, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 30, |
| 2950 |
GES.Error.NEGATIVE_TIME) |
| 2951 |
# set back |
| 2952 |
self.assertTrue(c7.set_inpoint(1)) |
| 2953 |
self.assertTimelineConfig({ c7 : {"in-point": 1}}) |
| 2954 |
|
| 2955 |
# moving layer is not supported |
| 2956 |
self.assertFailEdit( |
| 2957 |
c0, 2, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 7, None) |
| 2958 |
self.assertFailEdit( |
| 2959 |
c0, 2, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 23, None) |
| 2960 |
|
| 2961 |
# successes |
| 2962 |
self.timeline.set_snapping_distance(0) |
| 2963 |
|
| 2964 |
# c1 and g1 are trimmed at their end |
| 2965 |
# NOTE: c12 is not trimmed even though it shares a group g3 |
| 2966 |
# with g1 because g3 does not share the same edge |
| 2967 |
# trim forward |
| 2968 |
self.assertEdit( |
| 2969 |
c6, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 11, None, |
| 2970 |
[], [], |
| 2971 |
{ |
| 2972 |
c6 : {"start": 11, "in-point": 8, "duration": 4}, |
| 2973 |
c1 : {"duration": 11}, |
| 2974 |
c9 : {"duration": 8}, |
| 2975 |
g1 : {"duration": 11}, |
| 2976 |
}, [], []) |
| 2977 |
# and reset |
| 2978 |
self.assertEdit( |
| 2979 |
c6, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 10, None, |
| 2980 |
[], [], |
| 2981 |
{ |
| 2982 |
c6 : {"start": 10, "in-point": 7, "duration": 5}, |
| 2983 |
c1 : {"duration": 10}, |
| 2984 |
c9 : {"duration": 7}, |
| 2985 |
g1 : {"duration": 10}, |
| 2986 |
}, [], []) |
| 2987 |
|
| 2988 |
# same with g0 |
| 2989 |
self.assertEdit( |
| 2990 |
g0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 11, None, |
| 2991 |
[], [], |
| 2992 |
{ |
| 2993 |
c6 : {"start": 11, "in-point": 8, "duration": 4}, |
| 2994 |
c3 : {"start": 11, "in-point": 3, "duration": 5}, |
| 2995 |
g0 : {"start": 11, "duration": 9}, |
| 2996 |
c1 : {"duration": 11}, |
| 2997 |
c9 : {"duration": 8}, |
| 2998 |
g1 : {"duration": 11}, |
| 2999 |
}, [], []) |
| 3000 |
self.assertEdit( |
| 3001 |
g0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 10, None, |
| 3002 |
[], [], |
| 3003 |
{ |
| 3004 |
c6 : {"start": 10, "in-point": 7, "duration": 5}, |
| 3005 |
c3 : {"start": 10, "in-point": 2, "duration": 6}, |
| 3006 |
g0 : {"start": 10, "duration": 10}, |
| 3007 |
c1 : {"duration": 10}, |
| 3008 |
c9 : {"duration": 7}, |
| 3009 |
g1 : {"duration": 10}, |
| 3010 |
}, [], []) |
| 3011 |
|
| 3012 |
self.timeline.set_snapping_distance(1) |
| 3013 |
# trim backward |
| 3014 |
# NOTE: c9 has zero width, not considered overlapping with c6 |
| 3015 |
# snapping allows the edit to succeed (in-point of c6 no longer |
| 3016 |
# negative) |
| 3017 |
# NOTE: c12 does not move, but c8 does because it is in the same |
| 3018 |
# group as g1 |
| 3019 |
# loose transitions |
| 3020 |
self.assertEdit( |
| 3021 |
c6, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 2, 3, |
| 3022 |
[c6], [c12], |
| 3023 |
{ |
| 3024 |
c6 : {"start": 3, "in-point": 0, "duration": 12}, |
| 3025 |
g0 : {"start": 3, "duration": 17}, |
| 3026 |
c1 : {"duration": 3}, |
| 3027 |
c8 : {"duration": 3}, |
| 3028 |
c9 : {"duration": 0}, |
| 3029 |
g1 : {"duration": 3}, |
| 3030 |
}, [], [(c1, c0, video), (c8, c12, audio0)]) |
| 3031 |
|
| 3032 |
# bring back |
| 3033 |
# NOTE: no snapping to c3 start edge because it is part of the |
| 3034 |
# element being edited, g0, even though it doesn't end up changing |
| 3035 |
# gain back new transitions |
| 3036 |
self.assertEdit( |
| 3037 |
g0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 10, None, |
| 3038 |
[], [], |
| 3039 |
{ |
| 3040 |
c6 : {"start": 10, "in-point": 7, "duration": 5}, |
| 3041 |
g0 : {"start": 10, "duration": 10}, |
| 3042 |
c1 : {"duration": 10}, |
| 3043 |
c8 : {"duration": 10}, |
| 3044 |
c9 : {"duration": 7}, |
| 3045 |
g1 : {"duration": 10}, |
| 3046 |
}, [(c1, c0, video), (c8, c12, audio0)], []) |
| 3047 |
|
| 3048 |
|
| 3049 |
# same but with the end edge of g0 |
| 3050 |
self.timeline.set_snapping_distance(0) |
| 3051 |
self.assertEdit( |
| 3052 |
c7, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 19, None, [], [], |
| 3053 |
{ |
| 3054 |
c7 : {"duration": 4}, |
| 3055 |
c2 : {"start": 19, "in-point": 19, "duration": 11}, |
| 3056 |
c10 : {"start": 19, "in-point": 0, "duration": 8}, |
| 3057 |
g2 : {"start": 19, "duration": 11}, |
| 3058 |
}, [], []) |
| 3059 |
self.assertEdit( |
| 3060 |
c7, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 20, None, [], [], |
| 3061 |
{ |
| 3062 |
c7 : {"duration": 5}, |
| 3063 |
c2 : {"start": 20, "in-point": 20, "duration": 10}, |
| 3064 |
c10 : {"start": 20, "in-point": 1, "duration": 7}, |
| 3065 |
g2 : {"start": 20, "duration": 10}, |
| 3066 |
}, [], []) |
| 3067 |
# do same with g0 |
| 3068 |
self.assertEdit( |
| 3069 |
g0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 19, None, [], [], |
| 3070 |
{ |
| 3071 |
c7 : {"duration": 4}, |
| 3072 |
c5 : {"duration": 5}, |
| 3073 |
g0 : {"duration": 9}, |
| 3074 |
c2 : {"start": 19, "in-point": 19, "duration": 11}, |
| 3075 |
c10 : {"start": 19, "in-point": 0, "duration": 8}, |
| 3076 |
g2 : {"start": 19, "duration": 11}, |
| 3077 |
}, [], []) |
| 3078 |
self.assertEdit( |
| 3079 |
g0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 20, None, [], [], |
| 3080 |
{ |
| 3081 |
c7 : {"duration": 5}, |
| 3082 |
c5 : {"duration": 6}, |
| 3083 |
g0 : {"duration": 10}, |
| 3084 |
c2 : {"start": 20, "in-point": 20, "duration": 10}, |
| 3085 |
c10 : {"start": 20, "in-point": 1, "duration": 7}, |
| 3086 |
g2 : {"start": 20, "duration": 10}, |
| 3087 |
}, [], []) |
| 3088 |
|
| 3089 |
self.timeline.set_snapping_distance(1) |
| 3090 |
# trim forwards |
| 3091 |
# NOTE: c10 has zero width, not considered overlapping with c7 |
| 3092 |
# snapping allows the edit to succeed (duration of c7 no longer |
| 3093 |
# above its limit) |
| 3094 |
# NOTE: c12 does not move, but c11 does because it is in the same |
| 3095 |
# group as g2 |
| 3096 |
self.assertEdit( |
| 3097 |
c7, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 28, 27, |
| 3098 |
[c7], [c13], |
| 3099 |
{ |
| 3100 |
c7 : {"duration": 12}, |
| 3101 |
g0 : {"duration": 17}, |
| 3102 |
c2 : {"start": 27, "in-point": 27, "duration": 3}, |
| 3103 |
c10 : {"start": 27, "in-point": 8, "duration": 0}, |
| 3104 |
c11 : {"start": 27, "in-point": 7, "duration": 3}, |
| 3105 |
g2 : {"start": 27, "duration": 3}, |
| 3106 |
}, [], [(c0, c2, video), (c13, c11, audio1)]) |
| 3107 |
# bring back using g0 |
| 3108 |
# NOTE: no snapping to c5 end edge because it is part of the |
| 3109 |
# element being edited, g0, even though it doesn't end up changing |
| 3110 |
self.assertEdit( |
| 3111 |
g0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 20, None, [], [], |
| 3112 |
{ |
| 3113 |
c7 : {"duration": 5}, |
| 3114 |
g0 : {"duration": 10}, |
| 3115 |
c2 : {"start": 20, "in-point": 20, "duration": 10}, |
| 3116 |
c10 : {"start": 20, "in-point": 1, "duration": 7}, |
| 3117 |
c11 : {"start": 20, "in-point": 0, "duration": 10}, |
| 3118 |
g2 : {"start": 20, "duration": 10}, |
| 3119 |
}, [(c0, c2, video), (c13, c11, audio1)], []) |
| 3120 |
|
| 3121 |
# adjust c0 for snapping |
| 3122 |
# doesn't move anything else |
| 3123 |
self.assertEdit( |
| 3124 |
c0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 8, None, |
| 3125 |
[], [], |
| 3126 |
{ |
| 3127 |
c0 : {"start": 8, "in-point": 1, "duration": 15}, |
| 3128 |
}, [], []) |
| 3129 |
self.assertEdit( |
| 3130 |
c0, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 22, None, [], [], |
| 3131 |
{ |
| 3132 |
c0 : {"duration": 14}, |
| 3133 |
}, [], []) |
| 3134 |
""" |
| 3135 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3136 |
0 5 10 15 20 25 30 |
| 3137 |
_____________________________________________________________ |
| 3138 |
layer0_______________________________________________________ |
| 3139 |
|
| 3140 |
*===========================* ] |
| 3141 |
| c0 | ] |
| 3142 |
*===============*===*===================*===*===============* ]>video |
| 3143 |
| c1 | | c2 | ] |
| 3144 |
*===================* *===================* ] |
| 3145 |
..........g0......... |
| 3146 |
*===========* : ] |
| 3147 |
| c3 | : ]>audio0 |
| 3148 |
*===*=======*===* : ] |
| 3149 |
: | c4 | : ] ] |
| 3150 |
: *===*=======*===* ] |
| 3151 |
: | c5 | ]>audio1 |
| 3152 |
: *===========* ] |
| 3153 |
____________________:___________________:____________________ |
| 3154 |
layer1______________:___________________:____________________ |
| 3155 |
: : |
| 3156 |
.............g3.....:.... : |
| 3157 |
: *=================* : ] |
| 3158 |
: | c12 | ....:...g4............... ] |
| 3159 |
: *=================* : : : ] |
| 3160 |
:........g1.........: : : :.........g2........: ]>audio0 |
| 3161 |
*===================* : : *=============* : ] |
| 3162 |
| c8 | : : | c10 | : ] |
| 3163 |
*===================* : *=========*=============* : ] |
| 3164 |
: : : | c7 | : ] ] |
| 3165 |
: *=========*=========* : ]>video |
| 3166 |
: | c6 | : : : ] ] |
| 3167 |
: *=============*=========* : *===================* ] |
| 3168 |
: | c9 |...:...........:...| c11 | ] |
| 3169 |
: *=============* : : *===================* ] |
| 3170 |
:...................: : : :...................: ]>audio1 |
| 3171 |
:.......................: *=================* : ] |
| 3172 |
| c13 | : ] |
| 3173 |
*=================* : ] |
| 3174 |
:.......................: |
| 3175 |
""" |
| 3176 |
# rolling only moves an element if it contains a source that |
| 3177 |
# touches the rolling edge. For a group, any source below it |
| 3178 |
# at the corresponding edge counts, we also prefer trimming the |
| 3179 |
# whole group over just one of its childrens. |
| 3180 |
# As such, when rolling the end of c5, c11 shares the audio1 |
| 3181 |
# track and starts when c5 ends, so is set to be trimmed. But it |
| 3182 |
# is also at the start edge of its parent g2, so g2 is set to be |
| 3183 |
# trimmed. However, it is not at the start of g4, so g4 is not |
| 3184 |
# set to be trimmed. As such, c10 will also move, even though it |
| 3185 |
# does not share a track. c2, on the other hand, will not move |
| 3186 |
# NOTE: snapping helps keep c5's duration below its limit (8) |
| 3187 |
self.assertEdit( |
| 3188 |
c5, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 23, 22, |
| 3189 |
[c5], [c0], |
| 3190 |
{ |
| 3191 |
c5 : {"duration": 8}, |
| 3192 |
g0 : {"duration": 12}, |
| 3193 |
c11 : {"start": 22, "in-point": 2, "duration": 8}, |
| 3194 |
c10 : {"start": 22, "in-point": 3, "duration": 5}, |
| 3195 |
g2 : {"start": 22, "duration": 8}, |
| 3196 |
}, [], []) |
| 3197 |
|
| 3198 |
# same with c3 at its start edge |
| 3199 |
self.assertEdit( |
| 3200 |
c3, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 7, 8, |
| 3201 |
[c3], [c0], |
| 3202 |
{ |
| 3203 |
c3 : {"start": 8, "in-point": 0, "duration": 8}, |
| 3204 |
g0 : {"start": 8, "duration": 14}, |
| 3205 |
c8 : {"duration": 8}, |
| 3206 |
c9 : {"duration": 5}, |
| 3207 |
g1 : {"duration": 8}, |
| 3208 |
}, [], []) |
| 3209 |
""" |
| 3210 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3211 |
0 5 10 15 20 25 30 |
| 3212 |
_____________________________________________________________ |
| 3213 |
layer0_______________________________________________________ |
| 3214 |
|
| 3215 |
*===========================* ] |
| 3216 |
| c0 | ] |
| 3217 |
*===============*===*===================*===*===============* ]>video |
| 3218 |
| c1 | | c2 | ] |
| 3219 |
*===================* *===================* ] |
| 3220 |
..............g0............. |
| 3221 |
*===============* : ] |
| 3222 |
| c3 | : ]>audio0 |
| 3223 |
*=======*=======*===* : ] |
| 3224 |
: | c4 | : ] ] |
| 3225 |
: *===*=======*=======* ] |
| 3226 |
: | c5 | ]>audio1 |
| 3227 |
: *===============* ] |
| 3228 |
________________:___________________________:________________ |
| 3229 |
layer1__________:___________________________:________________ |
| 3230 |
: : |
| 3231 |
.............g3.:........ : |
| 3232 |
: *=================* : ] |
| 3233 |
: | c12 | ........:.g4............. ] |
| 3234 |
: *=================* : : : ] |
| 3235 |
:........g1.....: : : :.....g2........: ]>audio0 |
| 3236 |
*===============* : : *=========* : ] |
| 3237 |
| c8 | : : | c10 | : ] |
| 3238 |
*===============* : *=========* *=========* : ] |
| 3239 |
: : : | c7 | : : ] ] |
| 3240 |
: : *=========*=========* : : ]>video |
| 3241 |
: : | c6 | : : : ] ] |
| 3242 |
: *=========* *=========* : *===============* ] |
| 3243 |
: | c9 |.......:...........:.......| c11 | ] |
| 3244 |
: *=========* : : *===============* ] |
| 3245 |
:...............: : : :...............: ]>audio1 |
| 3246 |
:.......................: *=================* : ] |
| 3247 |
| c13 | : ] |
| 3248 |
*=================* : ] |
| 3249 |
:.......................: |
| 3250 |
""" |
| 3251 |
# rolling end of c1 only moves c6, similarly with c2 and c7 |
| 3252 |
self.assertEdit( |
| 3253 |
c1, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 8, 8, |
| 3254 |
[c1], [c9, c8, c3, c0], |
| 3255 |
{ |
| 3256 |
c1 : {"duration": 8}, |
| 3257 |
c6 : {"start": 8, "in-point": 5, "duration": 7}, |
| 3258 |
}, [], [(c1, c0, video)]) |
| 3259 |
self.assertEdit( |
| 3260 |
c2, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 22, 22, |
| 3261 |
[c2], [c0, c5, c10, c11], |
| 3262 |
{ |
| 3263 |
c2 : {"start": 22, "in-point": 22, "duration": 8}, |
| 3264 |
c7 : {"duration": 7}, |
| 3265 |
}, [], [(c0, c2, video)]) |
| 3266 |
|
| 3267 |
# move c3 end edge out the way |
| 3268 |
self.timeline.set_snapping_distance(0) |
| 3269 |
self.assertEdit( |
| 3270 |
c3, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 17, None, [], [], |
| 3271 |
{ |
| 3272 |
c3: {"duration": 9}, |
| 3273 |
}, [], []) |
| 3274 |
|
| 3275 |
self.timeline.set_snapping_distance(2) |
| 3276 |
|
| 3277 |
""" |
| 3278 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3279 |
0 5 10 15 20 25 30 |
| 3280 |
_____________________________________________________________ |
| 3281 |
layer0_______________________________________________________ |
| 3282 |
|
| 3283 |
*===========================* ] |
| 3284 |
| c0 | ] |
| 3285 |
*===============*===========================*===============* ]>video |
| 3286 |
| c1 | | c2 | ] |
| 3287 |
*===============* *===============* ] |
| 3288 |
..............g0............. |
| 3289 |
*=================* : ] |
| 3290 |
| c3 | : ]>audio0 |
| 3291 |
*=======*=========*=* : ] |
| 3292 |
: | c4 | : ] ] |
| 3293 |
: *===*=======*=======* ] |
| 3294 |
: | c5 | ]>audio1 |
| 3295 |
: *===============* ] |
| 3296 |
________________:___________________________:________________ |
| 3297 |
layer1__________:___________________________:________________ |
| 3298 |
: : |
| 3299 |
.............g3.:........ : |
| 3300 |
: *=================* : ] |
| 3301 |
: | c12 | ........:.g4............. ] |
| 3302 |
: *=================* : : : ] |
| 3303 |
:........g1.....: : : :.....g2........: ]>audio0 |
| 3304 |
*===============* : : *=========* : ] |
| 3305 |
| c8 | : : | c10 | : ] |
| 3306 |
*===============* : *=============*=========* : ] |
| 3307 |
: : : | c7 | : ] ] |
| 3308 |
: *=============*=============* : ]>video |
| 3309 |
: | c6 | : : : ] ] |
| 3310 |
: *=========*=============* : *===============* ] |
| 3311 |
: | c9 |.......:...........:.......| c11 | ] |
| 3312 |
: *=========* : : *===============* ] |
| 3313 |
:...............: : : :...............: ]>audio1 |
| 3314 |
:.......................: *=================* : ] |
| 3315 |
| c13 | : ] |
| 3316 |
*=================* : ] |
| 3317 |
:.......................: |
| 3318 |
""" |
| 3319 |
|
| 3320 |
# can safely roll within a group |
| 3321 |
# NOTE: we do not snap to an edge used in the edit |
| 3322 |
self.assertEdit( |
| 3323 |
c6, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_END, 15, 14, |
| 3324 |
[c6], [c5], |
| 3325 |
{ |
| 3326 |
c6: {"duration": 6}, |
| 3327 |
c7: {"start": 14, "in-point": 0, "duration": 8}, |
| 3328 |
}, [], []) |
| 3329 |
self.assertEdit( |
| 3330 |
c7, -1, GES.EditMode.EDIT_ROLL, GES.Edge.EDGE_START, 16, 17, |
| 3331 |
[c7], [c3], |
| 3332 |
{ |
| 3333 |
c6: {"duration": 9}, |
| 3334 |
c7: {"start": 17, "in-point": 3, "duration": 5}, |
| 3335 |
}, [], []) |
| 3336 |
|
| 3337 |
def test_snap_from_negative(self): |
| 3338 |
track = self.add_video_track() |
| 3339 |
c0 = self.add_clip("c0", 0, [track], 0, 20) |
| 3340 |
c1 = self.add_clip("c1", 0, [track], 100, 10) |
| 3341 |
g1 = self.add_group("g0", [c0, c1]) |
| 3342 |
snap_to = self.add_clip("snap-to", 2, [track], 4, 50) |
| 3343 |
|
| 3344 |
self.assertTimelineConfig() |
| 3345 |
|
| 3346 |
self.timeline.set_snapping_distance(9) |
| 3347 |
# move without snap would make start edge of c0 go to -5, but this |
| 3348 |
# edge snaps to the start edge of snap_to, allowing the edit to |
| 3349 |
# succeed |
| 3350 |
self.assertEdit( |
| 3351 |
c1, 1, GES.EditMode.NORMAL, GES.Edge.NONE, 95, 4, [c0], [snap_to], |
| 3352 |
{ |
| 3353 |
c0 : {"start": 4, "layer": 1}, |
| 3354 |
c1 : {"start": 104, "layer": 1}, |
| 3355 |
g1 : {"start": 4, "layer": 1}, |
| 3356 |
}, [], []) |
| 3357 |
|
| 3358 |
def test_move_layer(self): |
| 3359 |
""" |
| 3360 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3361 |
0 5 10 15 20 25 30 |
| 3362 |
_____________________________________________________________ |
| 3363 |
layer0_______________________________________________________ |
| 3364 |
|
| 3365 |
*===================* |
| 3366 |
| c1 | |
| 3367 |
*===================* |
| 3368 |
..............g2............... |
| 3369 |
: : |
| 3370 |
:.............g0..............: |
| 3371 |
*=============================* |
| 3372 |
| c0 | |
| 3373 |
*=============================* |
| 3374 |
: : |
| 3375 |
: : |
| 3376 |
__________:_____________________________:____________________ |
| 3377 |
layer1____:_____________________________:____________________ |
| 3378 |
: : |
| 3379 |
*===================* : |
| 3380 |
| c2 | : |
| 3381 |
*===================* : |
| 3382 |
:.............................: |
| 3383 |
: ...............g1...:.......... |
| 3384 |
: *=============================* |
| 3385 |
: | c3 | |
| 3386 |
: *=============================* |
| 3387 |
__________:_________:_____________________________:__________ |
| 3388 |
layer2____:_________:_____________________________:__________ |
| 3389 |
: : : |
| 3390 |
: : *===================* |
| 3391 |
: : | c5 | |
| 3392 |
: :.........*===================* |
| 3393 |
*===================* : |
| 3394 |
| c4 | : |
| 3395 |
*===================* : |
| 3396 |
:.............................: |
| 3397 |
*===================* |
| 3398 |
| c6 | |
| 3399 |
*===================* |
| 3400 |
""" |
| 3401 |
track = self.add_video_track() |
| 3402 |
c0 = self.add_clip("c0", 0, [track], 5, 15) |
| 3403 |
c1 = self.add_clip("c1", 0, [track], 15, 10) |
| 3404 |
self.register_auto_transition(c0, c1, track) |
| 3405 |
c2 = self.add_clip("c2", 1, [track], 5, 10) |
| 3406 |
c3 = self.add_clip("c3", 1, [track], 10, 15) |
| 3407 |
self.register_auto_transition(c2, c3, track) |
| 3408 |
c4 = self.add_clip("c4", 2, [track], 5, 10) |
| 3409 |
c5 = self.add_clip("c5", 2, [track], 15, 10) |
| 3410 |
c6 = self.add_clip("c6", 2, [track], 10, 10) |
| 3411 |
self.register_auto_transition(c4, c6, track) |
| 3412 |
self.register_auto_transition(c6, c5, track) |
| 3413 |
|
| 3414 |
g0 = self.add_group("g0", [c0, c2]) |
| 3415 |
g1 = self.add_group("g1", [c3, c5]) |
| 3416 |
g2 = self.add_group("g2", [g0, c4]) |
| 3417 |
|
| 3418 |
self.assertTimelineConfig() |
| 3419 |
|
| 3420 |
layer = self.timeline.get_layer(0) |
| 3421 |
self.assertIsNotNone(layer) |
| 3422 |
|
| 3423 |
# don't loose auto-transitions |
| 3424 |
# clips stay in their layer (groups do not move them) |
| 3425 |
self.timeline.move_layer(layer, 2) |
| 3426 |
self.assertTimelineConfig( |
| 3427 |
{ |
| 3428 |
c0 : {"layer": 2}, |
| 3429 |
c1 : {"layer": 2}, |
| 3430 |
c2 : {"layer": 0}, |
| 3431 |
c3 : {"layer": 0}, |
| 3432 |
c4 : {"layer": 1}, |
| 3433 |
c5 : {"layer": 1}, |
| 3434 |
c6 : {"layer": 1}, |
| 3435 |
g1 : {"layer": 0}, |
| 3436 |
}) |
| 3437 |
""" |
| 3438 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3439 |
0 5 10 15 20 25 30 |
| 3440 |
_____________________________________________________________ |
| 3441 |
layer0_______________________________________________________ |
| 3442 |
|
| 3443 |
..............g2............... |
| 3444 |
: : |
| 3445 |
:.............g0..............: |
| 3446 |
*===================* : |
| 3447 |
| c2 | : |
| 3448 |
*===================* : |
| 3449 |
: ..........................: |
| 3450 |
: : ...............g1.............. |
| 3451 |
: : *=============================* |
| 3452 |
: : | c3 | |
| 3453 |
: : *=============================* |
| 3454 |
__________:___:_____:_____________________________:__________ |
| 3455 |
layer1____:___:_____:_____________________________:__________ |
| 3456 |
: : : : |
| 3457 |
: : : *===================* |
| 3458 |
: : : | c5 | |
| 3459 |
: : : *===================* |
| 3460 |
: : :.............................: |
| 3461 |
: :..........g2..... |
| 3462 |
: g0 : |
| 3463 |
: : : |
| 3464 |
*===================*: |
| 3465 |
| c4 |: |
| 3466 |
*===================*: |
| 3467 |
: :................: |
| 3468 |
: : *===================* |
| 3469 |
: : | c6 | |
| 3470 |
: : *===================* |
| 3471 |
__________:___:______________________________________________ |
| 3472 |
layer2____:___:______________________________________________ |
| 3473 |
: :.......................... |
| 3474 |
*=============================* |
| 3475 |
| c0 | |
| 3476 |
*=============================* |
| 3477 |
:.............................: |
| 3478 |
:.............................: |
| 3479 |
*===================* |
| 3480 |
| c1 | |
| 3481 |
*===================* |
| 3482 |
""" |
| 3483 |
layer = self.timeline.get_layer(1) |
| 3484 |
self.assertIsNotNone(layer) |
| 3485 |
self.timeline.move_layer(layer, 0) |
| 3486 |
self.assertTimelineConfig( |
| 3487 |
{ |
| 3488 |
c2 : {"layer": 1}, |
| 3489 |
c3 : {"layer": 1}, |
| 3490 |
c4 : {"layer": 0}, |
| 3491 |
c5 : {"layer": 0}, |
| 3492 |
c6 : {"layer": 0}, |
| 3493 |
g0 : {"layer": 1}, |
| 3494 |
}) |
| 3495 |
""" |
| 3496 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3497 |
0 5 10 15 20 25 30 |
| 3498 |
_____________________________________________________________ |
| 3499 |
layer0_______________________________________________________ |
| 3500 |
|
| 3501 |
*===================* |
| 3502 |
| c6 | |
| 3503 |
*===================* |
| 3504 |
|
| 3505 |
..............g2............... |
| 3506 |
*===================* : |
| 3507 |
| c4 | : |
| 3508 |
*===================* : |
| 3509 |
: ...............g1...:.......... |
| 3510 |
: : *===================* |
| 3511 |
: : | c5 | |
| 3512 |
: : *===================* |
| 3513 |
__________:_________:___________________:_________:__________ |
| 3514 |
layer1____:_________:___________________:_________:__________ |
| 3515 |
: : : : |
| 3516 |
: *=============================* |
| 3517 |
: | c3 | |
| 3518 |
: *=============================* |
| 3519 |
: :...................:.........: |
| 3520 |
:.............g0..............: |
| 3521 |
*===================* : |
| 3522 |
| c2 | : |
| 3523 |
*===================* : |
| 3524 |
:.............................: |
| 3525 |
__________:_____________________________:____________________ |
| 3526 |
layer2____:_____________________________:____________________ |
| 3527 |
: : |
| 3528 |
*=============================* |
| 3529 |
| c0 | |
| 3530 |
*=============================* |
| 3531 |
:.............................: |
| 3532 |
:.............................: |
| 3533 |
*===================* |
| 3534 |
| c1 | |
| 3535 |
*===================* |
| 3536 |
""" |
| 3537 |
self.timeline.append_layer() |
| 3538 |
layer = self.timeline.get_layer(3) |
| 3539 |
self.assertIsNotNone(layer) |
| 3540 |
self.timeline.move_layer(layer, 1) |
| 3541 |
self.assertTimelineConfig( |
| 3542 |
{ |
| 3543 |
c0 : {"layer": 3}, |
| 3544 |
c1 : {"layer": 3}, |
| 3545 |
c2 : {"layer": 2}, |
| 3546 |
c3 : {"layer": 2}, |
| 3547 |
g0 : {"layer": 2}, |
| 3548 |
}) |
| 3549 |
layer = self.timeline.get_layer(3) |
| 3550 |
self.assertIsNotNone(layer) |
| 3551 |
self.timeline.move_layer(layer, 0) |
| 3552 |
self.assertTimelineConfig( |
| 3553 |
{ |
| 3554 |
c0 : {"layer": 0}, |
| 3555 |
c1 : {"layer": 0}, |
| 3556 |
c2 : {"layer": 3}, |
| 3557 |
c3 : {"layer": 3}, |
| 3558 |
c4 : {"layer": 1}, |
| 3559 |
c5 : {"layer": 1}, |
| 3560 |
c6 : {"layer": 1}, |
| 3561 |
g0 : {"layer": 0}, |
| 3562 |
g1 : {"layer": 1}, |
| 3563 |
}) |
| 3564 |
""" |
| 3565 |
, . . . . , . . . . , . . . . , . . . . , . . . . , . . . . , |
| 3566 |
0 5 10 15 20 25 30 |
| 3567 |
_____________________________________________________________ |
| 3568 |
layer0_______________________________________________________ |
| 3569 |
|
| 3570 |
*===================* |
| 3571 |
| c1 | |
| 3572 |
*===================* |
| 3573 |
..............g2............... |
| 3574 |
:.............g0..............: |
| 3575 |
*=============================* |
| 3576 |
| c0 | |
| 3577 |
*=============================* |
| 3578 |
: ..........................: |
| 3579 |
__________:___:______________________________________________ |
| 3580 |
layer1____:___:______________________________________________ |
| 3581 |
: : |
| 3582 |
: :.......g2....... |
| 3583 |
: g0 : |
| 3584 |
: : : |
| 3585 |
*===================* |
| 3586 |
| c4 | |
| 3587 |
*===================* |
| 3588 |
: :...............: |
| 3589 |
: : *===================* |
| 3590 |
: : | c6 | |
| 3591 |
: : *===================* |
| 3592 |
: : ...............g1.............. |
| 3593 |
: : : *===================* |
| 3594 |
: : : | c5 | |
| 3595 |
: : : *===================* |
| 3596 |
__________:___:_____:_____________________________:__________ |
| 3597 |
layer2____:___:_____:_____________________________:__________ |
| 3598 |
__________:___:_____:_____________________________:__________ |
| 3599 |
layer3____:___:_____:_____________________________:__________ |
| 3600 |
: : : : |
| 3601 |
: : *=============================* |
| 3602 |
: : | c3 | |
| 3603 |
: : *=============================* |
| 3604 |
: : :.............................: |
| 3605 |
: :.......................... |
| 3606 |
*===================* : |
| 3607 |
| c2 | : |
| 3608 |
*===================* : |
| 3609 |
:.............................: |
| 3610 |
:.............................: |
| 3611 |
""" |
| 3612 |
layer = self.timeline.get_layer(1) |
| 3613 |
self.assertTrue(self.timeline.remove_layer(layer)) |
| 3614 |
|
| 3615 |
# TODO: add tests when removing layers: |
| 3616 |
# FIXME: groups should probably loose their children when they |
| 3617 |
# are removed from the timeline, which would change g1's |
| 3618 |
# priority, but currently c5 remains in the group with priority |
| 3619 |
# of the removed layer |
| 3620 |
|
| 3621 |
def test_not_snappable(self): |
| 3622 |
track = self.add_video_track() |
| 3623 |
c0 = self.add_clip("c0", 0, [track], 0, 10) |
| 3624 |
no_source = self.add_clip( |
| 3625 |
"no-source", 0, [], 5, 10, effects=[GES.Effect.new("agingtv")]) |
| 3626 |
effect_clip = self.add_clip( |
| 3627 |
"effect-clip", 0, [track], 5, 10, clip_type=GES.EffectClip, |
| 3628 |
asset_id="agingtv || audioecho") |
| 3629 |
text = self.add_clip( |
| 3630 |
"text-clip", 0, [track], 5, 10, clip_type=GES.TextOverlayClip) |
| 3631 |
|
| 3632 |
self.assertTimelineConfig() |
| 3633 |
|
| 3634 |
self.timeline.set_snapping_distance(20) |
| 3635 |
|
| 3636 |
self.assertEdit( |
| 3637 |
c0, 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 8, None, |
| 3638 |
[], [], {c0 : {"start": 8}}, [], []) |
| 3639 |
self.assertEdit( |
| 3640 |
c0, 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_START, 5, None, |
| 3641 |
[], [], {c0 : {"start": 5}}, [], []) |
| 3642 |
self.assertEdit( |
| 3643 |
c0, 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_END, 8, None, |
| 3644 |
[], [], {c0 : {"duration": 3}}, [], []) |
| 3645 |
|
| 3646 |
c1 = self.add_clip("c1", 0, [track], 30, 3) |
| 3647 |
self.assertTimelineConfig() |
| 3648 |
|
| 3649 |
# end edge snaps to start of c1 |
| 3650 |
self.assertEdit( |
| 3651 |
c0, 0, GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 10, 30, |
| 3652 |
[c0], [c1], {c0 : {"start": 27}}, [], []) |
| 3653 |
|
| 3654 |
def test_disable_timeline_editing_apis(self): |
| 3655 |
track = self.add_video_track() |
| 3656 |
self.assertEqual(self.timeline.props.auto_transition, True) |
| 3657 |
self.timeline.disable_edit_apis(True) |
| 3658 |
self.assertEqual(self.timeline.props.auto_transition, False) |
| 3659 |
|
| 3660 |
c0 = self.add_clip("c0", 0, [track], 0, 10) |
| 3661 |
# Without disabling edit API adding clip would fail |
| 3662 |
c1 = self.add_clip("c1", 0, [track], 0, 10) |
| 3663 |
self.assertTimelineConfig() |
| 3664 |
|
| 3665 |
c1.set_start(1) |
| 3666 |
c1.set_duration(1) |
| 3667 |
self.assertEqual(c1.get_start(), 1) |
| 3668 |
self.assertEqual(c1.get_duration(), 1) |
| 3669 |
|
| 3670 |
|
| 3671 |
class TestTransitions(common.GESSimpleTimelineTest): |
| 3672 |
|
| 3673 |
def test_emission_order_for_transition_clip_added_signal(self): |
| 3674 |
self.timeline.props.auto_transition = True |
| 3675 |
unused_clip1 = self.add_clip(0, 0, 100) |
| 3676 |
clip2 = self.add_clip(100, 0, 100) |
| 3677 |
|
| 3678 |
# Connect to signals to track in which order they are emitted. |
| 3679 |
signals = [] |
| 3680 |
|
| 3681 |
def clip_added_cb(layer, clip): |
| 3682 |
self.assertIsInstance(clip, GES.TransitionClip) |
| 3683 |
signals.append("clip-added") |
| 3684 |
self.layer.connect("clip-added", clip_added_cb) |
| 3685 |
|
| 3686 |
def property_changed_cb(clip, pspec): |
| 3687 |
self.assertEqual(clip, clip2) |
| 3688 |
self.assertEqual(pspec.name, "start") |
| 3689 |
signals.append("notify::start") |
| 3690 |
clip2.connect("notify::start", property_changed_cb) |
| 3691 |
|
| 3692 |
# Move clip2 to create a transition with clip1. |
| 3693 |
clip2.edit([], self.layer.get_priority(), |
| 3694 |
GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE, 50) |
| 3695 |
# The clip-added signal is emitted twice, once for the video |
| 3696 |
# transition and once for the audio transition. |
| 3697 |
self.assertEqual( |
| 3698 |
signals, ["notify::start", "clip-added", "clip-added"]) |
| 3699 |
|
| 3700 |
def create_xges(self): |
| 3701 |
uri = common.get_asset_uri("png.png") |
| 3702 |
return r"""<ges version='0.4'> |
| 3703 |
<project properties='properties;' metadatas='metadatas, author=(string)"", render-scale=(double)100, format-version=(string)0.4;'> |
| 3704 |
<ressources> |
| 3705 |
<asset id='GESTitleClip' extractable-type-name='GESTitleClip' properties='properties;' metadatas='metadatas;' /> |
| 3706 |
<asset id='bar-wipe-lr' extractable-type-name='GESTransitionClip' properties='properties;' metadatas='metadatas, description=(string)GES_VIDEO_STANDARD_TRANSITION_TYPE_BAR_WIPE_LR;' /> |
| 3707 |
<asset id='%(uri)s' extractable-type-name='GESUriClip' properties='properties, supported-formats=(int)4, duration=(guint64)18446744073709551615;' metadatas='metadatas, video-codec=(string)PNG, file-size=(guint64)73294;' /> |
| 3708 |
<asset id='crossfade' extractable-type-name='GESTransitionClip' properties='properties;' metadatas='metadatas, description=(string)GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE;' /> |
| 3709 |
</ressources> |
| 3710 |
<timeline properties='properties, auto-transition=(boolean)true, snapping-distance=(guint64)31710871;' metadatas='metadatas, duration=(guint64)13929667032;'> |
| 3711 |
<track caps='video/x-raw(ANY)' track-type='4' track-id='0' properties='properties, async-handling=(boolean)false, message-forward=(boolean)true, caps=(string)"video/x-raw\(ANY\)", restriction-caps=(string)"video/x-raw\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ framerate\=\(fraction\)30/1", mixing=(boolean)true;' metadatas='metadatas;'/> |
| 3712 |
<track caps='audio/x-raw(ANY)' track-type='2' track-id='1' properties='properties, async-handling=(boolean)false, message-forward=(boolean)true, caps=(string)"audio/x-raw\(ANY\)", restriction-caps=(string)"audio/x-raw\,\ format\=\(string\)S32LE\,\ channels\=\(int\)2\,\ rate\=\(int\)44100\,\ layout\=\(string\)interleaved", mixing=(boolean)true;' metadatas='metadatas;'/> |
| 3713 |
<layer priority='0' properties='properties, auto-transition=(boolean)true;' metadatas='metadatas, volume=(float)1;'> |
| 3714 |
<clip id='0' asset-id='%(uri)s' type-name='GESUriClip' layer-priority='0' track-types='6' start='0' duration='4558919302' inpoint='0' rate='0' properties='properties, name=(string)uriclip25263, mute=(boolean)false, is-image=(boolean)false;' /> |
| 3715 |
<clip id='1' asset-id='bar-wipe-lr' type-name='GESTransitionClip' layer-priority='0' track-types='4' start='3225722559' duration='1333196743' inpoint='0' rate='0' properties='properties, name=(string)transitionclip84;' children-properties='properties, GESVideoTransition::border=(uint)0, GESVideoTransition::invert=(boolean)false;'/> |
| 3716 |
<clip id='2' asset-id='%(uri)s' type-name='GESUriClip' layer-priority='0' track-types='6' start='3225722559' duration='3479110239' inpoint='4558919302' rate='0' properties='properties, name=(string)uriclip25265, mute=(boolean)false, is-image=(boolean)false;' /> |
| 3717 |
</layer> |
| 3718 |
<groups> |
| 3719 |
</groups> |
| 3720 |
</timeline> |
| 3721 |
</project> |
| 3722 |
</ges>""" % {"uri": uri} |
| 3723 |
|
| 3724 |
def test_auto_transition(self): |
| 3725 |
xges = self.create_xges() |
| 3726 |
with common.created_project_file(xges) as proj_uri: |
| 3727 |
project = GES.Project.new(proj_uri) |
| 3728 |
timeline = project.extract() |
| 3729 |
|
| 3730 |
mainloop = common.create_main_loop() |
| 3731 |
def loaded_cb(unused_project, unused_timeline): |
| 3732 |
mainloop.quit() |
| 3733 |
project.connect("loaded", loaded_cb) |
| 3734 |
|
| 3735 |
mainloop.run() |
| 3736 |
|
| 3737 |
layers = timeline.get_layers() |
| 3738 |
self.assertEqual(len(layers), 1) |
| 3739 |
|
| 3740 |
self.assertTrue(layers[0].props.auto_transition) |
| 3741 |
|
| 3742 |
def test_transition_type(self): |
| 3743 |
xges = self.create_xges() |
| 3744 |
with common.created_project_file(xges) as proj_uri: |
| 3745 |
project = GES.Project.new(proj_uri) |
| 3746 |
timeline = project.extract() |
| 3747 |
|
| 3748 |
mainloop = common.create_main_loop() |
| 3749 |
def loaded_cb(unused_project, unused_timeline): |
| 3750 |
mainloop.quit() |
| 3751 |
project.connect("loaded", loaded_cb) |
| 3752 |
mainloop.run() |
| 3753 |
|
| 3754 |
layers = timeline.get_layers() |
| 3755 |
self.assertEqual(len(layers), 1) |
| 3756 |
|
| 3757 |
clips = layers[0].get_clips() |
| 3758 |
clip1 = clips[0] |
| 3759 |
clip2 = clips[-1] |
| 3760 |
# There should be a transition because clip1 intersects clip2 |
| 3761 |
self.assertLess(clip1.props.start, clip2.props.start) |
| 3762 |
self.assertLess(clip2.props.start, clip1.props.start + clip1.props.duration) |
| 3763 |
self.assertLess(clip1.props.start + clip1.props.duration, clip2.props.start + clip2.props.duration) |
| 3764 |
self.assertEqual(len(clips), 3) |
| 3765 |
|
| 3766 |
|
| 3767 |
class TestPriorities(common.GESSimpleTimelineTest): |
| 3768 |
|
| 3769 |
def test_clips_priorities(self): |
| 3770 |
clip = self.add_clip(0, 0, 100) |
| 3771 |
clip1 = self.add_clip(100, 0, 100) |
| 3772 |
self.timeline.commit() |
| 3773 |
|
| 3774 |
self.assertLess(clip.props.priority, clip1.props.priority) |
| 3775 |
|
| 3776 |
clip.props.start = 101 |
| 3777 |
self.timeline.commit() |
| 3778 |
self.assertGreater(clip.props.priority, clip1.props.priority) |
| 3779 |
|
| 3780 |
|
| 3781 |
class TestTimelineElement(common.GESSimpleTimelineTest): |
| 3782 |
|
| 3783 |
def test_set_child_property(self): |
| 3784 |
clip = self.add_clip(0, 0, 100) |
| 3785 |
source = clip.find_track_element(None, GES.VideoSource) |
| 3786 |
self.assertTrue(source.set_child_property("height", 5)) |
| 3787 |
self.assertEqual(clip.get_child_property("height"), (True, 5)) |