You've already forked VptPassiveAdapter
静音音频流
This commit is contained in:
@@ -334,15 +334,26 @@ func QuickVideoCut(ctx context.Context, inputFile string, offset, length float64
|
||||
"-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",
|
||||
}
|
||||
if config.Config.AddSilentAudio {
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=44100",
|
||||
"-c:v", "copy",
|
||||
"-c:a", "aac",
|
||||
"-shortest",
|
||||
)
|
||||
} else {
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-c:v", "copy",
|
||||
"-an",
|
||||
)
|
||||
}
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-t", strconv.FormatFloat(length, 'f', 2, 64),
|
||||
"-fflags", "+genpts",
|
||||
"-f", "mp4",
|
||||
outputFile,
|
||||
}
|
||||
)
|
||||
return handleFfmpegProcess(subCtx, ffmpegCmd)
|
||||
}
|
||||
|
||||
@@ -378,15 +389,26 @@ func QuickConcatVideoCut(ctx context.Context, inputFiles []dto.File, offset, len
|
||||
"-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",
|
||||
}
|
||||
if config.Config.AddSilentAudio {
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=44100",
|
||||
"-c:v", "copy",
|
||||
"-c:a", "aac",
|
||||
"-shortest",
|
||||
)
|
||||
} else {
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-c:v", "copy",
|
||||
"-an",
|
||||
)
|
||||
}
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-t", strconv.FormatFloat(length, 'f', 2, 64),
|
||||
"-fflags", "+genpts",
|
||||
"-f", "mp4",
|
||||
outputFile,
|
||||
}
|
||||
)
|
||||
return handleFfmpegProcess(subCtx, ffmpegCmd)
|
||||
}
|
||||
|
||||
@@ -403,10 +425,13 @@ func SlowVideoCut(ctx context.Context, inputFiles []dto.File, offset, length flo
|
||||
ffmpegCmd = append(ffmpegCmd, "-i", file.Url)
|
||||
}
|
||||
|
||||
// 添加静音音频源作为额外输入
|
||||
ffmpegCmd = append(ffmpegCmd, "-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=44100")
|
||||
|
||||
inputCount := len(inputFiles)
|
||||
|
||||
if config.Config.AddSilentAudio {
|
||||
// 添加静音音频源作为额外输入
|
||||
ffmpegCmd = append(ffmpegCmd, "-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=44100")
|
||||
}
|
||||
|
||||
filterComplex := strings.Builder{}
|
||||
for i := 0; i < inputCount; i++ {
|
||||
filterComplex.WriteString(fmt.Sprintf("[%d:v]", i))
|
||||
@@ -416,9 +441,19 @@ func SlowVideoCut(ctx context.Context, inputFiles []dto.File, offset, length flo
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-filter_complex", filterComplex.String(),
|
||||
"-map", "[v]",
|
||||
"-map", fmt.Sprintf("%d:a", inputCount),
|
||||
"-c:a", "aac",
|
||||
"-shortest",
|
||||
)
|
||||
|
||||
if config.Config.AddSilentAudio {
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-map", fmt.Sprintf("%d:a", inputCount),
|
||||
"-c:a", "aac",
|
||||
"-shortest",
|
||||
)
|
||||
} else {
|
||||
ffmpegCmd = append(ffmpegCmd, "-an")
|
||||
}
|
||||
|
||||
ffmpegCmd = append(ffmpegCmd,
|
||||
"-preset:v", "fast",
|
||||
"-ss", strconv.FormatFloat(offset, 'f', 2, 64),
|
||||
"-t", strconv.FormatFloat(length, 'f', 2, 64),
|
||||
|
||||
Reference in New Issue
Block a user