Overview
Compensates for AAC encoder delay (FDK AAC-LC priming) in Remotion renders by losslessly remuxing to shift audio back by the encoder delay.
Description
The AAC Encoder Delay module handles Remotion's libfdk_aac encoder which emits 2048 samples of priming ahead of the first real sample, causing ~42.7ms audio lag at 48kHz. This module remuxes losslessly, shifting audio back by the encoder delay so priming packets carry negative timestamps (edit list). Also provides `rendersRemotionAacTrack` to detect if a render has an AAC track.
Usage
- Render pipeline: Applied after Remotion render to fix audio sync drift in exported video.
Code Reference
Source Location
- Repository: OpenChatCut
- File: remotion/aac-encoder-delay.mjs
- Lines: 1-102
Signature
export async function compensateAacEncoderDelay(inputPath: string, outputPath: string): Promise<void>;
export function rendersRemotionAacTrack(filePath: string): Promise<boolean>;
Import
import { compensateAacEncoderDelay, rendersRemotionAacTrack } from './aac-encoder-delay.mjs';
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| inputPath |
string |
Yes |
Source video with AAC priming delay
|
| outputPath |
string |
Yes |
Target remuxed video path
|
Outputs
| Name |
Type |
Description
|
| compensateAacEncoderDelay() returns |
Promise<void> |
Losslessly remuxed video with corrected audio sync
|
| rendersRemotionAacTrack() returns |
Promise<boolean> |
Whether file has AAC track
|
Usage Examples
Compensating AAC Delay
import { compensateAacEncoderDelay } from './aac-encoder-delay.mjs';
await compensateAacEncoderDelay('/tmp/render.mp4', '/tmp/render-fixed.mp4');
// Audio sync corrected for AAC priming delay
Related Pages
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.