From e589e6ee73bcdf25e1e73640792aa95ab92667f2 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Mon, 18 Feb 2019 00:39:27 -0500 Subject: encode/decode audio memes with ffmpeg to improve storage --- src/audio/ytdl.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/audio/ytdl.rs') diff --git a/src/audio/ytdl.rs b/src/audio/ytdl.rs index e88d8f8..8239683 100644 --- a/src/audio/ytdl.rs +++ b/src/audio/ytdl.rs @@ -45,6 +45,8 @@ pub(crate) trait CodecInfo { } pub(crate) struct Pcm {} + +#[allow(dead_code)] pub(crate) struct Opus {} impl CodecInfo for Pcm { @@ -66,12 +68,9 @@ impl CodecInfo for Opus { fn ffmpeg_opts() -> &'static[&'static str] { lazy_static! { static ref OPTS: Vec<&'static str> = vec! [ -// "-f", "s16le", + "-f", "opus", "-acodec", "libopus", - "-sample_fmt", "s16", - "-vbr", "off", -// "-b:a 96k", -// "-vn", + "-b:a 96k", ]; } @@ -129,6 +128,11 @@ pub(crate) fn ffmpeg_dl(uri: &str, start: Option, end: O .map(|s| s.to_owned()) .collect::>(); + if let Some(e) = end { + opts.push("-to".to_owned()); + opts.push(format!("{:02}:{:02}:{:02}", e.num_hours(), e.num_minutes() % 60, e.num_seconds() % 60)); + } + let codec_opts = T::ffmpeg_opts().into_iter().map(|&s| s.to_owned()).collect::>(); opts.extend(codec_opts); @@ -137,11 +141,6 @@ pub(crate) fn ffmpeg_dl(uri: &str, start: Option, end: O opts.push(format!("{}", limit)); } - if let Some(e) = end { - opts.push("-to".to_owned()); - opts.push(format!("{:02}:{:02}:{:02}", e.num_hours(), e.num_minutes() % 60, e.num_seconds() % 60)); - } - opts.push("-".to_owned()); debug!("ffmpeg -i \"{}\" {}", uri, opts.join(" ")); -- cgit v1.3.1