Skip to content

fix: addresses slow frame emission due to time unit mismatch#2081

Merged
pedroSG94 merged 1 commit intopedroSG94:masterfrom
lcintron:fix/audio-source-sleeptime-mismatch
Apr 24, 2026
Merged

fix: addresses slow frame emission due to time unit mismatch#2081
pedroSG94 merged 1 commit intopedroSG94:masterfrom
lcintron:fix/audio-source-sleeptime-mismatch

Conversation

@lcintron
Copy link
Copy Markdown
Contributor

Description

SilenceAudioSource.create() computes sleepTime in microseconds (* 1_000_000L) but passes it to kotlinx.coroutines.delay(Long), which interprets its argument as milliseconds. As a result the silent PCM frames are emitted ~1000× slower than real time. When used with RTMP ingestors that require an audio track (e.g. YouTube), the muxer holds video waiting on audio-timestamp progression, producing multi-second to multi-minute A/V lag. Changing the multiplier from 1_000_000L to 1_000L makes the cadence match the frame's PCM duration.

Reproduction

RtmpStream with SilenceAudioSource, stream to YouTube — latency grows unboundedly. With the fix, latency matches a MicrophoneSource stream.

@pedroSG94 pedroSG94 merged commit dad7782 into pedroSG94:master Apr 24, 2026
1 check passed
@pedroSG94
Copy link
Copy Markdown
Owner

Hello,

Merged, Thank you for the PR

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.

2 participants