rsmpeg/avutil/
timestamp.rs

1use crate::ffi::{av_q2d, AVRational, AV_NOPTS_VALUE};
2use std::ffi::c_double;
3
4/// Get a string containing a timestamp representation.
5pub fn ts2str(ts: i64) -> String {
6    if ts == AV_NOPTS_VALUE {
7        "NOPTS".to_string()
8    } else {
9        ts.to_string()
10    }
11}
12
13/// Get a string containing a timestamp time representation.
14pub fn ts2timestr(ts: i64, tb: AVRational) -> String {
15    if ts == AV_NOPTS_VALUE {
16        "NOPTS".to_string()
17    } else {
18        format!("{:.6}", av_q2d(tb) * ts as c_double)
19    }
20}