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 /remuxer/src/mpeg4.rs | |
parent | 50dc0e7bea02d7fc5b38edb7f943e19bd8c0285b (diff) | |
download | jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.bz2 jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.zst |
transcode impl but broken
Diffstat (limited to 'remuxer/src/mpeg4.rs')
-rw-r--r-- | remuxer/src/mpeg4.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/remuxer/src/mpeg4.rs b/remuxer/src/mpeg4.rs new file mode 100644 index 0000000..9e59514 --- /dev/null +++ b/remuxer/src/mpeg4.rs @@ -0,0 +1,34 @@ +/* + This file is part of jellything (https://codeberg.org/metamuffin/jellything) + which is licensed under the GNU Affero General Public License (version 3); see /COPYING. + Copyright (C) 2025 metamuffin <metamuffin.org> +*/ +use anyhow::Result; +use std::{ + fs::{remove_file, File}, + io::{copy, Read, Write}, + process::{Command, Stdio}, + random::random, +}; + +pub fn matroska_to_mpeg4( + mut input: impl Read + Send + 'static, + mut output: impl Write, +) -> Result<()> { + let path = format!("/tmp/jellything-tc-hack-{:016x}", random::<u64>()); + let args = format!("-f matroska -i pipe:0 -c copy -map 0 -f mp4 {path}"); + let mut child = Command::new("ffmpeg") + .args(args.split(" ")) + .stdin(Stdio::piped()) + .stderr(Stdio::inherit()) + .spawn()?; + + let mut stdin = child.stdin.take().unwrap(); + copy(&mut input, &mut stdin)?; + drop(stdin); + child.wait()?.exit_ok()?; + copy(&mut File::open(&path)?, &mut output)?; + remove_file(path)?; + + Ok(()) +} |