diff --git a/main.go b/main.go index c790249..97c94db 100644 --- a/main.go +++ b/main.go @@ -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 {