Skip to content

bug: obs-ffmpeg: a recording started while the replay buffer runs still waits for the next keyframe with VA-API, AOM AV1 and SVT-AV1 (follow-up to #594, upstream obsproject/obs-studio#12069) #597

Closed

Description

@rdoupe

Follow-up to #594 (upstream obsproject/obs-studio#12069). #594 added the optional request_keyframe callback to obs_encoder_info, which libobs calls when an output starts on a video encoder another output already runs, but only obs-x264 implements it. With the other encoders, a recording started while the replay buffer runs still waits for the encoder's next scheduled keyframe: it misses its first seconds, and one stopped before that keyframe takes seconds to stop and leaves an unreadable file.

Location

Class

Data loss: recordings miss their first seconds or are empty and unreadable; the stop hangs for seconds. Same as #593, with encoders other than x264.

How it is reached

Advanced output, replay buffer enabled (it shares the recording encoder), recording encoder FFmpeg VA-API H.264/HEVC, AOM AV1 or SVT-AV1, 20 fps. Start the replay buffer, start recording a few seconds later, stop it after a few seconds.

Reproduced

Headless, private config, obs-websocket; Advanced output, mkv, 20 fps, replay buffer 20 s, a Media Source looping a clip. Each round: start the replay buffer, start recording 3 s later and stop it after 6 s; then a round that starts recording 1 s after the replay buffer and stops it after 2 s. Two rounds of each.

  • Current release (AppImage 33.0.0-beta6-799), SVT-AV1: the 6 s recordings hold 2.97 s; stopping the 2 s recordings takes 3.17 s and leaves 674-byte files ffprobe cannot read (Duplicate element, invalid as first byte of an EBML number). VA-API could not be run in the AppImage on the test machine (its bundled libva does not load the system's VA-API driver), so VA-API was reproduced with a master build:
  • Current master, VA-API H.264 (default settings, keyframe interval 120 frames): the 6 s recordings hold 3.0 s; stopping the 2 s recordings takes 3.18 s and leaves unreadable 735-byte files. SVT-AV1 in the same build: 2.7 s, and 3.4 s stops with unreadable files.

Proposed fix and failing test

Fix: implement request_keyframe in obs-ffmpeg for VA-API H.264 and HEVC and for AOM AV1 and SVT-AV1: the next frame goes to FFmpeg with pict_type = AV_PICTURE_TYPE_I, which FFmpeg's VA-API encoders turn into an IDR frame, libaom into a forced keyframe and SVT-AV1 into a key picture.

RED test: extend test_encoder_join_keyframe with cases that load the built obs-x264 and obs-ffmpeg modules and run the same join with the real encoders (10 s keyframe interval). The joining output's first packet must be a keyframe made from the frame the encoder got when the output joined, within a few frames. Today the four obs-ffmpeg cases get nothing within 3 s; x264 passes. Each case skips when its encoder is not available (no VA-API device, FFmpeg without the library), as in CI.

Not covered: NVENC, QSV and AMF (no such hardware to test on), VA-API AV1 (the test GPU has no AV1 encoding), and OpenH264 (the system FFmpeg used here is built without libopenh264).

Activity

  1. rdoupe commented on Oct 13, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_encoder_join_keyframe gets real-encoder cases (x264, VA-API H.264/HEVC, AOM AV1, SVT-AV1); the four obs-ffmpeg ones fail: the joining output waits for the next scheduled keyframe.
    2. GREEN: obs-ffmpeg implements request_keyframe (from libobs, obs-x264: Ask a running encoder for a keyframe when an output joins #594) for those encoders.
      PR today.
  2. added a commit that references this issue on Oct 13, 2026
    44170a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions