mirror of
https://github.com/encounter/rust-ffmpeg-zmwangx.git
synced 2026-07-10 21:18:40 -07:00
feat(format/stream): expose frame-rate guessing
This commit is contained in:
@@ -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) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user