Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/lib/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,12 @@ interface PositionCoords {
if (shouldKeepAudio) args.push("-c:a", "aac", "-b:a", "128k");
}

// Add explicit output duration when speed != 1 to prevent slight duration
// overshoot caused by encoder/filter pipeline frame flush at stream end.
if (recipe.speed !== 1) {
const sourceDuration = (recipe.trimEnd ?? videoDuration) - recipe.trimStart;
const outputDuration = sourceDuration / recipe.speed;
args.push("-t", outputDuration.toFixed(6));
}
// Add explicit output duration to prevent slight duration overshoot
// caused by encoder/filter pipeline frame flush at stream end,
// and to prevent infinite loops when adding looped audio to silent videos.
const sourceDuration = (recipe.trimEnd ?? videoDuration) - recipe.trimStart;
const outputDuration = sourceDuration / recipe.speed;
args.push("-t", outputDuration.toFixed(6));

args.push(outputName);
return args;
Expand Down