Compare commits

..

No commits in common. "cursed" and "main" have entirely different histories.
cursed ... main

2 changed files with 0 additions and 30 deletions

View file

@ -48,7 +48,6 @@ fn write_raw(cmd_in: &mut ChildStdin, media: util::RawMedia) -> Result<(), Box<d
} }
pub fn read_raw_loop(mut cmd_in: ChildStdin, c_in: mpsc::Receiver<util::RawMedia>, c_err: mpsc::Sender<Box<dyn Error + Send + Sync>>) { pub fn read_raw_loop(mut cmd_in: ChildStdin, c_in: mpsc::Receiver<util::RawMedia>, c_err: mpsc::Sender<Box<dyn Error + Send + Sync>>) {
let mut i = 0;
loop { loop {
let media = match c_in.recv() { let media = match c_in.recv() {
Ok(x) => x, Ok(x) => x,
@ -57,22 +56,10 @@ pub fn read_raw_loop(mut cmd_in: ChildStdin, c_in: mpsc::Receiver<util::RawMedia
// needed, park to keep c_err // needed, park to keep c_err
// allocated // allocated
}; };
if i % 30 == 0 {
match media.media_type {
util::RawMediaType::YUV420P => {
let yuv = media.sample.clone();
thread::spawn(move || {
util::cursed_jpg(yuv);
});
},
_ => ()
}
}
match write_raw(&mut cmd_in, media) { match write_raw(&mut cmd_in, media) {
Ok(_) => (), Ok(_) => (),
Err(err) => {util::thread_freeze(c_err, err); return} // park thread, wait for main to Err(err) => {util::thread_freeze(c_err, err); return} // park thread, wait for main to
// exit // exit
} }
i += 1;
} }
} }

View file

@ -1,11 +1,9 @@
// general use structs, functions and errors go here // general use structs, functions and errors go here
use std::io::Write;
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
use std::thread; use std::thread;
use std::sync::mpsc; use std::sync::mpsc;
use std::process::{Command, Stdio};
// Data structs/enums // Data structs/enums
@ -238,18 +236,3 @@ pub fn thread_freeze(err_sender: mpsc::Sender<Box<dyn Error + Send + Sync>>, err
pub fn blank_vec(n: usize) -> Vec<u8> { pub fn blank_vec(n: usize) -> Vec<u8> {
return vec![0u8; n]; return vec![0u8; n];
} }
pub fn cursed_jpg(yuv: Vec<u8>) {
let mut cmd = Command::new("ffmpeg").args([
"-pix_fmt", "yuv420p",
"-f", "rawvideo",
"-s", "1280x720",
"-i", "-",
"-q:v", "10",
"out.jpg",
"-y", "-hide_banner", "-loglevel", "quiet",
]).stdin(Stdio::piped()).spawn().unwrap();
let mut stdin = cmd.stdin.take().unwrap();
stdin.write_all(yuv.as_slice());
drop(stdin);
}