|
OpenShot Library | libopenshot 1.1.1
|
This class represents a timeline. More...
#include <Timeline.h>
Public Member Functions | |
| void | AddClip (openshot::Clip *clip) |
| Add an openshot::Clip to the timeline. More... | |
| void | AddEffect (openshot::EffectBase *effect) |
| Add an effect to the timeline. More... | |
| void | AddTrackedObject (std::shared_ptr< openshot::TrackedObjectBase > trackedObject) |
| Add to the tracked_objects map a pointer to a tracked object (TrackedObjectBBox) More... | |
| std::shared_ptr< openshot::Frame > | apply_effects (std::shared_ptr< openshot::Frame > frame, int64_t timeline_frame_number, int layer, TimelineInfoStruct *options) |
| Apply global/timeline effects to the source frame (if any) More... | |
| void | ApplyJsonDiff (std::string value) |
| Apply a special formatted JSON object, which represents a change to the timeline (add, update, delete) This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync with another application... such as OpenShot Video Editor (http://www.openshot.org). More... | |
| void | ApplyMapperToClips () |
| Apply the timeline's framerate and samplerate to all clips. More... | |
| bool | AutoMapClips () |
| Determine if clips are automatically mapped to the timeline's framerate and samplerate. More... | |
| void | AutoMapClips (bool auto_map) |
| Automatically map all clips to the timeline's framerate and samplerate. More... | |
| uint64_t | CacheEpoch () const |
| Return the current cache invalidation epoch. More... | |
| bool | CacheRefreshPending () const |
| void | Clear () |
| Clear all clips, effects, and frame mappers from timeline (and free memory) More... | |
| void | ClearAllCache (bool deep=false) |
| std::list< openshot::EffectBase * > | ClipEffects () const |
| Return the list of effects on all clips. More... | |
| std::list< openshot::Clip * > | Clips () override |
| Return a list of clips on the timeline. More... | |
| void | Close () override |
| Close the timeline reader (and any resources it was consuming) More... | |
| std::list< openshot::EffectBase * > | Effects () |
| Return the list of effects on the timeline. More... | |
| openshot::CacheBase * | GetCache () override |
| Get the cache object used by this reader. More... | |
| openshot::Clip * | GetClip (const std::string &id) |
| Look up a single clip by ID. More... | |
| openshot::EffectBase * | GetClipEffect (const std::string &id) |
| Look up a clip effect by ID. More... | |
| openshot::EffectBase * | GetEffect (const std::string &id) |
| Look up a timeline effect by ID. More... | |
| std::shared_ptr< openshot::Frame > | GetFrame (int64_t requested_frame) override |
| int64_t | GetMaxFrame () |
| Look up the end frame number of the latest element on the timeline. More... | |
| double | GetMaxTime () |
| Look up the end time of the latest timeline element. More... | |
| int64_t | GetMinFrame () |
| Look up the start frame number of the first element on the timeline (first frame is 1) More... | |
| double | GetMinTime () |
| Look up the position/start time of the first timeline element. More... | |
| std::shared_ptr< openshot::TrackedObjectBase > | GetTrackedObject (std::string id) const |
| Return tracked object pointer by it's id. More... | |
| std::list< std::string > | GetTrackedObjectsIds () const |
| Return the ID's of the tracked objects as a list of strings. More... | |
| std::string | GetTrackedObjectValues (std::string id, int64_t frame_number) const |
| Return the trackedObject's properties as a JSON string. More... | |
| bool | IsOpen () override |
| Determine if reader is open or closed. More... | |
| std::string | Json () const override |
| Generate JSON string of this object. More... | |
| Json::Value | JsonValue () const override |
| Generate Json::Value for this object. More... | |
| std::string | Name () override |
| Return the type name of the class. More... | |
| void | Open () override |
| Open the reader (and start consuming resources) More... | |
| void | RemoveClip (openshot::Clip *clip) |
| Remove an openshot::Clip from the timeline. More... | |
| void | RemoveEffect (openshot::EffectBase *effect) |
| Remove an effect from the timeline. More... | |
| void | RequestClearAllCache () |
| void | SetCache (openshot::CacheBase *new_cache) |
| void | SetJson (const std::string value) override |
| Load JSON string into this object. More... | |
| void | SetJsonValue (const Json::Value root) override |
| Load Json::Value into this object. More... | |
| void | SetMaxSize (int width, int height) |
| void | SortTimeline () |
| Sort all clips and effects on timeline - which affects the internal order of clips and effects arrays This is called automatically when Clips or Effects modify the Layer(), Position(), Start(), or End(). More... | |
| Timeline (const std::string &projectPath, bool convert_absolute_paths) | |
| Project-file constructor for the timeline. More... | |
| Timeline (int width, int height, openshot::Fraction fps, int sample_rate, int channels, openshot::ChannelLayout channel_layout) | |
| Constructor for the timeline (which configures the default frame properties) More... | |
| Timeline (ReaderInfo info) | |
| Constructor which takes a ReaderInfo struct to configure parameters. More... | |
| virtual | ~Timeline () |
Public Member Functions inherited from openshot::TimelineBase | |
| virtual std::list< openshot::Clip * > | Clips ()=0 |
| TimelineBase () | |
| Constructor for the base timeline. More... | |
| virtual | ~TimelineBase ()=default |
Public Member Functions inherited from openshot::ReaderBase | |
| bool | ApplyOrientationMetadata () const |
| Return whether readers apply source orientation metadata to returned frames. More... | |
| void | ApplyOrientationMetadata (bool value) |
| Set whether readers should apply source orientation metadata to returned frames. More... | |
| virtual void | Close ()=0 |
| Close the reader (and any resources it was consuming) More... | |
| void | DisplayInfo (std::ostream *out=&std::cout) |
| Display file information in the standard output stream (stdout) More... | |
| virtual openshot::CacheBase * | GetCache ()=0 |
| Get the cache object used by this reader (note: not all readers use cache) More... | |
| virtual std::shared_ptr< openshot::Frame > | GetFrame (int64_t number)=0 |
| virtual bool | HardwareDecodeSuccessful () const |
| bool | HasMaxDecodeSize () const |
| Return true when a maximum decoded frame size is active. More... | |
| virtual bool | IsOpen ()=0 |
| Determine if reader is open or closed. More... | |
| virtual std::string | Json () const =0 |
| Generate JSON string of this object. More... | |
| virtual Json::Value | JsonValue () const =0 |
| Generate Json::Value for this object. More... | |
| int | MaxDecodeHeight () const |
| Return the current maximum decoded frame height (0 when unlimited). More... | |
| int | MaxDecodeWidth () const |
| Return the current maximum decoded frame width (0 when unlimited). More... | |
| virtual std::string | Name ()=0 |
| Return the type name of the class. More... | |
| virtual void | Open ()=0 |
| Open the reader (and start consuming resources, such as images or video files) More... | |
| openshot::ClipBase * | ParentClip () |
| Parent clip object of this reader (which can be unparented and NULL) More... | |
| void | ParentClip (openshot::ClipBase *new_clip) |
| Set parent clip object of this reader. More... | |
| ReaderBase () | |
| Constructor for the base reader, where many things are initialized. More... | |
| virtual void | SetJson (const std::string value)=0 |
| Load JSON string into this object. More... | |
| virtual void | SetJsonValue (const Json::Value root)=0 |
| Load Json::Value into this object. More... | |
| void | SetMaxDecodeSize (int width, int height) |
| virtual | ~ReaderBase ()=default |
Public Attributes | |
| openshot::Color | color |
| Background color of timeline canvas. More... | |
| openshot::Keyframe | viewport_scale |
| Curve representing the scale of the viewport (0 to 100) More... | |
| openshot::Keyframe | viewport_x |
| Curve representing the x coordinate for the viewport. More... | |
| openshot::Keyframe | viewport_y |
| Curve representing the y coordinate for the viewport. More... | |
Public Attributes inherited from openshot::TimelineBase | |
| int | preview_height |
| Optional preview width of timeline image. If your preview window is smaller than the timeline, it's recommended to set this. More... | |
| int | preview_width |
| Optional preview width of timeline image. If your preview window is smaller than the timeline, it's recommended to set this. More... | |
Public Attributes inherited from openshot::ReaderBase | |
| openshot::ReaderInfo | info |
| Information about the current media file. More... | |
Additional Inherited Members | |
Protected Attributes inherited from openshot::ReaderBase | |
| bool | apply_orientation_metadata |
| Apply source orientation metadata while reading frames. More... | |
| openshot::ClipBase * | clip |
| Pointer to the parent clip instance (if any) More... | |
| std::recursive_mutex | getFrameMutex |
| Mutex for multiple threads. More... | |
| int | max_decode_height |
| Optional maximum decoded frame height (0 disables the limit) More... | |
| int | max_decode_width |
| Optional maximum decoded frame width (0 disables the limit) More... | |
This class represents a timeline.
The timeline is one of the most important features of a video editor, and controls all aspects of how video, image, and audio clips are combined together, and how the final video output will be rendered. It has a collection of layers and clips, that arrange, sequence, and generate the final video output.
The following graphic displays a timeline, and how clips can be arranged, scaled, and layered together. It also demonstrates how the viewport can be scaled smaller than the canvas, which can be used to zoom and pan around the canvas (i.e. pan & scan).
The following graphic displays how the playhead determines which frames to combine and layer.
Lets take a look at what the code looks like:
Definition at line 154 of file Timeline.h.
| Timeline::Timeline | ( | int | width, |
| int | height, | ||
| openshot::Fraction | fps, | ||
| int | sample_rate, | ||
| int | channels, | ||
| openshot::ChannelLayout | channel_layout | ||
| ) |
Constructor for the timeline (which configures the default frame properties)
| width | The image width of generated openshot::Frame objects |
| height | The image height of generated openshot::Frame objects |
| fps | The frame rate of the generated video |
| sample_rate | The audio sample rate |
| channels | The number of audio channels |
| channel_layout | The channel layout (i.e. mono, stereo, 3 point surround, etc...) |
Definition at line 36 of file Timeline.cpp.
| Timeline::Timeline | ( | ReaderInfo | info | ) |
Constructor which takes a ReaderInfo struct to configure parameters.
| info | The reader parameters to configure the new timeline with |
Definition at line 82 of file Timeline.cpp.
| Timeline::Timeline | ( | const std::string & | projectPath, |
| bool | convert_absolute_paths | ||
| ) |
Project-file constructor for the timeline.
Loads a JSON structure from a file path, and initializes the timeline described within.
| projectPath | The path of the UTF-8 *.osp project file (JSON contents). Contents will be loaded automatically. |
| convert_absolute_paths | Should all paths be converted to absolute paths (relative to the location of projectPath) |
Definition at line 87 of file Timeline.cpp.
|
virtual |
Definition at line 214 of file Timeline.cpp.
| void Timeline::AddClip | ( | openshot::Clip * | clip | ) |
Add an openshot::Clip to the timeline.
| clip | Add an openshot::Clip to the timeline. A clip can contain any type of Reader. |
Definition at line 340 of file Timeline.cpp.
Referenced by SetJsonValue(), and openshot::QtPlayer::SetSource().
| void Timeline::AddEffect | ( | openshot::EffectBase * | effect | ) |
Add an effect to the timeline.
| effect | Add an effect to the timeline. An effect can modify the audio or video of an openshot::Frame. |
Definition at line 368 of file Timeline.cpp.
Referenced by SetJsonValue().
| void Timeline::AddTrackedObject | ( | std::shared_ptr< openshot::TrackedObjectBase > | trackedObject | ) |
Add to the tracked_objects map a pointer to a tracked object (TrackedObjectBBox)
Definition at line 231 of file Timeline.cpp.
Referenced by openshot::Clip::AddEffect().
| std::shared_ptr< Frame > Timeline::apply_effects | ( | std::shared_ptr< openshot::Frame > | frame, |
| int64_t | timeline_frame_number, | ||
| int | layer, | ||
| TimelineInfoStruct * | options | ||
| ) |
Apply global/timeline effects to the source frame (if any)
Definition at line 563 of file Timeline.cpp.
| void Timeline::ApplyJsonDiff | ( | std::string | value | ) |
Apply a special formatted JSON object, which represents a change to the timeline (add, update, delete) This is primarily designed to keep the timeline (and its child objects... such as clips and effects) in sync with another application... such as OpenShot Video Editor (http://www.openshot.org).
| value | A JSON string containing a key, value, and type of change. |
Definition at line 1403 of file Timeline.cpp.
| void Timeline::ApplyMapperToClips | ( | ) |
Apply the timeline's framerate and samplerate to all clips.
Definition at line 539 of file Timeline.cpp.
|
inline |
Determine if clips are automatically mapped to the timeline's framerate and samplerate.
Definition at line 278 of file Timeline.h.
|
inline |
Automatically map all clips to the timeline's framerate and samplerate.
Definition at line 281 of file Timeline.h.
|
inline |
Return the current cache invalidation epoch.
Definition at line 334 of file Timeline.h.
Referenced by ApplyJsonDiff(), GetFrame(), openshot::VideoCacheThread::prefetchWindow(), and openshot::VideoCacheThread::run().
|
inline |
Definition at line 331 of file Timeline.h.
Referenced by GetFrame().
| void Timeline::Clear | ( | ) |
Clear all clips, effects, and frame mappers from timeline (and free memory)
Definition at line 900 of file Timeline.cpp.
Referenced by ~Timeline().
| void Timeline::ClearAllCache | ( | bool | deep = false | ) |
Clear all cache for this timeline instance, including all clips' cache
| deep | If True, clear all FrameMappers and nested Readers (QtImageReader, FFmpegReader, etc...) |
Definition at line 1836 of file Timeline.cpp.
Referenced by ApplyMapperToClips(), Close(), and GetFrame().
| std::list< openshot::EffectBase * > Timeline::ClipEffects | ( | ) | const |
Return the list of effects on all clips.
Definition at line 458 of file Timeline.cpp.
Referenced by openshot::EffectBase::SetJsonValue().
|
inlineoverridevirtual |
Return a list of clips on the timeline.
Implements openshot::TimelineBase.
Definition at line 291 of file Timeline.h.
|
overridevirtual |
Close the timeline reader (and any resources it was consuming)
Implements openshot::ReaderBase.
Definition at line 946 of file Timeline.cpp.
Referenced by SetJsonValue(), and ~Timeline().
|
inline |
Return the list of effects on the timeline.
Definition at line 316 of file Timeline.h.
|
inlineoverridevirtual |
Get the cache object used by this reader.
Implements openshot::ReaderBase.
Definition at line 322 of file Timeline.h.
| openshot::Clip * Timeline::GetClip | ( | const std::string & | id | ) |
Look up a single clip by ID.
Definition at line 422 of file Timeline.cpp.
Referenced by openshot::Clip::AttachToObject().
| openshot::EffectBase * Timeline::GetClipEffect | ( | const std::string & | id | ) |
Look up a clip effect by ID.
Definition at line 445 of file Timeline.cpp.
Referenced by openshot::EffectBase::SetParentEffect().
| openshot::EffectBase * Timeline::GetEffect | ( | const std::string & | id | ) |
Look up a timeline effect by ID.
Definition at line 434 of file Timeline.cpp.
|
overridevirtual |
Get an openshot::Frame object for a specific frame number of this timeline.
| requested_frame | The frame number that is requested. |
Implements openshot::ReaderBase.
Definition at line 980 of file Timeline.cpp.
| int64_t Timeline::GetMaxFrame | ( | ) |
Look up the end frame number of the latest element on the timeline.
Definition at line 483 of file Timeline.cpp.
Referenced by GetFrame().
| double Timeline::GetMaxTime | ( | ) |
Look up the end time of the latest timeline element.
Definition at line 477 of file Timeline.cpp.
Referenced by GetMaxFrame().
| int64_t Timeline::GetMinFrame | ( | ) |
Look up the start frame number of the first element on the timeline (first frame is 1)
Definition at line 496 of file Timeline.cpp.
| double Timeline::GetMinTime | ( | ) |
Look up the position/start time of the first timeline element.
Definition at line 504 of file Timeline.cpp.
Referenced by GetMinFrame().
| std::shared_ptr< openshot::TrackedObjectBase > Timeline::GetTrackedObject | ( | std::string | id | ) | const |
Return tracked object pointer by it's id.
Definition at line 249 of file Timeline.cpp.
Referenced by openshot::Clip::AttachToObject().
| std::list< std::string > Timeline::GetTrackedObjectsIds | ( | ) | const |
Return the ID's of the tracked objects as a list of strings.
Definition at line 266 of file Timeline.cpp.
| std::string Timeline::GetTrackedObjectValues | ( | std::string | id, |
| int64_t | frame_number | ||
| ) | const |
Return the trackedObject's properties as a JSON string.
Definition at line 282 of file Timeline.cpp.
|
inlineoverridevirtual |
Determine if reader is open or closed.
Implements openshot::ReaderBase.
Definition at line 351 of file Timeline.h.
|
overridevirtual |
Generate JSON string of this object.
Implements openshot::ReaderBase.
Definition at line 1240 of file Timeline.cpp.
|
overridevirtual |
Generate Json::Value for this object.
Implements openshot::ReaderBase.
Definition at line 1247 of file Timeline.cpp.
Referenced by Json().
|
inlineoverridevirtual |
Return the type name of the class.
Implements openshot::ReaderBase.
Definition at line 354 of file Timeline.h.
|
overridevirtual |
Open the reader (and start consuming resources)
Implements openshot::ReaderBase.
Definition at line 968 of file Timeline.cpp.
Referenced by SetJsonValue(), openshot::QtPlayer::SetSource(), and openshot::QtPlayer::SetTimelineSource().
| void Timeline::RemoveClip | ( | openshot::Clip * | clip | ) |
Remove an openshot::Clip from the timeline.
| clip | Remove an openshot::Clip from the timeline. |
Definition at line 403 of file Timeline.cpp.
| void Timeline::RemoveEffect | ( | openshot::EffectBase * | effect | ) |
Remove an effect from the timeline.
| effect | Remove an effect from the timeline. |
Definition at line 384 of file Timeline.cpp.
| void Timeline::RequestClearAllCache | ( | ) |
Request a full refresh without waiting for an active decoder. Subsequent GetFrame calls bypass cached results until the decoder consumes it.
Definition at line 1830 of file Timeline.cpp.
| void Timeline::SetCache | ( | openshot::CacheBase * | new_cache | ) |
Set the cache object used by this reader. You must now manage the lifecycle of this cache object though (Timeline will not delete it for you).
Definition at line 1224 of file Timeline.cpp.
|
overridevirtual |
Load JSON string into this object.
Implements openshot::ReaderBase.
Definition at line 1281 of file Timeline.cpp.
Referenced by openshot::QtPlayer::SetTimelineSource(), and Timeline().
|
overridevirtual |
Load Json::Value into this object.
Implements openshot::ReaderBase.
Definition at line 1301 of file Timeline.cpp.
Referenced by SetJson().
| void Timeline::SetMaxSize | ( | int | width, |
| int | height | ||
| ) |
Fit the preview within these bounds, aligning reduced dimensions to four pixels (minimum 4x4). Ignore nonpositive bounds; preserve native output size.
Definition at line 1880 of file Timeline.cpp.
Referenced by Timeline().
|
inline |
Sort all clips and effects on timeline - which affects the internal order of clips and effects arrays This is called automatically when Clips or Effects modify the Layer(), Position(), Start(), or End().
Definition at line 385 of file Timeline.h.
Referenced by openshot::ClipBase::End(), openshot::ClipBase::Layer(), openshot::ClipBase::Position(), and openshot::ClipBase::Start().
| openshot::Color openshot::Timeline::color |
Background color of timeline canvas.
Definition at line 348 of file Timeline.h.
Referenced by GetFrame(), JsonValue(), and Timeline().
| openshot::Keyframe openshot::Timeline::viewport_scale |
Curve representing the scale of the viewport (0 to 100)
Definition at line 343 of file Timeline.h.
Referenced by JsonValue(), and Timeline().
| openshot::Keyframe openshot::Timeline::viewport_x |
Curve representing the x coordinate for the viewport.
Definition at line 344 of file Timeline.h.
Referenced by JsonValue(), and Timeline().
| openshot::Keyframe openshot::Timeline::viewport_y |
Curve representing the y coordinate for the viewport.
Definition at line 345 of file Timeline.h.
Referenced by JsonValue(), and Timeline().