Struct ffmpeg_the_third::util::rational::Rational
source · pub struct Rational(pub i32, pub i32);
Tuple Fields§
§0: i32
§1: i32
Implementations§
source§impl Rational
impl Rational
pub fn new(numerator: i32, denominator: i32) -> Self
pub fn numerator(&self) -> i32
pub fn denominator(&self) -> i32
pub fn reduce(&self) -> Rational
pub fn reduce_with_limit(&self, max: i32) -> Result<Rational, Rational>
sourcepub fn invert(&self) -> Rational
pub fn invert(&self) -> Rational
Examples found in repository?
examples/transcode-x264.rs (line 62)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
fn new(
ist: &format::stream::Stream,
octx: &mut format::context::Output,
ost_index: usize,
x264_opts: Dictionary,
enable_logging: bool,
) -> Result<Self, ffmpeg::Error> {
let global_header = octx.format().flags().contains(format::Flags::GLOBAL_HEADER);
let decoder = ffmpeg::codec::context::Context::from_parameters(ist.parameters())?
.decoder()
.video()?;
let mut ost = octx.add_stream(encoder::find(codec::Id::H264))?;
let mut encoder = codec::context::Context::from_parameters(ost.parameters())?
.encoder()
.video()?;
encoder.set_height(decoder.height());
encoder.set_width(decoder.width());
encoder.set_aspect_ratio(decoder.aspect_ratio());
encoder.set_format(decoder.format());
encoder.set_frame_rate(decoder.frame_rate());
encoder.set_time_base(decoder.frame_rate().unwrap().invert());
if global_header {
encoder.set_flags(codec::Flags::GLOBAL_HEADER);
}
encoder
.open_with(x264_opts)
.expect("error opening libx264 encoder with supplied settings");
encoder = codec::context::Context::from_parameters(ost.parameters())?
.encoder()
.video()?;
ost.set_parameters(&encoder);
Ok(Self {
ost_index,
decoder,
encoder: codec::context::Context::from_parameters(ost.parameters())?
.encoder()
.video()?,
logging_enabled: enable_logging,
frame_count: 0,
last_log_frame_count: 0,
starting_time: Instant::now(),
last_log_time: Instant::now(),
})
}
Trait Implementations§
source§impl From<AVRational> for Rational
impl From<AVRational> for Rational
source§fn from(value: AVRational) -> Rational
fn from(value: AVRational) -> Rational
Converts to this type from the input type.
source§impl From<Rational> for AVRational
impl From<Rational> for AVRational
source§fn from(value: Rational) -> AVRational
fn from(value: Rational) -> AVRational
Converts to this type from the input type.
source§impl PartialEq<Rational> for Rational
impl PartialEq<Rational> for Rational
source§impl PartialOrd<Rational> for Rational
impl PartialOrd<Rational> for Rational
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more