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 | |
parent | 50dc0e7bea02d7fc5b38edb7f943e19bd8c0285b (diff) | |
download | jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.bz2 jellything-39dee6820db4581fa41cfac8bcfdd399a96f5319.tar.zst |
transcode impl but broken
Diffstat (limited to 'remuxer/src')
-rw-r--r-- | remuxer/src/lib.rs | 3 | ||||
-rw-r--r-- | remuxer/src/mpeg4.rs | 34 |
2 files changed, 37 insertions, 0 deletions
diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs index 9ddf7c1..c20197f 100644 --- a/remuxer/src/lib.rs +++ b/remuxer/src/lib.rs @@ -3,9 +3,11 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ +#![feature(random, exit_status_error)] pub mod extract; pub mod fragment; pub mod metadata; +pub mod mpeg4; pub mod remux; pub mod seek_index; pub mod segment_extractor; @@ -14,6 +16,7 @@ pub mod trim_writer; use ebml_struct::matroska::TrackEntry; pub use fragment::write_fragment_into; use jellymatroska::{Master, MatroskaTag}; +pub use mpeg4::matroska_to_mpeg4; pub use remux::remux_stream_into; pub fn ebml_header(webm: bool) -> MatroskaTag { 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(()) +} |