Skip to content

bug: vlc-video: playlist cuts the last second of every track (upstream #9345) #301

Closed

Description

@rdoupe

Upstream OBS bug, reported by COOLIGUAY in obsproject/obs-studio#9345 (4 +1s and more users through 2025; earlier duplicate obsproject/obs-studio#3712 with about ten users, and #11984). Code unchanged in this fork.

Location

  • plugins/vlc-video/vlc-video-source.c vlcs_audio_setup/libvlc_audio_set_callbacks_(..., vlcs_audio_play, NULL, NULL, NULL, NULL, c): no drain callback is registered. libVLC hands audio to the play callback about a second ahead of its pts and calls drain at the end of an item so the output can play out what it was given; without one, the item counts as finished as soon as its last block is handed over, and the next item starts about 1 s before the previous one's audio is due.
  • libobs then places the next item's first packet (about 1.04 s earlier than expected, under MAX_TS_VAR, over TS_SMOOTHING_THRESHOLD) inside the buffered tail, and source_output_audio_place() truncates the rest of it.

Class

Audio cut: the last ~1 s of every track in a VLC playlist (except the last) is missing from recordings and streams.

How it is reached

A VLC Video Source with a playlist of audio files (the reporter's case): at every track change the end of the previous track is cut. A single file with looping on loses the same second at each repeat. Files with video are not affected (libVLC waits for the video output there).

Reproduced with the real vlc_source and generated 3 s WAV tracks, measuring program audio: in a 2- and 3-file playlist each track but the last is heard only to ~1.96 s (1.04-1.05 s missing).

Proposed fix and failing test

Fix: register a drain callback that waits on the libVLC clock until the audio handed over so far is due (capped at 3 s), as a real audio device drains its buffer, with an abort event so stop, restart, next/previous, settings updates, deactivation and destroy never wait for it.

RED test (cmocka, test_vlc_playlist_gap): single file, 2- and 3-file playlists, and a stop near a track's end (must stay prompt). The two playlist cases fail today; skipped without libVLC or a display.

Activity

  1. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_vlc_playlist_gap (2 of 4 failing): generated WAV playlists through the real vlc_source, program audio measured per track.
    2. GREEN: a libVLC audio drain callback that plays out the handed-over audio before the next item starts, abortable on stop/next/destroy.
      PR today.
  2. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

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

    Cause: libVLC hands audio to OBS about a second ahead of when it plays, and asks the player to "drain" at the end of each item so that last second gets played out. OBS's VLC source never registered that drain callback, so each item counted as finished as soon as its last audio was handed over, the next item started about a second early, and OBS dropped the overlapping tail. Now the source drains properly (and a stop, next or settings change still interrupts at once). The test plays generated tracks as a playlist and measures program audio: before, every track except the last lost its final ~1.05 s; now each plays to the end.

    Workaround on stock OBS: add about a second of silence to the end of each file.

    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 playlists play through would really help.

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