feat(format/stream): expose frame-rate guessing

This commit is contained in:
tilpner
2023-05-24 17:22:59 +02:00
committed by Till Höppner
parent be43de0157
commit 70fae591d3
+19
View File
@@ -1,3 +1,5 @@
use std::ptr;
use libc::c_int;
use super::Disposition;
@@ -96,6 +98,23 @@ impl<'a> Stream<'a> {
unsafe { Rational::from((*self.as_ptr()).avg_frame_rate) }
}
pub fn guess_frame_rate(&self) -> Option<Rational> {
unsafe {
let r = Rational::from(av_guess_frame_rate(
self.context.as_ptr() as *mut _,
self.as_ptr() as *mut _,
ptr::null_mut(),
));
if r == Rational(0, 1) {
None
}
else {
Some(r)
}
}
}
pub fn metadata(&self) -> DictionaryRef<'_> {
unsafe { DictionaryRef::wrap((*self.as_ptr()).metadata) }
}