Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xsline OpenChatCut AAC Encoder Delay

From Leeroopedia
Knowledge Sources
Domains Audio, Rendering
Last Updated 2026-10-22 14:00 GMT

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.
Principle
Implementation
Heuristic
Environment