Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-outputs: Set FLV DTS offset based on first audio or video packet #10999

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

derrod
Copy link
Member

@derrod derrod commented Jul 17, 2024

Description

Ensures that PTS/DTS for audio start at 0 if there by ensuring the DTS offset is based on the first packet that comes in, regardless of whether or not it's video (b-frame delay), or audio (priming sample delay).

Motivation and Context

Fixes #10998

This became necessary due to #10689 and #10690 which fix handling of audio priming samples with negative timestamps. Note that if users have a sufficiently large number of b-frames configured (1 is enough) this currently doesn't actually cause any issues.

How Has This Been Tested?

Logged output packets and ensured the resulting FLV files are playable.

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 the Bug Fix Non-breaking change which fixes an issue label Jul 17, 2024
@derrod derrod added this to the OBS Studio 30.2 milestone Jul 17, 2024
@RytoEX RytoEX requested a review from tt2468 July 17, 2024 20:15
@derrod derrod force-pushed the flv-ensure-audio-ts-is-positive branch from 582a744 to dba4bb3 Compare July 18, 2024 04:22
@derrod derrod changed the title obs-outputs: Adjust audio PTS/DTS to start at 0 if necessary obs-outputs: Set FLV DTS offset based on first audio or video packet Jul 18, 2024
@Lain-B
Copy link
Collaborator

Lain-B commented Jul 20, 2024

The fact that the first audio packet is 0ms, the second audio packet is -1ms, and the third audio packet is 20ms in the issue report seems a bit concerning, are those three full audio packets or am I misunderstanding something? I know that we merged the code for the encoder delay but is that supposed to be that way? Has it always been that way? I admit I've rarely used/tested CoreAudio personally.

@derrod
Copy link
Member Author

derrod commented Jul 21, 2024

The fact that the first audio packet is 0ms, the second audio packet is -1ms, and the third audio packet is 20ms in the issue report seems a bit concerning, are those three full audio packets or am I misunderstanding something? I know that we merged the code for the encoder delay but is that supposed to be that way? Has it always been that way? I admit I've rarely used/tested CoreAudio personally.

In the issue report they're logging the timestamps of outgoing packets, not incoming ones, so it includes the audio track "header" packet which always has a timestamp of 0. The packets from the actual encoder then start with a negative timestamp.

@tt2468
Copy link
Member

tt2468 commented Jul 22, 2024

It might be a good idea to have a code comment explaining the issue and/or describing the effects. Just so someone in the future can understand why the code exists.

@RytoEX
Copy link
Member

RytoEX commented Jul 22, 2024

Merging as-is based on off-thread discussion. If someone feels the code needs clarified, we can add comments later.

@RytoEX RytoEX merged commit 31963f8 into obsproject:master Jul 22, 2024
15 checks passed
@derrod derrod deleted the flv-ensure-audio-ts-is-positive branch July 23, 2024 02:49
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Streaming always failed due to the CoreAudio AAC timestamp issue
4 participants