Skip to content

Fix audio desync when seek point doesn't match an audio frame start - #24734

Closed
kepstin wants to merge 1 commit into
bigbluebutton:v3.0.x-releasefrom
kepstin:audio-gap-sync
Closed

kepstin wants to merge 1 commit into
bigbluebutton:v3.0.x-releasefrom
kepstin:audio-gap-sync

Conversation

@kepstin

@kepstin kepstin commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

By default, the aresample filter assumes that the timestamp of the first audio frame it sees is the start of the audio, and the output timestamps will be offset so that point becomes 0 in the output. If the seek point happened to be in a gap where there were no audio frames, this will cause the audio to be earlier than expected (desynced).

Setting the first_pts=0 option causes the filter to trim or pad the start of the output audio to preserve the correct offset relative to 0, where 0 is the seek point (set with the -ss option).

By default, the `aresample` filter assumes that the timestamp of the
first audio frame it sees is the start of the audio, and the output
timestamps will be offset so that point becomes 0 in the output.
If the seek point happened to be in a gap where there were no audio
frames, this will cause the audio to be earlier than expected.

Setting the `first_pts=0` option causes the filter to trim or pad
the start of the output audio to preserve the correct offset relative to
0, where 0 is the seek point (set with the `-ss` option).
@coderabbitai

coderabbitai Bot commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The FFMPEG_AFORMAT constant in the BigBlueButton EDL Audio module is updated to include an additional ffmpeg filter parameter. The aresample filter chain is modified by adding first_pts=0 to the filter configuration. This changes the audio processing filter string from aresample=async=1000,aformat=... to aresample=async=1000:first_pts=0,aformat=.... No functional logic or control flow is altered; only the filter parameters are adjusted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing audio desynchronization when a seek point doesn't align with an audio frame start.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem (aresample filter behavior with misaligned seek points) and the solution (adding first_pts=0 option).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
record-and-playback/core/lib/recordandplayback/edl/audio.rb (1)

23-24: Optional: Consider freezing string constants and using single quotes.

Static analysis flags this constant for not being frozen and using double quotes. The same applies to FFMPEG_AEVALSRC on line 23. Both patterns already exist in this file, so this is a low-priority consistency improvement.

♻️ Optional fix to freeze constants and use single quotes
-      FFMPEG_AEVALSRC = "aevalsrc=s=48000:c=stereo:exprs=0|0"
-      FFMPEG_AFORMAT = "aresample=async=1000:first_pts=0,aformat=sample_fmts=s16:sample_rates=48000:channel_layouts=stereo"
+      FFMPEG_AEVALSRC = 'aevalsrc=s=48000:c=stereo:exprs=0|0'.freeze
+      FFMPEG_AFORMAT = 'aresample=async=1000:first_pts=0,aformat=sample_fmts=s16:sample_rates=48000:channel_layouts=stereo'.freeze
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb` around lines 23
- 24, Constants FFMPEG_AFORMAT and FFMPEG_AEVALSRC should use frozen
single-quoted string literals for consistency and to satisfy static analysis;
update the definitions of FFMPEG_AFORMAT and FFMPEG_AEVALSRC to use single
quotes and call freeze (or use a frozen string literal) so the constants are
immutable and match the existing pattern in this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@record-and-playback/core/lib/recordandplayback/edl/audio.rb`:
- Around line 23-24: Constants FFMPEG_AFORMAT and FFMPEG_AEVALSRC should use
frozen single-quoted string literals for consistency and to satisfy static
analysis; update the definitions of FFMPEG_AFORMAT and FFMPEG_AEVALSRC to use
single quotes and call freeze (or use a frozen string literal) so the constants
are immutable and match the existing pattern in this file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 82d2e066-e214-4c60-b4f4-6e00dd9d9f3e

📥 Commits

Reviewing files that changed from the base of the PR and between a0ed28c and 9fdeb4d.

📒 Files selected for processing (1)
  • record-and-playback/core/lib/recordandplayback/edl/audio.rb

@github-actions

Copy link
Copy Markdown

🚨 Automated tests failed

@antobinary antobinary added this to the Release 3.0 milestone Mar 11, 2026
@kepstin

kepstin commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

@kepstin kepstin closed this Mar 27, 2026
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.

3 participants