From 9fbc791e57878dba2f9ee02e971b06eab1fb3553 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Tue, 16 Dec 2025 23:36:04 -0500 Subject: [PATCH] Fix snippet duration: revert to simple, reliable FFmpeg approach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts the problematic -accurate_seek and -to flags that caused wildly incorrect durations (9:40 instead of 10s). Returns to the standard, reliable FFmpeg pattern for stream copy: ffmpeg -ss START -i input -t DURATION -c copy output This places -ss before -i for fast keyframe seeking and uses -t for duration (not -to which is an absolute timestamp causing incorrect extraction). Should now correctly extract the configured snippet length centered on video midpoint. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- main.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 97c94db..6f497bc 100644 --- a/main.go +++ b/main.go @@ -3366,20 +3366,17 @@ 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) + // Simple, reliable approach: -ss before -i for fast seek, -t for duration args = []string{ - "-y", + "-ss", start, // Seek to start position (before -i for fast keyframe seek) + "-i", inputPath, + "-t", fmt.Sprintf("%d", snippetLength), // Duration to extract + "-c", "copy", // Stream copy - no re-encoding + "-map", "0", // Include all streams + "-avoid_negative_ts", "make_zero", // Fix timestamp issues + "-y", // Overwrite output "-hide_banner", "-loglevel", "error", - "-accurate_seek", // Seek accurately to keyframes - "-ss", start, - "-i", inputPath, - "-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 {