Skip to content

obs-ffmpeg: Fix B-frame offset calculation in AMF - #13762

Merged
RytoEX merged 1 commit into
obsproject:masterfrom
amazon-contributing:lexano/amd-b-frame
Aug 24, 2026
Merged

RytoEX merged 1 commit into
obsproject:masterfrom
amazon-contributing:lexano/amd-b-frame

Conversation

@lexano-ivs

@lexano-ivs lexano-ivs commented Aug 6, 2026 •

Copy link
Copy Markdown

AMF AVC and AV1 encoders support B-frames in more recent GPUs, however the enc->dts_offset was being incremented even when b-frames were set to 0.

For AVC, this caused IVS Stages to reject the stream because the offset is used to infer the presence of B-frames, which are not supported by IVS Stages (and WebRTC).

For AV1, the code is not needed and was removed. See below for details.

Description

For AVC, only increment the enc->dts_offset if the AMF encoder supports B-frames and b-frames are greater than 0.

For AV1, remove the dts_offset calculation from amf_av1_create_internal. This code was dead β€” convert_to_encoder_packet already excludes AV1 from the DTS subtraction (added in b2d83efcf, PR #10996), since AV1 handles frame reordering transparently and doesn't require decode-order delay compensation at the mux layer.

The AV1 dts_offset block was introduced in 1a2f8c284 (AMD AV1 B-frame support) as a mechanical copy of the AVC pattern without accounting for this exclusion. This aligns with the NVENC implementation (plugins/obs-nvenc/nvenc.c), which similarly guards its DTS adjustment with if (enc->codec != CODEC_AV1) and has no offset calculation in its AV1 path.

Motivation and Context

The original bug report at #13723 provides the details.

How Has This Been Tested?

I created an IVS Stage and reproduced the problem initially, then implemented the fix and tested on the same stage. There were no disconnects after the fix was in place.

Types of changes

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

Checklist:

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

Comment thread plugins/obs-ffmpeg/texture-amf.cpp Resolved
@lexano-ivs
lexano-ivs force-pushed the lexano/amd-b-frame branch 2 times, most recently from 3e96e49 to dc09615 Compare August 6, 2026 20:36
AVC and AV1 encoders in AMF that support B-frames were incrementing
`dts_offset` even when B-frames were set to 0. For AVC, adjust the
`dts_offset` only when B-frames are supported and are greater than 0,
and clamp to maximum supported.

For AV1, remove the dts_offset code completely because it is being
ignored anyway. AV1 handles B-frames and offsets differently; refer
to [1] for details.

[1]: obsproject#10996
HoboStreamer pushed a commit to HoboStreamer/ovbs-studio that referenced this pull request Aug 12, 2026
@RytoEX
RytoEX requested a review from derrod August 21, 2026 02:27
@RytoEX RytoEX added kind/bug Categorizes issue or PR as related to a bug. area/encoding release-note/fix Groups pull request under the "Fixes" section in the associated patch notes labels Aug 21, 2026
@RytoEX RytoEX added this to the OBS Studio 33.0 milestone Aug 24, 2026
@RytoEX
RytoEX merged commit 0969e43 into obsproject:master Aug 24, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Ready For Review to Merged in Current Release Tracker (33.0) Aug 24, 2026
@github-project-automation github-project-automation Bot moved this from Ready For Review to Merged in Next Release Tracker (33.2) Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/encoding kind/bug Categorizes issue or PR as related to a bug. release-note/fix Groups pull request under the "Fixes" section in the associated patch notes

Projects

Status: Merged
Status: Merged

Development

Successfully merging this pull request may close these issues.

3 participants