mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
refactor: rename rate methods to either sample_rate or frame_rate
This commit is contained in:
+12
-12
@@ -20,11 +20,11 @@ fn main() {
|
||||
}
|
||||
|
||||
if let Ok(video) = codec.video() {
|
||||
if let Some(rates) = video.rates() {
|
||||
println!("\t rates: {:?}", rates.collect::<Vec<_>>());
|
||||
if let Some(rates) = video.frame_rates() {
|
||||
println!("\t frame rates: {:?}", rates.collect::<Vec<_>>());
|
||||
}
|
||||
else {
|
||||
println!("\t rates: any");
|
||||
println!("\t frame rates: any");
|
||||
}
|
||||
|
||||
if let Some(formats) = video.formats() {
|
||||
@@ -36,11 +36,11 @@ fn main() {
|
||||
}
|
||||
|
||||
if let Ok(audio) = codec.audio() {
|
||||
if let Some(rates) = audio.rates() {
|
||||
println!("\t rates: {:?}", rates.collect::<Vec<_>>());
|
||||
if let Some(rates) = audio.sample_rates() {
|
||||
println!("\t sample rates: {:?}", rates.collect::<Vec<_>>());
|
||||
}
|
||||
else {
|
||||
println!("\t rates: any");
|
||||
println!("\t sample rates: any");
|
||||
}
|
||||
|
||||
if let Some(formats) = audio.formats() {
|
||||
@@ -75,11 +75,11 @@ fn main() {
|
||||
}
|
||||
|
||||
if let Ok(video) = codec.video() {
|
||||
if let Some(rates) = video.rates() {
|
||||
println!("\t rates: {:?}", rates.collect::<Vec<_>>());
|
||||
if let Some(rates) = video.frame_rates() {
|
||||
println!("\t frame rates: {:?}", rates.collect::<Vec<_>>());
|
||||
}
|
||||
else {
|
||||
println!("\t rates: any");
|
||||
println!("\t frame rates: any");
|
||||
}
|
||||
|
||||
if let Some(formats) = video.formats() {
|
||||
@@ -91,11 +91,11 @@ fn main() {
|
||||
}
|
||||
|
||||
if let Ok(audio) = codec.audio() {
|
||||
if let Some(rates) = audio.rates() {
|
||||
println!("\t rates: {:?}", rates.collect::<Vec<_>>());
|
||||
if let Some(rates) = audio.sample_rates() {
|
||||
println!("\t sample rates: {:?}", rates.collect::<Vec<_>>());
|
||||
}
|
||||
else {
|
||||
println!("\t rates: any");
|
||||
println!("\t sample rates: any");
|
||||
}
|
||||
|
||||
if let Some(formats) = audio.formats() {
|
||||
|
||||
@@ -44,7 +44,7 @@ fn main() {
|
||||
println!("\tframes: {}", stream.frames());
|
||||
println!("\tdisposition: {:?}", stream.disposition());
|
||||
println!("\tdiscard: {:?}", stream.discard());
|
||||
println!("\trate: {}", stream.rate());
|
||||
println!("\tframe rate: {}", stream.frame_rate());
|
||||
|
||||
let codec = stream.codec();
|
||||
println!("\tmedium: {:?}", codec.medium());
|
||||
@@ -77,7 +77,7 @@ fn main() {
|
||||
println!("\tbit_rate: {}", audio.bit_rate());
|
||||
println!("\tmax_rate: {}", audio.max_bit_rate());
|
||||
println!("\tdelay: {}", audio.delay());
|
||||
println!("\taudio.rate: {}", audio.rate());
|
||||
println!("\taudio.sample_rate: {}", audio.sample_rate());
|
||||
println!("\taudio.channels: {}", audio.channels());
|
||||
println!("\taudio.format: {:?}", audio.format());
|
||||
println!("\taudio.frames: {}", audio.frames());
|
||||
|
||||
@@ -12,7 +12,7 @@ fn filter(
|
||||
let args = format!(
|
||||
"time_base={}:sample_rate={}:sample_fmt={}:channel_layout=0x{:x}",
|
||||
decoder.time_base(),
|
||||
decoder.rate(),
|
||||
decoder.sample_rate(),
|
||||
decoder.format().name(),
|
||||
decoder.channel_layout().bits()
|
||||
);
|
||||
@@ -25,7 +25,7 @@ fn filter(
|
||||
|
||||
out.set_sample_format(encoder.format());
|
||||
out.set_channel_layout(encoder.channel_layout());
|
||||
out.set_sample_rate(encoder.rate());
|
||||
out.set_sample_rate(encoder.sample_rate());
|
||||
}
|
||||
|
||||
filter.output("in", 0)?.input("out", 0)?.parse(spec)?;
|
||||
@@ -89,7 +89,7 @@ fn transcoder<P: AsRef<Path>>(
|
||||
encoder.set_flags(ffmpeg::codec::flag::Flags::GLOBAL_HEADER);
|
||||
}
|
||||
|
||||
encoder.set_rate(decoder.rate() as i32);
|
||||
encoder.set_sample_rate(decoder.sample_rate() as i32);
|
||||
encoder.set_channel_layout(channel_layout);
|
||||
encoder.set_channels(channel_layout.channels());
|
||||
encoder.set_format(
|
||||
@@ -102,8 +102,8 @@ fn transcoder<P: AsRef<Path>>(
|
||||
encoder.set_bit_rate(decoder.bit_rate());
|
||||
encoder.set_max_bit_rate(decoder.max_bit_rate());
|
||||
|
||||
encoder.set_time_base((1, decoder.rate() as i32));
|
||||
output.set_time_base((1, decoder.rate() as i32));
|
||||
encoder.set_time_base((1, decoder.sample_rate() as i32));
|
||||
output.set_time_base((1, decoder.sample_rate() as i32));
|
||||
|
||||
let encoder = encoder.open_as(codec)?;
|
||||
output.set_parameters(&encoder);
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ impl Audio {
|
||||
}
|
||||
|
||||
impl Audio {
|
||||
pub fn rates(&self) -> Option<RateIter> {
|
||||
pub fn sample_rates(&self) -> Option<RateIter> {
|
||||
unsafe {
|
||||
if (*self.as_ptr()).supported_samplerates.is_null() {
|
||||
None
|
||||
|
||||
@@ -30,7 +30,7 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rate(&self) -> u32 {
|
||||
pub fn sample_rate(&self) -> u32 {
|
||||
unsafe { (*self.as_ptr()).sample_rate as u32 }
|
||||
}
|
||||
|
||||
|
||||
@@ -77,13 +77,13 @@ impl Audio {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_rate(&mut self, rate: i32) {
|
||||
pub fn set_sample_rate(&mut self, rate: i32) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).sample_rate = rate;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rate(&self) -> u32 {
|
||||
pub fn sample_rate(&self) -> u32 {
|
||||
unsafe { (*self.as_ptr()).sample_rate as u32 }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ impl Video {
|
||||
}
|
||||
|
||||
impl Video {
|
||||
pub fn rates(&self) -> Option<RateIter> {
|
||||
pub fn frame_rates(&self) -> Option<RateIter> {
|
||||
unsafe {
|
||||
if (*self.codec.as_ptr()).supported_framerates.is_null() {
|
||||
None
|
||||
|
||||
@@ -88,7 +88,7 @@ impl<'a> Stream<'a> {
|
||||
SideDataIter::new(self)
|
||||
}
|
||||
|
||||
pub fn rate(&self) -> Rational {
|
||||
pub fn frame_rate(&self) -> Rational {
|
||||
unsafe { Rational::from(av_stream_get_r_frame_rate(self.as_ptr())) }
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ impl frame::Audio {
|
||||
Context::get(
|
||||
self.format(),
|
||||
self.channel_layout(),
|
||||
self.rate(),
|
||||
self.sample_rate(),
|
||||
format,
|
||||
channel_layout,
|
||||
rate,
|
||||
@@ -31,7 +31,7 @@ impl decoder::Audio {
|
||||
Context::get(
|
||||
self.format(),
|
||||
self.channel_layout(),
|
||||
self.rate(),
|
||||
self.sample_rate(),
|
||||
format,
|
||||
channel_layout,
|
||||
rate,
|
||||
|
||||
@@ -90,7 +90,7 @@ impl Audio {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn rate(&self) -> u32 {
|
||||
pub fn sample_rate(&self) -> u32 {
|
||||
unsafe { av_frame_get_sample_rate(self.as_ptr()) as u32 }
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ impl ::std::fmt::Debug for Audio {
|
||||
f.write_str("ffmpeg::frame::Audio { ")?;
|
||||
f.write_str(&format!("format: {:?}, ", self.format()))?;
|
||||
f.write_str(&format!("channels: {:?}, ", self.channels()))?;
|
||||
f.write_str(&format!("rate: {:?}, ", self.rate()))?;
|
||||
f.write_str(&format!("sample_rate: {:?}, ", self.sample_rate()))?;
|
||||
f.write_str(&format!("samples: {:?} ", self.samples()))?;
|
||||
f.write_str("}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user