pub struct PreviewOptions {
pub frames_per_second: u64,
pub scale: u32,
pub previews_per_second: u64,
pub budget_bytes: u64,
}Expand description
How the index trades memory and pass length against how fine the scrub is.
Every field has a defensible default and a reason a caller would change it,
which is why this is a struct rather than three arguments: a 4K source wants
a smaller scale than a 480p one, a long documentary wants
fewer previews per second than a short clip, and an embedded caller wants a
smaller budget_bytes than a desktop editor.
Fields§
§frames_per_second: u64The source’s frame rate, which is what turns
previews_per_second into a frame stride.
scale: u32How far each preview is shrunk on each axis.
A preview is drawn stretched back over the whole video quad, so this is a resolution the picture is recognizable at rather than one it is sharp at: a quarter on each axis is a sixteenth of the memory and reads as the right shot on a 1080p source. The exact frame replaces it shortly anyway.
previews_per_second: u64How many previews a second of playback gets, when memory allows it.
Closer together is a finer scrub but a longer pass - every preview is a full-resolution picture the reader has to convert before it can be shrunk, and until the pass reaches the far end of the track a lookup there falls back to an earlier picture. Half a second apart is about as coarse as a scrub can be before the picture stops answering “which shot is this”.
budget_bytes: u64A ceiling on what the whole index may hold.
The stride follows from this and the track length rather than being fixed, so a long track keeps fewer, further-apart previews instead of growing without bound. At a quarter scale a 1080p preview is 480x270x4 bytes, so the default holds about 129 of them.
Implementations§
Source§impl PreviewOptions
impl PreviewOptions
Sourcepub fn for_frame_rate(frames_per_second: u64) -> Self
pub fn for_frame_rate(frames_per_second: u64) -> Self
The defaults, for a source running at frames_per_second.
Sourcepub fn stride(&self, dimensions: &VideoDimensions, frame_count: u64) -> u64
pub fn stride(&self, dimensions: &VideoDimensions, frame_count: u64) -> u64
How many frames apart the previews are: previews_per_second of
playback, or further apart when that many would not fit in the budget.
Sourcepub fn preview_bytes(&self, dimensions: &VideoDimensions) -> u64
pub fn preview_bytes(&self, dimensions: &VideoDimensions) -> u64
What one preview of a dimensions source costs in memory.