Skip to content

bug: media-playback: non-looping media (e.g. a GIF) drops its last frames (upstream #10425) #306

Closed

Description

@rdoupe

Upstream OBS bug, reported by XC3N in obsproject/obs-studio#10425 (reproduced by RytoEX). Code unchanged in this fork.

Location

  • shared/media-playback/media-playback/media.c mp_media_thread(): after outputting a frame the thread decodes the next one; when there is none and looping is off, mp_media_eof() stops playback at once, without waiting for the last frame's duration (looping waits for it through the offset in mp_media_reset).
  • The stop calls media_stopped (plugins/obs-ffmpeg/obs-ffmpeg-source.c), which clears the source with obs_source_output_video(NULL), and that drops every frame libobs has queued but not yet shown (free_async_cache). In buffered mode libobs shows a frame up to about one frame interval plus one output frame after it is output, so the last frame, and usually the one before it, is never shown.

Class

Wrong output: the end of non-looping media is cut, most visibly on GIFs (about 90% of frames shown, per the report).

How it is reached

A Media Source with Loop off playing a GIF (or any clip) once, with "Show nothing when playback ends" on (the default): the last frame(s) never appear on program output. Not GIF-specific; at video frame rates it is just hard to see.

Reproduced with the real ffmpeg_source and a generated 10-frame GIF (one solid colour per frame, 100 ms each) at 30 fps output: 8 of 10 frames appear; the same with a 10-frame video clip.

Proposed fix and failing test

Fix: when playback reaches its end with Loop off, the media thread keeps the last frame up for its duration plus the time libobs needs to show it (the interval between the last two frames plus two output frames, capped at 3 s) before it stops. A user stop still clears at once; looping is unchanged.

RED test (cmocka, test_media_gif_last_frame): one-shot GIF, one-shot video, and a looping GIF guard; it checks every frame appears in order. 2 of 3 fail today.

Activity

  1. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_media_gif_last_frame (2 of 3 failing): a generated 10-colour GIF and video played once through the real ffmpeg_source, every frame checked on program output.
    2. GREEN: the media thread holds the last frame long enough for libobs to show it before stopping.
      PR today.
  2. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    @XC3N you reported this in obsproject/obs-studio#10425, so a heads-up: it's fixed here in obs-rust by #307, merged today with a regression test.

    Cause: with Loop off, the media player stopped the moment it ran out of frames, without waiting for the last frame's duration, and the stop cleared the frames OBS had queued but not yet shown, so the last frame (and usually the one before it) never appeared. It isn't GIF-specific; a GIF just makes it obvious. Now the player keeps the last frame up long enough for OBS to show it before it stops; a manual stop still clears at once and looping is unchanged. The test plays a 10-colour GIF once through a real Media Source and checks every frame on the output: before, 8 of 10 appeared; now all 10 do, in order.

    Not covered yet: Stinger transitions with "preload into memory" still lose their last frame (a separate code path).

    Workaround on stock OBS: duplicate the last frame of the GIF (or add a short hold at the end).

    obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR.

    If you try it, a short reply here on whether your GIFs now play to the end would really help.

  3. added a commit that references this issue on Oct 12, 2026
    fb3a897
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