{"record":{"id":"a39898029fa5d596","repo":"tonhowtf/omniget","slug":"ffmpeg-encerrou-na-largada-permissao-de-gravacao-de-tela","errorCode":null,"errorMessage":"ffmpeg encerrou na largada (permissao de Gravacao de Tela?)","messagePattern":"ffmpeg encerrou na largada \\(permissao de Gravacao de Tela\\?\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/screen_record.rs","lineNumber":398,"sourceCode":"                _ => None,\n            },\n            None => None,\n        }\n    };\n    if let Some(stderr) = died {\n        let mut msg = String::new();\n        if let Some(mut e) = stderr {\n            use tokio::io::AsyncReadExt;\n            let _ = e.read_to_string(&mut msg).await;\n        }\n        *SESSION.lock().unwrap_or_else(|e| e.into_inner()) = None;\n        let msg = if msg.trim().is_empty() {\n            \"ffmpeg encerrou na largada (permissao de Gravacao de Tela?)\".to_string()\n        } else {\n            msg.trim().to_string()\n        };\n        *ERROR.lock().unwrap_or_else(|e| e.into_inner()) = Some(msg.clone());\n        return Err(anyhow!(msg));\n    }\n    Ok(state())\n}\n\nasync fn stop_child(mut child: tokio::process::Child) {\n    if let Some(mut stdin) = child.stdin.take() {\n        use tokio::io::AsyncWriteExt;\n        let _ = stdin.write_all(b\"q\\n\").await;\n        let _ = stdin.flush().await;\n    }\n    if tokio::time::timeout(std::time::Duration::from_secs(10), child.wait())\n        .await\n        .is_err()\n    {\n        let _ = child.kill().await;\n    }\n}\n","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/screen_record.rs#L380-L416","documentation":"After spawning ffmpeg, start() reads early stderr; if ffmpeg exits immediately at startup, it raises this message (or the actual stderr text if non-empty). The parenthetical hint points at the most common cause: missing macOS Screen Recording permission.","triggerScenarios":"ffmpeg exits with non-zero status right after spawn — invalid capture args for the platform, missing Screen Recording permission on macOS, device/permission errors on Linux (no /dev/video, x11grab auth failure), or an unsupported pixel format.","commonSituations":"macOS TCC permission not granted to the host app in System Settings > Privacy > Screen Recording; wrong DISPLAY/xauth in headless or SSH sessions; invalid output codec/arguments rejected instantly by ffmpeg.","solutions":["On macOS: grant Screen Recording permission to the app in System Settings > Privacy & Security > Screen Recording, then restart the app","Inspect the ERROR global / captured stderr for the precise ffmpeg message when it is not empty","Verify capture arguments match the platform and input device (display number, framerate, audio device)","Run the exact ffmpeg command line manually to reproduce and debug the failure"],"exampleFix":"// before\nlet state = start(opts).await?; // fails: ffmpeg exited immediately\n// after\nmatch start(opts).await {\n    Ok(s) => Ok(s),\n    Err(e) if e.to_string().contains(\"encerrou na largada\") => {\n        eprintln!(\"check Screen Recording permission / capture args: {}\", get_error().await?);\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","handlingStrategy":"try-catch","validationCode":"// macOS: check TCC screen-recording permission before starting\n#[cfg(target_os = \"macos\")]\nif !screen_capture_permission_granted() {\n    eprintln!(\"grant Screen Recording permission in System Settings, then restart the app\");\n}","typeGuard":null,"tryCatchPattern":"match screen_record::start(opts).await {\n    Err(e) if e.to_string().contains(\"encerrou na largada\") => {\n        eprintln!(\"ffmpeg died at startup — check Screen Recording permission and capture args\");\n        // surface the stored detailed error\n        if let Some(detail) = *screen_record::ERROR.lock().unwrap() { eprintln!(\"detail: {}\", detail); }\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["On macOS, grant Screen Recording permission to the host app before first use and restart it","Test the exact ffmpeg command manually to validate capture arguments","Confirm DISPLAY/xauth validity in headless or SSH sessions"],"tags":["ffmpeg","permissions","macos","screen-recording"],"backgroundTag":"permission-denied","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"}