capture ffmpeg stderr to logs, log capture framerate for debugging
This commit is contained in:
@@ -68,6 +68,7 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
|
||||
// user's chosen FPS. We must tell ffmpeg the actual rate so timestamps are
|
||||
// correct. The fps filter in the export pipeline handles the conversion.
|
||||
let capture_fps = detect_monitor_refresh_rate().max(setup.fps);
|
||||
tracing::info!("capture: ffmpeg framerate={}, size={}x{}", capture_fps, setup.width, setup.height);
|
||||
|
||||
let mut cmd = Command::new(&setup.ffmpeg_path);
|
||||
cmd.arg("-y")
|
||||
@@ -87,13 +88,25 @@ impl GraphicsCaptureApiHandler for CaptureHandler {
|
||||
.arg(&setup.output_path)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null());
|
||||
.stderr(Stdio::piped());
|
||||
|
||||
let mut child = cmd.spawn().map_err(|e| anyhow!("spawning ffmpeg: {e}"))?;
|
||||
let stdin = child
|
||||
.stdin
|
||||
.take()
|
||||
.ok_or_else(|| anyhow!("ffmpeg stdin not captured"))?;
|
||||
// Read stderr in background to capture ffmpeg errors
|
||||
let stderr = child.stderr.take();
|
||||
if let Some(serr) = stderr {
|
||||
let output_path = setup.output_path.clone();
|
||||
std::thread::spawn(move || {
|
||||
use std::io::{BufRead, BufReader};
|
||||
let reader = BufReader::new(serr);
|
||||
for line in reader.lines().map_while(Result::ok) {
|
||||
tracing::error!("ffmpeg: {line}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let frame_size = (setup.width as usize) * (setup.height as usize) * 4;
|
||||
Ok(Self {
|
||||
|
||||
Reference in New Issue
Block a user