GES.Timeline¶
- Subclasses:
None
Methods¶
- Inherited:
Gst.Bin (18), Gst.Element (82), Gst.Object (27), GObject.Object (37), Gst.ChildProxy (9), GES.Extractable (3), GES.MetaContainer (40)
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gst.Bin (8), Gst.Element (16), Gst.Object (1), GObject.Object (7), Gst.ChildProxy (5), GES.Extractable (3)
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
whether the transitions are added |
||
r |
The duration of the timeline |
||
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 |
---|---|
This signal will be emitted once the changes initiated by |
|
Will be emitted after the group is added to to the timeline. |
|
Will be emitted after the group is removed from the timeline through |
|
Will be emitted after the layer is added to the timeline. |
|
Will be emitted after the layer is removed from the timeline. |
|
Simplified version of |
|
This will be emitted whenever the timeline needs to determine which tracks a clip’s children should be added to. |
|
Will be emitted whenever a snapping event ends. |
|
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 |
|
Will be emitted after the track is added to the timeline. |
|
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 |
r |
A list of |
|
parent |
r |
||
tracks |
[ |
r |
Deprecated:1.10: (element-type GES.Track): This is not thread safe, use |
Class Details¶
- class GES.Timeline(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GES.Timeline
is the central object for any multimedia timeline.A timeline is composed of a set of
GES.Track
-s and a set ofGES.Layer
-s, which are added to the timeline usingGES.Timeline.add_track
() andGES.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 singleGES.VideoTrack
. You can create such a timeline withGES.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 ofGES.TrackElement
-s, which are added to the timeline’s tracks. SeeGES.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 theGES.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 aGES.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
andB
, with start timesstartA
andstartB
, and end timesendA
andendB
, respectively. The start time refers to theirGES.TimelineElement
:start
, and the end time is theirGES.TimelineElement
:start
+GES.TimelineElement
:duration
. These two sources *overlap* if:they share the same
GES.TrackElement
:track
(nonNone
), which belongs to the timeline;they share the same #GES_TIMELINE_ELEMENT_LAYER_PRIORITY; and
Note that when
startA = endB
orstartB = 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 ofA
overlaps the start ofB
.If, instead,
startA <= startB
andendA >= endB
, then we can say thatA
fully overlapsB
.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), aGES.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.NOTE: if you know what you are doing and want to be in full control of the timeline layout, you can disable the edit APIs with
GES.Timeline.disable_edit_apis
.- Saving
To save/load a timeline, you can use the
GES.Timeline.load_from_uri
() andGES.Timeline.save_to_uri
() methods that use the default format.- Playing
A timeline is a
Gst.Bin
with a sourceGst.Pad
for each of its tracks, which you can fetch withGES.Timeline.get_pad_for_track
(). You will likely want to link these to some compatible sinkGst.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_audio_video()[source]¶
- Returns:
The new timeline.
- Return type:
Creates a new timeline containing a single
GES.AudioTrack
and a singleGES.VideoTrack
.
- classmethod new_from_uri(uri)[source]¶
- Parameters:
uri (
str
) – The URI to load from- Raises:
- Returns:
A new timeline if the uri was loaded successfully, or
None
if the uri could not be loaded.- Return type:
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:
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 usingGES.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 returnTrue
. 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. UseGES.Timeline.append_layer
() andGES.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:
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 returnTrue
. 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:
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, orFalse
if nothing needed to be committed.- Return type:
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 useGES.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
toGst.State.PAUSED
, which is usually triggered by a corresponding state changes in a containingGES.Pipeline
.
- commit_sync()[source]¶
- Returns:
True
if pending changes were committed, orFalse
if nothing needed to be committed.- Return type:
Commit all the pending changes of the clips contained in the timeline and wait for the changes to complete.
See
GES.Timeline.commit
().
- disable_edit_apis(disable_edit_apis)[source]¶
- Parameters:
disable_edit_apis (
bool
) –True
to disable all the edit APIs so the user is in full control of ensuring timeline state validityFalse
otherwise.
WARNING: When using that mode, GES won’t guarantee the coherence of the timeline. You need to ensure that the rules described in the Overlaps and auto transitions section are respected any time the timeline is commited (otherwise playback will most probably fail in different ways).
When disabling editing APIs, GES won’t be able to enforce the rules that makes the timeline overall state to be valid but some feature won’t be usable:
New in version 1.22.
- freeze_commit()[source]¶
Freezes the timeline from being committed. This is usually needed while the timeline is being rendered to ensure that not change to the timeline are taken into account during that moment. Once the rendering is done, you should call
GES.Timeline.thaw_commit
so that committing becomes possible again and any call tocommit()
that happened during the rendering is actually taken into account.New in version 1.20.
- get_auto_transition()[source]¶
- Returns:
The auto-transition of self.
- Return type:
Gets
GES.Timeline
:auto-transition
for the timeline.
- get_duration()[source]¶
- Returns:
The current duration of self.
- Return type:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
Get the list of
GES.Track
-s used by the timeline.
- load_from_uri(uri)[source]¶
- Parameters:
uri (
str
) – The URI to load from- Raises:
- Returns:
True
if the timeline was loaded successfully from uri.- Return type:
Loads the contents of URI into the timeline.
- move_layer(layer, new_layer_priority)[source]¶
- Parameters:
- Return type:
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 pasteposition (
int
) – The position in the timeline element should be pasted to, i.e. theGES.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:
Paste an element inside the timeline. element **must** be the return of
GES.TimelineElement.copy
() withdeep=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:
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:
Remove a track from the timeline.
- save_to_uri(uri, formatter_asset, overwrite)[source]¶
- Parameters:
- Raises:
- Returns:
True
if self was successfully saved to uri.- Return type:
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 correspondingGES.Layer
:auto-transition
for all of the timeline’s layers to the same value. SeeGES.Layer.set_auto_transition
() if you wish to set the layer’sGES.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.
Signal Details¶
- GES.Timeline.signals.commited(timeline)¶
- Signal Name:
commited
- Flags:
- 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. UseGES.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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signalgroup (
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’sGES.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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signalgroup (
GES.Group
) – The group that was removed from timelinechildren ([
GES.Container
]) – A list ofGES.Container
-s that _were_ the children of the removed group
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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signallayer (
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’sGES.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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signallayer (
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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signalclip (
GES.Clip
) – The clip that track_element is being added totrack_element (
GES.TrackElement
) – The element being added
- Returns:
A track to put track_element into, or
None
if it should be discarded.- Return type:
Simplified version of
GES.Timeline
::select-tracks-for-object
which only allows track_element to be added to a singleGES.Track
.New in version 1.18.
- GES.Timeline.signals.select_tracks_for_object(timeline, clip, track_element)¶
- Signal Name:
select-tracks-for-object
- Flags:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signalclip (
GES.Clip
) – The clip that track_element is being added totrack_element (
GES.TrackElement
) – The element being added
- Returns:
An array of
GES.Track
-s that track_element should be added to, orNone
to not add the element to any track.- Return type:
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'sGES.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 aGES.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 containedGES.Track
. The timeline will set theGLib.DestroyNotify
free function on theGLib.PtrArray
to dereference the elements.
- GES.Timeline.signals.snapping_ended(timeline, obj1, obj2, position)¶
- Signal Name:
snapping-ended
- Flags:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signalobj1 (
GES.TrackElement
) – The first element that was snappingobj2 (
GES.TrackElement
) – The second element that was snappingposition (
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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signalobj1 (
GES.TrackElement
) – The first element that is snappingobj2 (
GES.TrackElement
) – The second element that is snappingposition (
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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signaltrack (
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’sGES.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:
- Parameters:
timeline (
GES.Timeline
) – The object which received the signaltrack (
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¶
-
Whether to automatically create a transition whenever two
GES.Source
-s overlap in a track of the timeline. SeeGES.Layer
:auto-transition
if you want this to only happen in some layers.
- GES.Timeline.props.duration¶
-
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¶
-
The distance (in nanoseconds) at which a
GES.TimelineElement
being moved within the timeline should snap one of itsGES.Source
-s with anotherGES.Source
-s edge. SeeGES.EditMode
for which edges can snap during an edit. 0 means no snapping.