pub struct TimelineSegment {
pub source_start: Frame,
pub source_end: Frame,
pub timescale: f64,
}Expand description
One contiguous slice of the source recording, played at timescale.
The project’s video is the ordered concatenation of its segments:
- Trim = adjust
source_start/source_end. - Split = replace one segment with two adjacent ones that share the cut frame.
- Speed = change
timescale.
Fields§
§source_start: FrameFirst source frame of the slice (inclusive).
source_end: FrameOne past the last source frame of the slice (exclusive), so
source_end - source_start is the slice length in source frames.
timescale: f64Playback speed multiplier. 1.0 = real time; 2.0 = 2× (the
slice’s source span is traversed in half the project time);
0.5 = half speed (slow motion). Always > 0; non-positive
values are treated as 1.0 by the mapping helpers.
Implementations§
Source§impl TimelineSegment
impl TimelineSegment
Sourcepub fn new(source_start: Frame, source_end: Frame) -> Self
pub fn new(source_start: Frame, source_end: Frame) -> Self
A real-time (timescale = 1.0) slice of
[source_start, source_end).
Sourcepub fn with_speed(
source_start: Frame,
source_end: Frame,
timescale: f64,
) -> Self
pub fn with_speed( source_start: Frame, source_end: Frame, timescale: f64, ) -> Self
A slice of [source_start, source_end) played at timescale.
Sourcepub fn source_len(self) -> Frame
pub fn source_len(self) -> Frame
Length of the slice in source frames
(source_end - source_start, saturating at 0).
Sourcepub fn project_len(self) -> Frame
pub fn project_len(self) -> Frame
Length of the slice in project frames after applying
timescale. A 100-source-frame slice at timescale = 2.0
occupies 50 project frames; at 0.5, 200 project frames. Always
at least 1 project frame for a non-empty slice so a sped-up clip
never vanishes entirely.
Sourcepub fn source_frame_at(self, project_offset: Frame) -> Frame
pub fn source_frame_at(self, project_offset: Frame) -> Frame
Map a project-frame offset within this segment
(0..self.project_len()) to the source frame the renderer should
decode. Clamped to the last source frame of the slice so it can
never index past source_end.
Sourcefn norm_timescale(self) -> f64
fn norm_timescale(self) -> f64
timescale, sanitized: non-finite or non-positive values fall
back to real time (1.0) so the mapping never divides by zero or
produces NaN.
Trait Implementations§
Source§impl Clone for TimelineSegment
impl Clone for TimelineSegment
Source§fn clone(&self) -> TimelineSegment
fn clone(&self) -> TimelineSegment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimelineSegment
impl Debug for TimelineSegment
Source§impl<'de> Deserialize<'de> for TimelineSegment
impl<'de> Deserialize<'de> for TimelineSegment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for TimelineSegment
impl PartialEq for TimelineSegment
Source§fn eq(&self, other: &TimelineSegment) -> bool
fn eq(&self, other: &TimelineSegment) -> bool
self and other values to be equal, and is used by ==.