stream_download/process/
ffmpeg.rs1use std::ffi::OsString;
2
3use super::Command;
4
5#[derive(Debug)]
9pub struct FfmpegConvertAudioCommand(Command);
10
11impl From<FfmpegConvertAudioCommand> for Command {
12 fn from(value: FfmpegConvertAudioCommand) -> Self {
13 value.0
14 }
15}
16
17impl FfmpegConvertAudioCommand {
18 pub fn new<S>(format: S) -> Self
20 where
21 S: AsRef<str>,
22 {
23 Self(Command::new("ffmpeg").args([
28 "-i",
29 "pipe:",
30 "-map",
31 "a",
32 "-f",
33 format.as_ref(),
34 "-loglevel",
35 "error",
36 "-",
37 ]))
38 }
39
40 #[must_use]
42 pub fn ffmpeg_path<S>(mut self, path: S) -> Self
43 where
44 S: Into<OsString>,
45 {
46 self.0.program = path.into();
47 self
48 }
49
50 #[must_use]
52 pub fn arg<S>(mut self, arg: S) -> Self
53 where
54 S: Into<OsString>,
55 {
56 let insert_pos = self.0.args.len() - 1;
58 self.0 = self.0.insert_arg(insert_pos, arg);
59 self
60 }
61
62 #[must_use]
64 pub fn args<I, S>(mut self, args: I) -> Self
65 where
66 I: IntoIterator<Item = S>,
67 S: Into<OsString>,
68 {
69 for arg in args {
70 self = self.arg(arg);
71 }
72 self
73 }
74}