Skip to content

fix(audio): prevent tail truncation during video export - #2

Open
iMyth wants to merge 2 commits into
mainfrom
fix/audio-tail-cutoff-on-export
Open

iMyth wants to merge 2 commits into
mainfrom
fix/audio-tail-cutoff-on-export

Conversation

@iMyth

@iMyth iMyth commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Problem

Audio gets cut off at the end when exporting video, both with and without sleep mode enabled.

Root Cause

  1. loudnorm filter missing linear=true — default mode uses an internal lookahead buffer that drops trailing samples at EOF
  2. -shortest flag truncates to the shorter stream — when video is slightly shorter than audio (due to frame duration rounding), the audio tail gets clipped

Fix

  • Add linear=true to loudnorm in both sleep mode and normal mode, ensuring fixed gain is applied without altering duration
  • Replace -shortest in merge_video_with_audio with -t <audio_duration> (probed via ffprobe), making audio the authoritative length source
  • Add probe_duration_secs helper function

Scope

  • Single section export
  • Multi-section merge
  • Sleep mode audio processing

iMyth added 2 commits August 19, 2026 10:15
Two issues caused audio to be cut off at the end:

1. loudnorm filter without linear=true uses internal buffering that
   can drop trailing samples. Adding linear=true makes it apply a
   fixed gain without altering duration.

2. -shortest flag in merge_video_with_audio truncates the output to
   the shorter stream. When video is slightly shorter than audio (due
   to frame duration rounding), audio gets clipped. Replaced with -t
   using the actual audio duration from ffprobe, making audio the
   authoritative length source.

Fixes both normal mode and sleep mode export paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant