Fix snippet duration accuracy with stream copy mode

Improves snippet timing accuracy for Default Format mode by:
- Adding -accurate_seek flag for precise keyframe seeking
- Changing from -t (duration) to -to (end time) for better accuracy
- Adding -avoid_negative_ts make_zero to fix timestamp issues with problematic containers like WMV

This should resolve issues where snippets were 1:20 or 0:21 instead of the configured length (e.g., 10s). Stream copy still uses keyframe-level precision but should now be much closer to target duration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Stu Leak 2025-12-16 23:24:29 -05:00
parent 727bbd9097
commit 1a04cab1d6

10
main.go
View File

@ -3367,15 +3367,19 @@ func (s *appState) executeSnippetJob(ctx context.Context, job *queue.Job, progre
if useSourceFormat {
// Source format mode: Use stream copy for clean extraction
// Note: This uses keyframe cutting, so duration may not be frame-perfect
// Calculate end time for more accurate cutting
endTime := center + float64(snippetLength)
args = []string{
"-y",
"-hide_banner",
"-loglevel", "error",
"-accurate_seek", // Seek accurately to keyframes
"-ss", start,
"-i", inputPath,
"-t", fmt.Sprintf("%d", snippetLength),
"-c", "copy", // Stream copy - no re-encoding
"-map", "0", // Include all streams
"-to", fmt.Sprintf("%.2f", endTime), // Use -to instead of -t for better accuracy
"-c", "copy", // Stream copy - no re-encoding
"-map", "0", // Include all streams
"-avoid_negative_ts", "make_zero", // Fix timestamp issues
outputPath,
}
} else {