use std::ffi::OsString;
use super::Command;
#[derive(Debug)]
pub struct FfmpegConvertAudioCommand(Command);
impl From<FfmpegConvertAudioCommand> for Command {
fn from(value: FfmpegConvertAudioCommand) -> Self {
value.0
}
}
impl FfmpegConvertAudioCommand {
pub fn new<S>(format: S) -> Self
where
S: AsRef<str>,
{
Self(Command::new("ffmpeg").args([
"-i",
"pipe:",
"-map",
"a",
"-f",
format.as_ref(),
"-loglevel",
"error",
"-",
]))
}
#[must_use]
pub fn ffmpeg_path<S>(mut self, path: S) -> Self
where
S: Into<OsString>,
{
self.0.program = path.into();
self
}
#[must_use]
pub fn arg<S>(mut self, arg: S) -> Self
where
S: Into<OsString>,
{
let insert_pos = self.0.args.len() - 1;
self.0 = self.0.insert_arg(insert_pos, arg);
self
}
#[must_use]
pub fn args<I, S>(mut self, args: I) -> Self
where
I: IntoIterator<Item = S>,
S: Into<OsString>,
{
for arg in args {
self = self.arg(arg);
}
self
}
}