Skip to content

Commit e35fe33

Browse files
fix: enforce -t flag on export to prevent infinite loop with background music (#1289)
Co-authored-by: Akanksha Trehun <akankshatrehun@gmail.com>
1 parent c990769 commit e35fe33

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎src/lib/ffmpeg.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,12 @@ interface PositionCoords {
614614
if (shouldKeepAudio) args.push("-c:a", "aac", "-b:a", "128k");
615615
}
616616

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

625624
args.push(outputName);
626625
return args;

0 commit comments

Comments
 (0)