Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
couleurm committed Feb 21, 2024
1 parent ea4d384 commit b1abb79
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 41 deletions.
65 changes: 32 additions & 33 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cmd::SmCommand;
use regex::Regex;
use std::process::{ChildStderr, Command, Stdio};

use crate::{verb};
use crate::verb;
use std::env;

//use crate::ffpb::ffmpeg;
Expand Down Expand Up @@ -147,42 +147,41 @@ pub fn _vpipe_render2(commands: Vec<SmCommand>) {
);
}

let mut vs = Command::new(cmd.vs_path)
.args(cmd.vs_args)
.stdout(Stdio::piped())
.spawn()
.expect("Failed in spawning FFmpeg child");

let pipe = vs.stdout.take().expect("Failed piping out of VSPipe");

let mut ffmpeg = Command::new(cmd.ff_path)
.args(cmd.ff_args)
.stdin(pipe)
.stdout(if previewing {
Stdio::piped()
} else {
Stdio::inherit()
})
.spawn()
.expect("Failed in spawning FFmpeg child");

if previewing {
let ffplay_pipe = ffmpeg.stdout.take().expect("Failed piping out of FFmpeg");
let ffplay = Command::new(cmd.ffplay_path.unwrap())
.args(cmd.ffplay_args.unwrap())
.stdin(ffplay_pipe)
.spawn()
.expect("Failed in spawning ffplay child");
ffplay.wait_with_output().unwrap();
}
let mut vs = Command::new(cmd.vs_path)
.args(cmd.vs_args)
.stdout(Stdio::piped())
.spawn()
.expect("Failed in spawning FFmpeg child");

vs.wait_with_output().unwrap();
ffmpeg.wait_with_output().unwrap();
let pipe = vs.stdout.take().expect("Failed piping out of VSPipe");

let mut ffmpeg = Command::new(cmd.ff_path)
.args(cmd.ff_args)
.stdin(pipe)
.stdout(if previewing {
Stdio::piped()
} else {
Stdio::inherit()
})
.spawn()
.expect("Failed in spawning FFmpeg child");

if previewing {
let ffplay_pipe = ffmpeg.stdout.take().expect("Failed piping out of FFmpeg");
let ffplay = Command::new(cmd.ffplay_path.unwrap())
.args(cmd.ffplay_args.unwrap())
.stdin(ffplay_pipe)
.spawn()
.expect("Failed in spawning ffplay child");
ffplay.wait_with_output().unwrap();
}

vs.wait_with_output().unwrap();
ffmpeg.wait_with_output().unwrap();
}
}

fn _old_ffpb(cmd: SmCommand, previewing: bool){
fn _old_ffpb(cmd: SmCommand, previewing: bool) {
let mut vs = Command::new(cmd.vs_path)
.args(cmd.vs_args)
.stdout(Stdio::piped())
Expand Down Expand Up @@ -219,4 +218,4 @@ fn _old_ffpb(cmd: SmCommand, previewing: bool){
// .expect("Failed in spawning ffplay child");
// ffplay.wait_with_output().unwrap();
}
}
}
19 changes: 11 additions & 8 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,13 @@ pub fn resolve_outpath(
value = format!("{}..", &value[..15]);
}
// replace filename forbidden characters with underscores
value = value.chars().map(|c| match c {
'<' | '>' | ':' | '"' | '/' | '\\' | '|' | '?' | '*' => '_',
_ => c,
}).collect();
value = value
.chars()
.map(|c| match c {
'<' | '>' | ':' | '"' | '/' | '\\' | '|' | '?' | '*' => '_',
_ => c,
})
.collect();
// skip this var if value is empty
if value.trim().is_empty() {
continue;
Expand Down Expand Up @@ -209,23 +212,23 @@ pub fn resolve_input(args: &mut Arguments, recipe: &Recipe) -> Vec<Payload> {
let mut videos: Vec<(PathBuf, FfProbe, Option<Vec<Timecodes>>)> = vec![];

if which("ffmpeg").is_err() {
let term = if cfg!(target_os = "windows"){
let term = if cfg!(target_os = "windows") {
"ffmpeg.exe"
} else {
"ffmpeg"
};
panic!("{term} is not installed/in PATH, ensure FFmpeg is installed.");
}
if which("ffprobe").is_err() {
let term = if cfg!(target_os = "windows"){
let term = if cfg!(target_os = "windows") {
"ffprobe.exe"
} else {
"ffprobe"
};
panic!("{term} is not installed/in PATH, ensure FFmpeg is installed.");
}
if recipe.get_bool("preview window", "enabled") && which("ffplay").is_err() {
let term = if cfg!(target_os = "windows"){
let term = if cfg!(target_os = "windows") {
"ffplay.exe"
} else {
"ffplay"
Expand Down Expand Up @@ -319,4 +322,4 @@ pub fn resolve_input(args: &mut Arguments, recipe: &Recipe) -> Vec<Payload> {
}

payloads
}
}

0 comments on commit b1abb79

Please sign in to comment.