Skip to main content

parse_ass_time

Function parse_ass_time 

Source
pub fn parse_ass_time(time_str: &str) -> Result<u32, CoreError>
Expand description

Parse ASS time format (H:MM:SS.CC) to centiseconds, the libass way.

ASS uses centiseconds (1/100th second) for timing. The fractional field is read exactly as libass reads it: as an integer count of centiseconds via sscanf("%d:%d:%d.%d") (then ms = field * 10 internally). The digit count is ignored and the value is not normalised, so .5 is 5cs, .054 is 54cs, and .100 is 100cs (one second). This matches the reference player rather than interpreting a 3-digit field as true milliseconds.

§Example

assert_eq!(parse_ass_time("0:01:30.50")?, 9050); // 1:30.5 = 9050 centiseconds

§Errors

Returns an error if the time format is invalid or cannot be parsed.