Skip to main content

DropFrameCalc

Struct DropFrameCalc 

Source
pub struct DropFrameCalc;
Expand description

Drop-frame timecode calculator for 29.97 fps.

29.97 fps = 30000/1001 fps. To keep timecode aligned with real time, 2 frame numbers are dropped per minute, except every 10th minute. Actual frame count per 24-hour day: 24 * 107892 = 2,589,408 frames.

Implementations§

Source§

impl DropFrameCalc

Source

pub fn frame_count_to_df(frame_count: u64) -> (u8, u8, u8, u8)

Convert a frame count to drop-frame timecode (hh, mm, ss, ff).

Uses the standard SMPTE drop-frame algorithm.

Reference algorithm (from SMPTE 12M): D = frame_count D_f = D + 2 * (D / 17982) + 2 * ((D % 17982 - 2) / 1798) [only if remainder >= 2]

Source

pub fn df_to_frame_count(hh: u8, mm: u8, ss: u8, ff: u8) -> u64

Convert drop-frame timecode (hh, mm, ss, ff) to a frame count.

Standard SMPTE formula: frame_count = 108000hh + 1800mm + 30ss + ff - 2(total_minutes - total_minutes/10)

Note: 108000 = 30 * 3600 (raw 30fps hour count, NOT the drop-frame hour count).

Source

pub fn format_df(frame_count: u64) -> String

Format a frame count as a drop-frame timecode string.

Drop-frame timecode uses semicolons (;) as separators.

Source

pub fn parse_df(tc: &str) -> Option<u64>

Parse a drop-frame timecode string (HH;MM;SS;FF) into a frame count.

Returns None if the string is not a valid drop-frame timecode.

Source

pub fn is_dropped_frame(hh: u8, mm: u8, ss: u8, ff: u8) -> bool

Check whether a given timecode position is a dropped frame number.

Frames 0 and 1 at the start of each minute (except multiples of 10) are dropped.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.