Skip to main content

ez_ffmpeg/core/frame_export/
audio_options.rs

1//! Public option enum for audio sample export: the channel layout to negotiate.
2
3/// The output channel layout for [`SampleExtractor`](super::SampleExtractor).
4///
5/// Selecting a value inserts a downmix into the resample stage
6/// (`aformat=channel_layouts=…`, backed by swr); leaving it unset preserves the
7/// source layout. ASR models such as whisper want [`Mono`](Channels::Mono).
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9#[non_exhaustive]
10pub enum Channels {
11    /// One channel. Stereo (and higher) sources are downmixed to mono.
12    Mono,
13    /// Two channels, interleaved as `L R`.
14    Stereo,
15}
16
17impl Channels {
18    /// The FFmpeg `channel_layouts` token this layout maps to.
19    pub(crate) fn layout_name(self) -> &'static str {
20        match self {
21            Channels::Mono => "mono",
22            Channels::Stereo => "stereo",
23        }
24    }
25}