pub struct ChannelLayout { /* private fields */ }Implementations§
Source§impl ChannelLayout
impl ChannelLayout
pub const FRONT_LEFT: ChannelLayout
pub const FRONT_RIGHT: ChannelLayout
pub const FRONT_CENTER: ChannelLayout
pub const LOW_FREQUENCY: ChannelLayout
pub const BACK_LEFT: ChannelLayout
pub const BACK_RIGHT: ChannelLayout
pub const FRONT_LEFT_OF_CENTER: ChannelLayout
pub const FRONT_RIGHT_OF_CENTER: ChannelLayout
pub const BACK_CENTER: ChannelLayout
pub const SIDE_LEFT: ChannelLayout
pub const SIDE_RIGHT: ChannelLayout
pub const TOP_CENTER: ChannelLayout
pub const TOP_FRONT_LEFT: ChannelLayout
pub const TOP_FRONT_CENTER: ChannelLayout
pub const TOP_FRONT_RIGHT: ChannelLayout
pub const TOP_BACK_LEFT: ChannelLayout
pub const TOP_BACK_CENTER: ChannelLayout
pub const TOP_BACK_RIGHT: ChannelLayout
pub const STEREO_LEFT: ChannelLayout
pub const STEREO_RIGHT: ChannelLayout
pub const WIDE_LEFT: ChannelLayout
pub const WIDE_RIGHT: ChannelLayout
pub const SURROUND_DIRECT_LEFT: ChannelLayout
pub const SURROUND_DIRECT_RIGHT: ChannelLayout
pub const LOW_FREQUENCY_2: ChannelLayout
pub const NATIVE: ChannelLayout
pub const MONO: ChannelLayout
pub const STEREO: ChannelLayout
pub const _2POINT1: ChannelLayout
pub const _2_1: ChannelLayout
pub const SURROUND: ChannelLayout
pub const _3POINT1: ChannelLayout
pub const _4POINT0: ChannelLayout
pub const _4POINT1: ChannelLayout
pub const _2_2: ChannelLayout
pub const QUAD: ChannelLayout
pub const _5POINT0: ChannelLayout
pub const _5POINT1: ChannelLayout
pub const _5POINT0_BACK: ChannelLayout
pub const _5POINT1_BACK: ChannelLayout
pub const _6POINT0: ChannelLayout
pub const _6POINT0_FRONT: ChannelLayout
pub const HEXAGONAL: ChannelLayout
pub const _6POINT1: ChannelLayout
pub const _6POINT1_BACK: ChannelLayout
pub const _6POINT1_FRONT: ChannelLayout
pub const _7POINT0: ChannelLayout
pub const _7POINT0_FRONT: ChannelLayout
pub const _7POINT1: ChannelLayout
pub const _7POINT1_WIDE: ChannelLayout
pub const _7POINT1_WIDE_BACK: ChannelLayout
pub const OCTAGONAL: ChannelLayout
pub const HEXADECAGONAL: ChannelLayout
pub const STEREO_DOWNMIX: ChannelLayout
Sourcepub const fn empty() -> ChannelLayout
pub const fn empty() -> ChannelLayout
Returns an empty set of flags
Sourcepub const fn all() -> ChannelLayout
pub const fn all() -> ChannelLayout
Returns the set containing all flags.
Sourcepub const fn bits(&self) -> c_ulonglong
pub const fn bits(&self) -> c_ulonglong
Returns the raw value of the flags currently stored.
Examples found in repository?
9fn filter(
10 spec: &str,
11 decoder: &codec::decoder::Audio,
12 encoder: &codec::encoder::Audio,
13) -> Result<filter::Graph, ffmpeg::Error> {
14 let mut filter = filter::Graph::new();
15
16 let args = format!(
17 "time_base={}:sample_rate={}:sample_fmt={}:channel_layout=0x{:x}",
18 decoder.time_base(),
19 decoder.rate(),
20 decoder.format().name(),
21 decoder.channel_layout().bits()
22 );
23
24 filter.add(&filter::find("abuffer").unwrap(), "in", &args)?;
25 filter.add(&filter::find("abuffersink").unwrap(), "out", "")?;
26
27 {
28 let mut out = filter.get("out").unwrap();
29
30 out.set_sample_format(encoder.format());
31 out.set_channel_layout(encoder.channel_layout());
32 out.set_sample_rate(encoder.rate());
33 }
34
35 filter.output("in", 0)?.input("out", 0)?.parse(spec)?;
36 filter.validate()?;
37
38 println!("{}", filter.dump());
39
40 if let Some(codec) = encoder.codec() {
41 if !codec
42 .capabilities()
43 .contains(ffmpeg::codec::capabilities::Capabilities::VARIABLE_FRAME_SIZE)
44 {
45 filter
46 .get("out")
47 .unwrap()
48 .sink()
49 .set_frame_size(encoder.frame_size());
50 }
51 }
52
53 Ok(filter)
54}Sourcepub fn from_bits(bits: c_ulonglong) -> Option<ChannelLayout>
pub fn from_bits(bits: c_ulonglong) -> Option<ChannelLayout>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
Sourcepub const fn from_bits_truncate(bits: c_ulonglong) -> ChannelLayout
pub const fn from_bits_truncate(bits: c_ulonglong) -> ChannelLayout
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
Sourcepub const unsafe fn from_bits_unchecked(bits: c_ulonglong) -> ChannelLayout
pub const unsafe fn from_bits_unchecked(bits: c_ulonglong) -> ChannelLayout
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
Sourcepub const fn intersects(&self, other: ChannelLayout) -> bool
pub const fn intersects(&self, other: ChannelLayout) -> bool
Returns true if there are flags common to both self and other.
Sourcepub const fn contains(&self, other: ChannelLayout) -> bool
pub const fn contains(&self, other: ChannelLayout) -> bool
Returns true all of the flags in other are contained within self.
Sourcepub fn insert(&mut self, other: ChannelLayout)
pub fn insert(&mut self, other: ChannelLayout)
Inserts the specified flags in-place.
Sourcepub fn remove(&mut self, other: ChannelLayout)
pub fn remove(&mut self, other: ChannelLayout)
Removes the specified flags in-place.
Sourcepub fn toggle(&mut self, other: ChannelLayout)
pub fn toggle(&mut self, other: ChannelLayout)
Toggles the specified flags in-place.
Sourcepub fn set(&mut self, other: ChannelLayout, value: bool)
pub fn set(&mut self, other: ChannelLayout, value: bool)
Inserts or removes the specified flags depending on the passed value.
Source§impl ChannelLayout
impl ChannelLayout
Sourcepub fn channels(&self) -> i32
pub fn channels(&self) -> i32
Examples found in repository?
63fn transcoder<P: AsRef<Path>>(
64 ictx: &mut format::context::Input,
65 octx: &mut format::context::Output,
66 path: &P,
67 filter_spec: &str,
68) -> Result<Transcoder, ffmpeg::Error> {
69 let input = ictx
70 .streams()
71 .best(media::Type::Audio)
72 .expect("could not find best audio stream");
73 let mut decoder = input.codec().decoder().audio()?;
74 let codec = ffmpeg::encoder::find(octx.format().codec(path, media::Type::Audio))
75 .expect("failed to find encoder")
76 .audio()?;
77 let global = octx
78 .format()
79 .flags()
80 .contains(ffmpeg::format::flag::Flags::GLOBAL_HEADER);
81
82 decoder.set_parameters(input.parameters())?;
83
84 let mut output = octx.add_stream(codec)?;
85 let mut encoder = output.codec().encoder().audio()?;
86
87 let channel_layout = codec
88 .channel_layouts()
89 .map(|cls| cls.best(decoder.channel_layout().channels()))
90 .unwrap_or(ffmpeg::channel_layout::ChannelLayout::STEREO);
91
92 if global {
93 encoder.set_flags(ffmpeg::codec::flag::Flags::GLOBAL_HEADER);
94 }
95
96 encoder.set_rate(decoder.rate() as i32);
97 encoder.set_channel_layout(channel_layout);
98 encoder.set_channels(channel_layout.channels());
99 encoder.set_format(
100 codec
101 .formats()
102 .expect("unknown supported formats")
103 .next()
104 .unwrap(),
105 );
106 encoder.set_bit_rate(decoder.bit_rate());
107 encoder.set_max_bit_rate(decoder.max_bit_rate());
108
109 encoder.set_time_base((1, decoder.rate() as i32));
110 output.set_time_base((1, decoder.rate() as i32));
111
112 let encoder = encoder.open_as(codec)?;
113 output.set_parameters(&encoder);
114
115 let filter = filter(filter_spec, &decoder, &encoder)?;
116
117 Ok(Transcoder {
118 stream: input.index(),
119 filter: filter,
120 decoder: decoder,
121 encoder: encoder,
122 })
123}pub fn default(number: i32) -> ChannelLayout
Trait Implementations§
Source§impl Binary for ChannelLayout
impl Binary for ChannelLayout
Source§impl BitAnd for ChannelLayout
impl BitAnd for ChannelLayout
Source§fn bitand(self, other: ChannelLayout) -> ChannelLayout
fn bitand(self, other: ChannelLayout) -> ChannelLayout
Returns the intersection between the two sets of flags.
Source§type Output = ChannelLayout
type Output = ChannelLayout
& operator.Source§impl BitAndAssign for ChannelLayout
impl BitAndAssign for ChannelLayout
Source§fn bitand_assign(&mut self, other: ChannelLayout)
fn bitand_assign(&mut self, other: ChannelLayout)
Disables all flags disabled in the set.
Source§impl BitOr for ChannelLayout
impl BitOr for ChannelLayout
Source§fn bitor(self, other: ChannelLayout) -> ChannelLayout
fn bitor(self, other: ChannelLayout) -> ChannelLayout
Returns the union of the two sets of flags.
Source§type Output = ChannelLayout
type Output = ChannelLayout
| operator.Source§impl BitOrAssign for ChannelLayout
impl BitOrAssign for ChannelLayout
Source§fn bitor_assign(&mut self, other: ChannelLayout)
fn bitor_assign(&mut self, other: ChannelLayout)
Adds the set of flags.
Source§impl BitXor for ChannelLayout
impl BitXor for ChannelLayout
Source§fn bitxor(self, other: ChannelLayout) -> ChannelLayout
fn bitxor(self, other: ChannelLayout) -> ChannelLayout
Returns the left flags, but with all the right flags toggled.
Source§type Output = ChannelLayout
type Output = ChannelLayout
^ operator.Source§impl BitXorAssign for ChannelLayout
impl BitXorAssign for ChannelLayout
Source§fn bitxor_assign(&mut self, other: ChannelLayout)
fn bitxor_assign(&mut self, other: ChannelLayout)
Toggles the set of flags.
Source§impl Clone for ChannelLayout
impl Clone for ChannelLayout
Source§fn clone(&self) -> ChannelLayout
fn clone(&self) -> ChannelLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelLayout
impl Debug for ChannelLayout
Source§impl Extend<ChannelLayout> for ChannelLayout
impl Extend<ChannelLayout> for ChannelLayout
Source§fn extend<T: IntoIterator<Item = ChannelLayout>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = ChannelLayout>>(&mut self, iterator: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<ChannelLayout> for ChannelLayout
impl FromIterator<ChannelLayout> for ChannelLayout
Source§fn from_iter<T: IntoIterator<Item = ChannelLayout>>(
iterator: T,
) -> ChannelLayout
fn from_iter<T: IntoIterator<Item = ChannelLayout>>( iterator: T, ) -> ChannelLayout
Source§impl Hash for ChannelLayout
impl Hash for ChannelLayout
Source§impl LowerHex for ChannelLayout
impl LowerHex for ChannelLayout
Source§impl Not for ChannelLayout
impl Not for ChannelLayout
Source§fn not(self) -> ChannelLayout
fn not(self) -> ChannelLayout
Returns the complement of this set of flags.
Source§type Output = ChannelLayout
type Output = ChannelLayout
! operator.Source§impl Octal for ChannelLayout
impl Octal for ChannelLayout
Source§impl Ord for ChannelLayout
impl Ord for ChannelLayout
Source§fn cmp(&self, other: &ChannelLayout) -> Ordering
fn cmp(&self, other: &ChannelLayout) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ChannelLayout
impl PartialEq for ChannelLayout
Source§impl PartialOrd for ChannelLayout
impl PartialOrd for ChannelLayout
Source§impl Sub for ChannelLayout
impl Sub for ChannelLayout
Source§fn sub(self, other: ChannelLayout) -> ChannelLayout
fn sub(self, other: ChannelLayout) -> ChannelLayout
Returns the set difference of the two sets of flags.
Source§type Output = ChannelLayout
type Output = ChannelLayout
- operator.Source§impl SubAssign for ChannelLayout
impl SubAssign for ChannelLayout
Source§fn sub_assign(&mut self, other: ChannelLayout)
fn sub_assign(&mut self, other: ChannelLayout)
Disables all flags enabled in the set.