GES.Timeline

g GES.Extractable GES.Extractable GES.Timeline GES.Timeline GES.Extractable->GES.Timeline GES.MetaContainer GES.MetaContainer GES.MetaContainer->GES.Timeline GObject.GInterface GObject.GInterface GObject.GInterface->GES.Extractable GObject.GInterface->GES.MetaContainer Gst.ChildProxy Gst.ChildProxy GObject.GInterface->Gst.ChildProxy GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gst.Bin Gst.Bin Gst.Bin->GES.Timeline Gst.ChildProxy->Gst.Bin Gst.Element Gst.Element Gst.Element->Gst.Bin Gst.Object->Gst.Element

Subclasses:None

Methods

Inherited:Gst.Bin (18), Gst.Element (79), Gst.Object (27), GObject.Object (37), Gst.ChildProxy (8), GES.Extractable (3), GES.MetaContainer (40)
Structs:Gst.ElementClass (10), GObject.ObjectClass (5)
class new ()
class new_audio_video ()
class new_from_uri (uri)
  add_layer (layer)
  add_track (track)
  append_layer ()
  commit ()
  commit_sync ()
  get_auto_transition ()
  get_duration ()
  get_element (name)
  get_frame_at (timestamp)
  get_frame_time (frame_number)
  get_groups ()
  get_layer (priority)
  get_layers ()
  get_pad_for_track (track)
  get_snapping_distance ()
  get_track_for_pad (pad)
  get_tracks ()
  is_empty ()
  load_from_uri (uri)
  move_layer (layer, new_layer_priority)
  paste_element (element, position, layer_priority)
  remove_layer (layer)
  remove_track (track)
  save_to_uri (uri, formatter_asset, overwrite)
  set_auto_transition (auto_transition)
  set_snapping_distance (snapping_distance)

Properties

Inherited:Gst.Bin (2), Gst.Object (2)
Name Type Flags Short Description
auto-transition bool r/w whether the transitions are added
duration int r The duration of the timeline
snapping-distance int r/w Distance from which moving an object will snap with neighbours

Signals

Inherited:Gst.Bin (5), Gst.Element (3), Gst.Object (1), GObject.Object (1), Gst.ChildProxy (2), GES.MetaContainer (1)
Name Short Description
commited This signal will be emitted once the changes initiated by GES.Timeline.commit() have been executed in the backend.
group-added Will be emitted after the group is added to to the timeline.
group-removed Will be emitted after the group is removed from the timeline through ges_container_ungroup.
layer-added Will be emitted after the layer is added to the timeline.
layer-removed Will be emitted after the layer is removed from the timeline.
select-element-track Simplified version of GES.Timeline ::select-tracks-for-object which only allows track_element to be added to a single GES.Track.
select-tracks-for-object This will be emitted whenever the timeline needs to determine which tracks a clip’s children should be added to.
snapping-ended Will be emitted whenever a snapping event ends.
snapping-started Will be emitted whenever an element’s movement invokes a snapping event during an edit (usually of one of its ancestors) because its start or end point lies within the GES.Timeline :snapping-distance of another element’s start or end point.
track-added Will be emitted after the track is added to the timeline.
track-removed Will be emitted after the track is removed from the timeline.

Fields

Inherited:Gst.Bin (5), Gst.Element (3), Gst.Object (1), GObject.Object (1), Gst.ChildProxy (2), GES.MetaContainer (1)
Name Type Access Description
layers [GES.Layer] r A list of GES.Layer-s sorted by priority. NOTE: Do not modify.
parent Gst.Bin r  
tracks [object] r Deprecated:1.10: (element-type GES.Track): This is not thread safe, use GES.Timeline.get_tracks instead.

Class Details

class GES.Timeline(**kwargs)
Bases:Gst.Bin, GES.Extractable, GES.MetaContainer
Abstract:No
Structure:GES.TimelineClass

GES.Timeline is the central object for any multimedia timeline.

A timeline is composed of a set of GES.Track-s and a set of GES.Layer-s, which are added to the timeline using GES.Timeline.add_track() and GES.Timeline.append_layer(), respectively.

The contained tracks define the supported types of the timeline and provide the media output. Essentially, each track provides an additional source Gst.Pad.

Most usage of a timeline will likely only need a single GES.AudioTrack and/or a single GES.VideoTrack. You can create such a timeline with GES.Timeline.new_audio_video(). After this, you are unlikely to need to work with the tracks directly.

A timeline’s layers contain GES.Clip-s, which in turn control the creation of GES.TrackElement-s, which are added to the timeline’s tracks. See GES.Timeline ::select-tracks-for-object if you wish to have more control over which track a clip’s elements are added to.

The layers are ordered, with higher priority layers having their content prioritised in the tracks. This ordering can be changed using GES.Timeline.move_layer().

Editing

See GES.TimelineElement for the various ways the elements of a timeline can be edited.

If you change the timing or ordering of a timeline’s GES.TimelineElement-s, then these changes will not actually be taken into account in the output of the timeline’s tracks until the GES.Timeline.commit() method is called. This allows you to move its elements around, say, in response to an end user’s mouse dragging, with little expense before finalising their effect on the produced data.

Overlaps and Auto-Transitions

There are certain restrictions placed on how GES.Source-s may overlap in a GES.Track that belongs to a timeline. These will be enforced by GES, so the user will not need to keep track of them, but they should be aware that certain edits will be refused as a result if the overlap rules would be broken.

Consider two GES.Source-s, A and B, with start times startA and startB, and end times endA and endB, respectively. The start time refers to their GES.TimelineElement :start, and the end time is their GES.TimelineElement :start + GES.TimelineElement :duration. These two sources *overlap* if:

  • they share the same GES.TrackElement :track (non None), which belongs to the timeline;
  • they share the same #GES_TIMELINE_ELEMENT_LAYER_PRIORITY; and
  • startA < endB and ``startB < endA ``.

Note that when startA = endB or startB = endA then the two sources will *touch* at their edges, but are not considered overlapping.

If, in addition, startA < startB < endA, then we can say that the end of A overlaps the start of B.

If, instead, startA <= startB and endA >= endB, then we can say that A fully overlaps B.

The overlap rules for a timeline are that:

One source cannot fully overlap another source.

A source can only overlap the end of up to one other source at its start.

A source can only overlap the start of up to one other source at its end.

The last two rules combined essentially mean that at any given timeline position, only up to two GES.Source-s may overlap at that position. So triple or more overlaps are not allowed.

If you switch on GES.Timeline :auto-transition, then at any moment when the end of one source (the first source) overlaps the start of another (the second source), a GES.TransitionClip will be automatically created for the pair in the same layer and it will cover their overlap. If the two elements are edited in a way such that the end of the first source no longer overlaps the start of the second, the transition will be automatically removed from the timeline. However, if the two sources still overlap at the same edges after the edit, then the same transition object will be kept, but with its timing and layer adjusted accordingly.

Saving

To save/load a timeline, you can use the GES.Timeline.load_from_uri() and GES.Timeline.save_to_uri() methods that use the default format.

Playing

A timeline is a Gst.Bin with a source Gst.Pad for each of its tracks, which you can fetch with GES.Timeline.get_pad_for_track(). You will likely want to link these to some compatible sink Gst.Element-s to be able to play or capture the content of the timeline.

You can use a GES.Pipeline to easily preview/play the timeline’s content, or render it to a file.

classmethod new()[source]
Returns:The new timeline.
Return type:GES.Timeline

Creates a new empty timeline.

classmethod new_audio_video()[source]
Returns:The new timeline, or None if the tracks could not be created and added.
Return type:GES.Timeline

Creates a new timeline containing a single GES.AudioTrack and a single GES.VideoTrack.

classmethod new_from_uri(uri)[source]
Parameters:uri (str) – The URI to load from
Raises:GLib.Error
Returns:A new timeline if the uri was loaded successfully, or None if the uri could not be loaded.
Return type:GES.Timeline or None

Creates a timeline from the given URI.

add_layer(layer)[source]
Parameters:layer (GES.Layer) – The layer to add
Returns:True if layer was properly added.
Return type:bool

Add a layer to the timeline.

If the layer contains GES.Clip-s, then this may trigger the creation of their core track element children for the timeline’s tracks, and the placement of the clip’s children in the tracks of the timeline using GES.Timeline ::select-tracks-for-object. Some errors may occur if this would break one of the configuration rules of the timeline in one of its tracks. In such cases, some track elements would fail to be added to their tracks, but this method would still return True. As such, it is advised that you only add clips to layers that already part of a timeline. In such situations, GES.Layer.add_clip() is able to fail if adding the clip would cause such an error.

Deprecated since version 1.18: This method requires you to ensure the layer’s GES.Layer :priority will be unique to the timeline. Use GES.Timeline.append_layer() and GES.Timeline.move_layer() instead.

add_track(track)[source]
Parameters:track (GES.Track) – The track to add
Returns:True if track was properly added.
Return type:bool

Add a track to the timeline.

If the timeline already contains clips, then this may trigger the creation of their core track element children for the track, and the placement of the clip’s children in the track of the timeline using GES.Timeline ::select-tracks-for-object. Some errors may occur if this would break one of the configuration rules for the timeline in the track. In such cases, some track elements would fail to be added to the track, but this method would still return True. As such, it is advised that you avoid adding tracks to timelines that already contain clips.

append_layer()[source]
Returns:The newly created layer.
Return type:GES.Layer

Append a newly created layer to the timeline. The layer will be added at the lowest GES.Layer :priority (numerically, the highest).

commit()[source]
Returns:True if pending changes were committed, or False if nothing needed to be committed.
Return type:bool

Commit all the pending changes of the clips contained in the timeline.

When changes happen in a timeline, they are not immediately executed internally, in a way that effects the output data of the timeline. You should call this method when you are done with a set of changes and you want them to be executed.

Any pending changes will be executed in the backend. The GES.Timeline ::commited signal will be emitted once this has completed. You should not try to change the state of the timeline, seek it or add tracks to it before receiving this signal. You can use GES.Timeline.commit_sync() if you do not want to perform other tasks in the mean time.

Note that all the pending changes will automatically be executed when the timeline goes from Gst.State.READY to Gst.State.PAUSED, which is usually triggered by a corresponding state changes in a containing GES.Pipeline.

commit_sync()[source]
Returns:True if pending changes were committed, or False if nothing needed to be committed.
Return type:bool

Commit all the pending changes of the clips contained in the timeline and wait for the changes to complete.

See GES.Timeline.commit().

get_auto_transition()[source]
Returns:The auto-transition of self.
Return type:bool

Gets GES.Timeline :auto-transition for the timeline.

get_duration()[source]
Returns:The current duration of self.
Return type:int

Get the current GES.Timeline :duration of the timeline

get_element(name)[source]
Parameters:name (str) – The name of the element to find
Returns:The timeline element in self with the given name, or None if it was not found.
Return type:GES.TimelineElement or None

Gets the element contained in the timeline with the given name.

get_frame_at(timestamp)[source]
Parameters:timestamp (int) – The timestamp to get the corresponding frame number of
Returns:The frame number timestamp corresponds to.
Return type:int

This method allows you to convert a timeline #GstClockTime into its corresponding #GESFrameNumber in the timeline’s output.

New in version 1.18.

get_frame_time(frame_number)[source]
Parameters:frame_number (int) – The frame number to get the corresponding timestamp of in the timeline coordinates
Returns:The timestamp corresponding to frame_number in the output of self.
Return type:int

This method allows you to convert a timeline output frame number into a timeline #GstClockTime. For example, this time could be used to seek to a particular frame in the timeline’s output, or as the edit position for an element within the timeline.

New in version 1.18.

get_groups()[source]
Returns:The list of groups that contain clips present in self’s layers. Must not be changed.
Return type:[GES.Group]

Get the list of GES.Group-s present in the timeline.

get_layer(priority)[source]
Parameters:priority (int) – The priority/index of the layer to find
Returns:The layer with the given priority, or None if none was found.
Return type:GES.Layer or None

Retrieve the layer whose index in the timeline matches the given priority.

get_layers()[source]
Returns:The list of layers present in self sorted by priority.
Return type:[GES.Layer]

Get the list of GES.Layer-s present in the timeline.

get_pad_for_track(track)[source]
Parameters:track (GES.Track) – A track
Returns:The pad corresponding to track, or None if there is an error.
Return type:Gst.Pad or None

Search for the Gst.Pad corresponding to the given timeline’s track. You can link to this pad to receive the output data of the given track.

get_snapping_distance()[source]
Returns:The snapping distance (in nanoseconds) of self.
Return type:int

Gets the GES.Timeline :snapping-distance for the timeline.

get_track_for_pad(pad)[source]
Parameters:pad (Gst.Pad) – A pad
Returns:The track corresponding to pad, or None if there is an error.
Return type:GES.Track or None

Search for the GES.Track corresponding to the given timeline’s pad.

get_tracks()[source]
Returns:The list of tracks used by self.
Return type:[GES.Track]

Get the list of GES.Track-s used by the timeline.

is_empty()[source]
Returns:True if self is empty.
Return type:bool

Check whether the timeline is empty or not.

load_from_uri(uri)[source]
Parameters:uri (str) – The URI to load from
Raises:GLib.Error
Returns:True if the timeline was loaded successfully from uri.
Return type:bool

Loads the contents of URI into the timeline.

move_layer(layer, new_layer_priority)[source]
Parameters:
  • layer (GES.Layer) – A layer within self, whose priority should be changed
  • new_layer_priority (int) – The new index for layer
Return type:

bool

Moves a layer within the timeline to the index given by new_layer_priority. An index of 0 corresponds to the layer with the highest priority in a timeline. If new_layer_priority is greater than the number of layers present in the timeline, it will become the lowest priority layer.

New in version 1.16.

paste_element(element, position, layer_priority)[source]
Parameters:
  • element (GES.TimelineElement) – The element to paste
  • position (int) – The position in the timeline element should be pasted to, i.e. the GES.TimelineElement :start value for the pasted element.
  • layer_priority (int) – The layer into which the element should be pasted. -1 means paste to the same layer from which element has been copied from
Returns:

The newly created element, or None if pasting fails.

Return type:

GES.TimelineElement or None

Paste an element inside the timeline. element **must** be the return of GES.TimelineElement.copy() with deep=TRUE, and it should not be changed before pasting. element itself is not placed in the timeline, instead a new element is created, alike to the originally copied element. Note that the originally copied element must also lie within self, at both the point of copying and pasting.

Pasting may fail if it would place the timeline in an unsupported configuration.

After calling this function element should not be used. In particular, element can **not** be pasted again. Instead, you can copy the returned element and paste that copy (although, this is only possible if the paste was successful).

See also GES.TimelineElement.paste().

remove_layer(layer)[source]
Parameters:layer (GES.Layer) – The layer to remove
Returns:True if layer was properly removed.
Return type:bool

Removes a layer from the timeline.

remove_track(track)[source]
Parameters:track (GES.Track) – The track to remove
Returns:True if track was properly removed.
Return type:bool

Remove a track from the timeline.

save_to_uri(uri, formatter_asset, overwrite)[source]
Parameters:
  • uri (str) – The location to save to
  • formatter_asset (GES.Asset or None) – The formatter asset to use, or None
  • overwrite (bool) – True to overwrite file if it exists
Raises:

GLib.Error

Returns:

True if self was successfully saved to uri.

Return type:

bool

Saves the timeline to the given location. If formatter_asset is None, the method will attempt to save in the same format the timeline was loaded from, before defaulting to the formatter with highest rank.

set_auto_transition(auto_transition)[source]
Parameters:auto_transition (bool) – Whether transitions should be automatically added to self’s layers

Sets GES.Timeline :auto-transition for the timeline. This will also set the corresponding GES.Layer :auto-transition for all of the timeline’s layers to the same value. See GES.Layer.set_auto_transition() if you wish to set the layer’s GES.Layer :auto-transition individually.

set_snapping_distance(snapping_distance)[source]
Parameters:snapping_distance (int) – The snapping distance to use (in nanoseconds)

Sets GES.Timeline :snapping-distance for the timeline. This new value will only effect future snappings and will not be used to snap the current element positions within the timeline.

do_group_added(group) virtual
Parameters:group (GES.Group) –
do_layer_added(layer) virtual
Parameters:layer (GES.Layer) –
do_layer_removed(layer) virtual
Parameters:layer (GES.Layer) –
do_track_added(track) virtual
Parameters:track (GES.Track) –
do_track_removed(track) virtual
Parameters:track (GES.Track) –

Signal Details

GES.Timeline.signals.commited(timeline)
Signal Name:commited
Flags:RUN_LAST
Parameters:timeline (GES.Timeline) – The object which received the signal

This signal will be emitted once the changes initiated by GES.Timeline.commit() have been executed in the backend. Use GES.Timeline.commit_sync() if you do not want to have to connect to this signal.

GES.Timeline.signals.group_added(timeline, group)
Signal Name:

group-added

Flags:

RUN_FIRST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • group (GES.Group) – The group that was added to timeline

Will be emitted after the group is added to to the timeline. This can happen when grouping with ges_container_group, or by adding containers to a newly created group.

Note that this should not be emitted whilst a timeline is being loaded from its GES.Project asset. You should connect to the project’s GES.Project ::loaded signal if you want to know which groups were created for the timeline.

GES.Timeline.signals.group_removed(timeline, group, children)
Signal Name:

group-removed

Flags:

RUN_FIRST

Parameters:

Will be emitted after the group is removed from the timeline through ges_container_ungroup. Note that group will no longer contain its former children, these are held in children.

Note that if a group is emptied, then it will no longer belong to the timeline, but this signal will **not** be emitted in such a case.

GES.Timeline.signals.layer_added(timeline, layer)
Signal Name:

layer-added

Flags:

RUN_FIRST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • layer (GES.Layer) – The layer that was added to timeline

Will be emitted after the layer is added to the timeline.

Note that this should not be emitted whilst a timeline is being loaded from its GES.Project asset. You should connect to the project’s GES.Project ::loaded signal if you want to know which layers were created for the timeline.

GES.Timeline.signals.layer_removed(timeline, layer)
Signal Name:

layer-removed

Flags:

RUN_FIRST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • layer (GES.Layer) – The layer that was removed from timeline

Will be emitted after the layer is removed from the timeline.

GES.Timeline.signals.select_element_track(timeline, clip, track_element)
Signal Name:

select-element-track

Flags:

RUN_LAST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • clip (GES.Clip) – The clip that track_element is being added to
  • track_element (GES.TrackElement) – The element being added
Returns:

A track to put track_element into, or None if it should be discarded.

Return type:

GES.Track

Simplified version of GES.Timeline ::select-tracks-for-object which only allows track_element to be added to a single GES.Track.

New in version 1.18.

GES.Timeline.signals.select_tracks_for_object(timeline, clip, track_element)
Signal Name:

select-tracks-for-object

Flags:

RUN_LAST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • clip (GES.Clip) – The clip that track_element is being added to
  • track_element (GES.TrackElement) – The element being added
Returns:

An array of GES.Track-s that track_element should be added to, or None to not add the element to any track.

Return type:

[GES.Track]

This will be emitted whenever the timeline needs to determine which tracks a clip’s children should be added to. The track element will be added to each of the tracks given in the return. If a track element is selected to go into multiple tracks, it will be copied into the additional tracks, under the same clip. Note that the copy will *not* keep its properties or state in sync with the original.

Connect to this signal once if you wish to control which element should be added to which track. Doing so will overwrite the default behaviour, which adds track_element to all tracks whose GES.Track :track-type includes the track_element’s GES.TrackElement :track-type.

Note that under the default track selection, if a clip would produce multiple core children of the same GES.TrackType, it will choose one of the core children arbitrarily to place in the corresponding tracks, with a warning for the other core children that are not placed in the track. For example, this would happen for a GES.UriClip that points to a file that contains multiple audio streams. If you wish to choose the stream, you could connect to this signal, and use, say, GES.UriSourceAsset.get_stream_info() to choose which core source to add.

When a clip is first added to a timeline, its core elements will be created for the current tracks in the timeline if they have not already been created. Then this will be emitted for each of these core children to select which tracks, if any, they should be added to. It will then be called for any non-core children in the clip.

In addition, if a new track element is ever added to a clip in a timeline (and it is not already part of a track) this will be emitted to select which tracks the element should be added to.

Finally, as a special case, if a track is added to the timeline *after* it already contains clips, then it will request the creation of the clips’ core elements of the corresponding type, if they have not already been created, and this signal will be emitted for each of these newly created elements. In addition, this will also be released for all other track elements in the timeline’s clips that have not yet been assigned a track. However, in this final case, the timeline will only check whether the newly added track appears in the track list. If it does appear, the track element will be added to the newly added track. All other tracks in the returned track list are ignored.

In this latter case, track elements that are already part of a track will not be asked if they want to be copied into the new track. If you wish to do this, you can use GES.Clip.add_child_to_track().

Note that the returned GLib.PtrArray should own a new reference to each of its contained GES.Track. The timeline will set the GLib.DestroyNotify free function on the GLib.PtrArray to dereference the elements.

GES.Timeline.signals.snapping_ended(timeline, obj1, obj2, position)
Signal Name:

snapping-ended

Flags:

RUN_LAST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • obj1 (GES.TrackElement) – The first element that was snapping
  • obj2 (GES.TrackElement) – The second element that was snapping
  • position (int) – The position where the two objects were to be snapped to

Will be emitted whenever a snapping event ends. After a snap event has started (see GES.Timeline ::snapping-started), it can later end because either another timeline edit has occurred (which may or may not have created a new snapping event), or because the timeline has been committed.

GES.Timeline.signals.snapping_started(timeline, obj1, obj2, position)
Signal Name:

snapping-started

Flags:

RUN_LAST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • obj1 (GES.TrackElement) – The first element that is snapping
  • obj2 (GES.TrackElement) – The second element that is snapping
  • position (int) – The position where the two objects will snap to

Will be emitted whenever an element’s movement invokes a snapping event during an edit (usually of one of its ancestors) because its start or end point lies within the GES.Timeline :snapping-distance of another element’s start or end point.

See GES.EditMode to see what can snap during an edit.

Note that only up to one snapping-started signal will be emitted per element edit within a timeline.

GES.Timeline.signals.track_added(timeline, track)
Signal Name:

track-added

Flags:

RUN_FIRST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • track (GES.Track) – The track that was added to timeline

Will be emitted after the track is added to the timeline.

Note that this should not be emitted whilst a timeline is being loaded from its GES.Project asset. You should connect to the project’s GES.Project ::loaded signal if you want to know which tracks were created for the timeline.

GES.Timeline.signals.track_removed(timeline, track)
Signal Name:

track-removed

Flags:

RUN_FIRST

Parameters:
  • timeline (GES.Timeline) – The object which received the signal
  • track (GES.Track) – The track that was removed from timeline

Will be emitted after the track is removed from the timeline.

Property Details

GES.Timeline.props.auto_transition
Name:auto-transition
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether to automatically create a transition whenever two GES.Source-s overlap in a track of the timeline. See GES.Layer :auto-transition if you want this to only happen in some layers.

GES.Timeline.props.duration
Name:duration
Type:int
Default Value:18446744073709551615
Flags:READABLE

The current duration (in nanoseconds) of the timeline. A timeline ‘starts’ at time 0, so this is the maximum end time of all of its GES.TimelineElement-s.

GES.Timeline.props.snapping_distance
Name:snapping-distance
Type:int
Default Value:0
Flags:READABLE, WRITABLE

The distance (in nanoseconds) at which a GES.TimelineElement being moved within the timeline should snap one of its GES.Source-s with another GES.Source-s edge. See GES.EditMode for which edges can snap during an edit. 0 means no snapping.