File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,6 +79,8 @@ export interface MuxVideoWithAudioOptions extends Partial<
7979 audioCodec ?: "aac" ;
8080 /** Preserve a priming edit list known to have been created by AAC re-encoding. */
8181 preserveAudioPrimingEditList ?: boolean ;
82+ /** Hard cap copied audio to the already-encoded video's exact duration. */
83+ durationSeconds ?: number ;
8284}
8385
8486async function shouldCopyAacSidecar (
@@ -706,6 +708,9 @@ export async function muxVideoWithAudio(
706708 // output container metadata. `-c:v copy` is retained; no re-encode.
707709 args . push ( "-r" , fpsToFfmpegArg ( fps ) ) ;
708710 }
711+ if ( config ?. durationSeconds !== undefined ) {
712+ args . push ( "-t" , String ( config . durationSeconds ) ) ;
713+ }
709714 args . push ( "-y" , outputPath ) ;
710715
711716 const processTimeout = config ?. ffmpegProcessTimeout ?? DEFAULT_CONFIG . ffmpegProcessTimeout ;
Original file line number Diff line number Diff line change @@ -323,7 +323,11 @@ export async function assemble(
323323 audioForMux ,
324324 muxOutputPath ,
325325 abortSignal ,
326- { audioCodec : "aac" , preserveAudioPrimingEditList } ,
326+ {
327+ audioCodec : "aac" ,
328+ preserveAudioPrimingEditList,
329+ durationSeconds : padTrimResult . targetDurationSeconds ,
330+ } ,
327331 { num : plan . dimensions . fpsNum , den : plan . dimensions . fpsDen } ,
328332 ) ;
329333 if ( ! muxResult . success ) {
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ export async function runAssembleStage(input: AssembleStageInput): Promise<Assem
7979 {
8080 audioCodec : "aac" ,
8181 preserveAudioPrimingEditList : normalizeResult . operation === "trim" ,
82+ durationSeconds : normalizeResult . targetDurationSeconds ,
8283 } ,
8384 job . config . fps ,
8485 ) ;
You can’t perform that action at this time.
0 commit comments