From 181a6b5368080e0c99d7530da7c7eafa29688623 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 6 Mar 2026 17:31:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(video):=20=E4=BF=AE=E5=A4=8D=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=89=AA=E8=BE=91=E6=97=B6=E9=97=B4=E6=88=B3=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整 -ss 参数位置以确保正确的剪辑起始时间 - 移除多余的 -reset_timestamps 参数避免时间戳重置问题 - 确保 -fflags +genpts 参数在正确的命令序列中设置 - 修复拼接操作中的时间偏移参数顺序 - 优化视频处理流程中的时间戳生成逻辑 --- util/ffmpeg.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/ffmpeg.go b/util/ffmpeg.go index e2b311a..629b4dd 100644 --- a/util/ffmpeg.go +++ b/util/ffmpeg.go @@ -331,13 +331,12 @@ func QuickVideoCut(ctx context.Context, inputFile string, offset, length float64 FfmpegExec, "-hide_banner", "-y", + "-ss", strconv.FormatFloat(offset, 'f', 2, 64), "-i", inputFile, "-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=44100", "-c:v", "copy", "-c:a", "aac", "-shortest", - "-reset_timestamps", "1", - "-ss", strconv.FormatFloat(offset, 'f', 2, 64), "-t", strconv.FormatFloat(length, 'f', 2, 64), "-fflags", "+genpts", "-f", "mp4", @@ -376,13 +375,14 @@ func QuickConcatVideoCut(ctx context.Context, inputFiles []dto.File, offset, len "-y", "-f", "concat", "-safe", "0", + "-ss", strconv.FormatFloat(offset, 'f', 2, 64), "-i", tmpFile, "-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=44100", "-c:v", "copy", "-c:a", "aac", "-shortest", - "-ss", strconv.FormatFloat(offset, 'f', 2, 64), "-t", strconv.FormatFloat(length, 'f', 2, 64), + "-fflags", "+genpts", "-f", "mp4", outputFile, }