From ba48243a5c81f183b203fcad21ec21b716e280a7 Mon Sep 17 00:00:00 2001 From: Austin Schey Date: Wed, 27 Nov 2024 17:24:29 -0800 Subject: [PATCH] add ffmpeg path --- libplatune/player/src/resolver/yt_dlp.rs | 11 +++++++++-- platuned/server/src/bin/platunectl.rs | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libplatune/player/src/resolver/yt_dlp.rs b/libplatune/player/src/resolver/yt_dlp.rs index ba5ca9fa..cc331d20 100644 --- a/libplatune/player/src/resolver/yt_dlp.rs +++ b/libplatune/player/src/resolver/yt_dlp.rs @@ -49,6 +49,12 @@ fn ytdl_exe() -> String { path } +fn ffmpeg_exe() -> String { + let path = env::var("FFMPEG_PATH").unwrap_or_else(|_| "ffmpeg".to_string()); + info!("Using ffmpeg path: {path:?}"); + path +} + pub(crate) struct YtDlpUrlResolver { rules: Vec, skip_flat_playlist: HashSet<&'static str>, @@ -158,6 +164,7 @@ impl RegistryEntry, CancellationToken)>> for YtDlpSource info!("ytdl video url: {}", input.source); info!("extracting video metadata - this may take a few seconds"); let output = YoutubeDl::new(input.source.clone()) + .youtube_dl_path(ytdl_exe()) .extract_audio(true) .run_async() .await?; @@ -212,8 +219,8 @@ impl RegistryEntry, CancellationToken)>> for YtDlpSource info!("source requires post-processing - converting to m4a using ffmpeg"); // yt-dlp can handle format conversion, but if we want to stream it directly from // stdout, we have to pipe the raw output to ffmpeg ourselves. - let builder = - CommandBuilder::new(cmd).pipe(FfmpegConvertAudioCommand::new(ffmpeg_format)); + let builder = CommandBuilder::new(cmd) + .pipe(FfmpegConvertAudioCommand::new(ffmpeg_format).ffmpeg_path(ffmpeg_exe())); ProcessStreamParams::new(builder)? }; let size = found_format.and_then(|f| f.filesize).map(|f| f as u64); diff --git a/platuned/server/src/bin/platunectl.rs b/platuned/server/src/bin/platunectl.rs index b3d8ef85..21689230 100644 --- a/platuned/server/src/bin/platunectl.rs +++ b/platuned/server/src/bin/platunectl.rs @@ -67,9 +67,13 @@ async fn run() -> Result<(), BoxedError> { .with_environment_variable_if_exists("PLATUNE_MTLS_CLIENT_CERT_PATH") .with_environment_variable_if_exists("PLATUNE_MTLS_CLIENT_KEY_PATH"); } - if let Ok(yt_dlp) = which("yt-dlp") { + if let Ok(yt_dlp_path) = which("yt-dlp") { manager_builder = - manager_builder.with_environment_variable("YT_DLP_PATH", yt_dlp.to_string_lossy()); + manager_builder.with_environment_variable("YT_DLP_PATH", yt_dlp_path.to_string_lossy()); + } + if let Ok(ffmpeg_path) = which("ffmpeg") { + manager_builder = + manager_builder.with_environment_variable("FFMPEG_PATH", ffmpeg_path.to_string_lossy()); } let manager = manager_builder.build().await.unwrap(); let logger_builder = LoggerBuilder::new(label.clone());