Skip to content

Conversation

@derrod
Copy link
Member

@derrod derrod commented May 18, 2024

Description

Note

Requires #10689 to be fully functional as currently OBS will not treat negative audio timestamps correctly.

CoreAudio - and other AAC encoders - generally have an encoder delay that produces a number of silent "priming" samples. For CoreAudio AAC this is 2112 by default and this needs to be subtracted from the PTS/DTS to ensure that PTS 0 is the actual start of the input audio.

See Apple's documentation for a good explanation of AAC encoder delay and how to deal with it: https://web.archive.org/web/20170912012230/https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html

Motivation and Context

Want audio to be in sync.

When using FFmpeg encoders libavcodec already handles this for us. This is also already done in the libfdk-aac module: https://github.com/obsproject/obs-studio/blob/master/plugins/obs-libfdk/obs-libfdk.c#L266-L272

How Has This Been Tested?

Validated on Windows that output DTS/PTS is now correct.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@derrod derrod added Bug Fix Non-breaking change which fixes an issue Windows Affects Windows macOS Affects macOS labels May 18, 2024
@derrod derrod force-pushed the fix-coreaudio-dts branch from 2758b91 to 7b6a5c2 Compare May 18, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue macOS Affects macOS Windows Affects Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants