diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-16 00:09:35 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-16 00:09:35 +0200 |
commit | 39dee6820db4581fa41cfac8bcfdd399a96f5319 (patch) | |
tree | c605156a6757e5623fae36635722758947e0db65 /transcoder | |
parent | 50dc0e7bea02d7fc5b38edb7f943e19bd8c0285b (diff) | |
download | jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.bz2 jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.zst |
transcode impl but broken
Diffstat (limited to 'transcoder')
-rw-r--r-- | transcoder/src/fragment.rs | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/transcoder/src/fragment.rs b/transcoder/src/fragment.rs index 1d06e9a..8692423 100644 --- a/transcoder/src/fragment.rs +++ b/transcoder/src/fragment.rs @@ -7,7 +7,7 @@ use crate::LOCAL_VIDEO_TRANSCODING_TASKS; use jellybase::{ cache::{async_cache_file, CachePath}, - common::stream::{StreamContainer, StreamFormatInfo, TrackKind}, + common::stream::{StreamFormatInfo, TrackKind}, CONF, }; use log::{debug, info}; @@ -24,7 +24,6 @@ pub async fn transcode( key: &str, kind: TrackKind, format: &StreamFormatInfo, - container: StreamContainer, input: impl FnOnce(ChildStdin), ) -> anyhow::Result<CachePath> { async_cache_file( @@ -34,8 +33,8 @@ pub async fn transcode( debug!("transcoding fragment with {format:?}"); let template = match format.codec.as_str() { - "V_AVC" => CONF.encoders.avc.as_ref(), - "V_HEVC" => CONF.encoders.hevc.as_ref(), + "V_MPEG4/ISO/AVC" => CONF.encoders.avc.as_ref(), + "V_MPEGH/ISO/HEVC" => CONF.encoders.hevc.as_ref(), "V_VP8" => CONF.encoders.vp8.as_ref(), "V_VP9" => CONF.encoders.vp9.as_ref(), "V_AV1" => CONF.encoders.av1.as_ref(), @@ -57,35 +56,27 @@ pub async fn transcode( }; let fallback_encoder = match format.codec.as_str() { "A_OPUS" => "libopus", - _ => unreachable!(), + "V_MPEG4/ISO/AVC" => "libx264", + "V_MPEGH/ISO/HEVC" => "libx265", + _ => "", }; let args = template .replace("%i", "-f matroska -i pipe:0") - .replace("%o", "-f %C pipe:1") + .replace("%o", "-f matroska pipe:1") .replace("%f", &filter) .replace("%e", "-c:%t %c -b:%t %r") .replace("%t", typechar) .replace("%c", fallback_encoder) - .replace("%r", &(format.bitrate as i64).to_string()) - .replace("%C", &container.to_string()); + .replace("%r", &(format.bitrate as i64).to_string()); info!("encoding with {:?}", args); - let container = match container { - StreamContainer::WebM => "webm", - StreamContainer::Matroska => "matroska", - StreamContainer::WebVTT => "vtt", - StreamContainer::MPEG4 => "mp4", - StreamContainer::JVTT => unreachable!(), - }; - - let mut proc = Command::new("ffmpeg") + let mut args = args.split(" "); + let mut proc = Command::new(args.next().unwrap()) .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .args(["-f", "matroska", "-i", "pipe:0"]) - .args(args.split(" ")) - .args(["-f", container, "pipe:1"]) + .args(args) .spawn()?; let stdin = proc.stdin.take().unwrap(); |