{"record":{"id":"6e9a228ade9ec2df","repo":"tonhowtf/omniget","slug":"ffmpeg-screen-record","errorCode":null,"errorMessage":"ffmpeg: {}","messagePattern":"ffmpeg: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/screen_record.rs","lineNumber":364,"sourceCode":"        PathBuf::from(opts.output_dir.trim())\n    };\n    std::fs::create_dir_all(&dir)?;\n    let ring = opts.replay_seconds > 0;\n    let (target, ring_dir, output) = if ring {\n        let r = super::temp_dir().join(format!(\"replay-{}\", uuid::Uuid::new_v4()));\n        std::fs::create_dir_all(&r)?;\n        (r.clone(), Some(r), None)\n    } else {\n        let out = dir.join(format!(\"Gravacao {}.mp4\", stamp()));\n        (out.clone(), None, Some(out))\n    };\n    let args = build_args(&opts, &target, ring);\n    let mut cmd = crate::core::process::command(&ffmpeg);\n    cmd.args(&args)\n        .stdin(std::process::Stdio::piped())\n        .stdout(std::process::Stdio::null())\n        .stderr(std::process::Stdio::piped());\n    let child = cmd.spawn().map_err(|e| anyhow!(\"ffmpeg: {}\", e))?;\n    *ERROR.lock().unwrap_or_else(|e| e.into_inner()) = None;\n    *SESSION.lock().unwrap_or_else(|e| e.into_inner()) = Some(Session {\n        child,\n        started: Instant::now(),\n        output,\n        ring_dir,\n        opts,\n    });\n    // Se o ffmpeg morrer nos primeiros instantes (permissão, dispositivo), avisa.\n    tokio::time::sleep(std::time::Duration::from_millis(900)).await;\n    let died = {\n        let mut s = SESSION.lock().unwrap_or_else(|e| e.into_inner());\n        match s.as_mut() {\n            Some(sess) => match sess.child.try_wait() {\n                Ok(Some(_)) => Some(sess.child.stderr.take()),\n                _ => None,\n            },\n            None => None,","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/screen_record.rs#L346-L382","documentation":"start() spawns the ffmpeg child process via crate::core::process::command(). If the OS-level spawn fails (io::Error), it is wrapped as \"ffmpeg: {io error}\". This happens before any recording state is stored.","triggerScenarios":"The ffmpeg binary path is invalid or not executable, the binary was removed after ensure_ffmpeg() earlier, resource limits (fork/ENOMEM), or an invalid working directory for the child.","commonSituations":"ffmpeg not installed and ensure_ffmpeg skipped or failed silently; a broken PATH; permission bits stripped from the binary; disk-full or fd-limit conditions.","solutions":["Ensure ensure_ffmpeg().await? is awaited successfully before start() and that ffmpeg exists at the returned path","Run `ffmpeg -version` manually with the same environment/PATH to reproduce the spawn failure","Check file permissions on the ffmpeg binary (chmod +x)","Check system resource limits (ulimit, disk space) if the binary exists"],"exampleFix":"// before\nstart(opts).await?; // assumes ffmpeg is present\n// after\nlet ffmpeg = ensure_ffmpeg().await?; // surface install errors early\nprintln!(\"using ffmpeg at {}\", ffmpeg);\nstart(opts).await?;","handlingStrategy":"try-catch","validationCode":"let ffmpeg = ensure_ffmpeg().await?;\nif !std::path::Path::new(&ffmpeg).exists() {\n    return Err(anyhow!(\"ffmpeg missing at {}\", ffmpeg));\n}","typeGuard":null,"tryCatchPattern":"match screen_record::start(opts).await {\n    Err(e) if e.to_string().starts_with(\"ffmpeg:\") => {\n        eprintln!(\"failed to spawn ffmpeg: {} — reinstall via ensure_ffmpeg()\", e);\n        ensure_ffmpeg().await?;\n        screen_record::start(opts).await\n    }\n    other => other,\n}","preventionTips":["Always call ensure_ffmpeg() (and check the returned path exists) before start()","Keep PATH intact when launching from GUI environments","Verify the binary is executable after any update/reinstall"],"tags":["ffmpeg","process-spawn","screen-recording","dependency"],"backgroundTag":"command-not-found","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}