fix logic error
This commit is contained in:
parent
319a6385dd
commit
c9d7f0c2ad
|
@ -327,7 +327,7 @@ impl EventHandler for Handler {
|
|||
async fn main() {
|
||||
if !Path::new("vid_encoded/").is_dir() {
|
||||
println!("encode: encoding video...");
|
||||
fs::create_dir("vid").expect("encode: unable to modify files");
|
||||
if let Ok(_) = fs::create_dir("vid") {
|
||||
let mut command = process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-i",
|
||||
|
@ -372,17 +372,18 @@ async fn main() {
|
|||
fs::rename("aud.opus", "aud_encoded")
|
||||
.expect("encode: unable to move aud.opus to aud_encoded");
|
||||
|
||||
fs::create_dir("vid_encoded").expect("encode: unable to modify files");
|
||||
}
|
||||
let _ = fs::create_dir("vid_encoded");
|
||||
let dir = fs::read_dir("vid")
|
||||
.expect("encode: unable to read files")
|
||||
.count();
|
||||
let running = Arc::new(Mutex::new(0));
|
||||
println!("encode: encoding gifs...");
|
||||
for n in 0..((dir as f32 / (25.0 * 5.0)).ceil() as usize) {
|
||||
*running.lock().unwrap() += 1;
|
||||
{
|
||||
let running = running.clone();
|
||||
thread::spawn(move || {
|
||||
*running.lock().unwrap() += 1;
|
||||
let mut image = File::create(format!("vid_encoded/{n}"))
|
||||
.expect("encode: unable to create gif file");
|
||||
let mut encoder = Some(
|
||||
|
@ -438,6 +439,7 @@ async fn main() {
|
|||
while *running.lock().unwrap() >= 6 {
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
}
|
||||
while *running.lock().unwrap() != 0 {
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
|
|
Loading…
Reference in a new issue