fix pts_scale: use capture fps (not declared 120) for timestamp correction
This commit is contained in:
@@ -327,7 +327,7 @@ impl CaptureSession {
|
||||
}
|
||||
|
||||
/// Re-encode the intermediate file with correct timestamps.
|
||||
/// The capture declares -framerate 120 but delivers at a lower rate.
|
||||
/// The capture declares -framerate N and applies fps=M filter.
|
||||
/// This scales PTS to match real-time duration.
|
||||
pub fn fix_intermediate_fps(
|
||||
ffmpeg: &std::path::Path,
|
||||
@@ -335,6 +335,7 @@ pub fn fix_intermediate_fps(
|
||||
output: &std::path::Path,
|
||||
elapsed_secs: f64,
|
||||
frame_count: u64,
|
||||
capture_fps: u32,
|
||||
) -> Result<()> {
|
||||
use std::process::Command;
|
||||
|
||||
@@ -344,11 +345,10 @@ pub fn fix_intermediate_fps(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let declared_fps = 120.0f64;
|
||||
let actual_fps = frame_count as f64 / elapsed_secs;
|
||||
let pts_scale = declared_fps / actual_fps;
|
||||
let pts_scale = capture_fps as f64 / actual_fps;
|
||||
tracing::info!(
|
||||
"capture fix: {frame_count} frames in {elapsed_secs:.1}s = {actual_fps:.1}fps, pts_scale={pts_scale:.2}"
|
||||
"capture fix: {frame_count} frames in {elapsed_secs:.1}s = {actual_fps:.1}fps (declared {capture_fps}), pts_scale={pts_scale:.2}"
|
||||
);
|
||||
|
||||
// Re-encode with scaled PTS to fix timing
|
||||
|
||||
Reference in New Issue
Block a user