#18537·mpv

Selecting an external video track mid-playback stalls while it decodes from the start of its file

Author: 2opremioCreated Sep 28, 2026Updated Sep 28, 2026

mpv Information

mpv v0.41.0 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
 built on Dec 23 2025 13:03:04
libplacebo version: v7.351.0
FFmpeg version: 8.0
FFmpeg library versions:
   libavcodec      62.11.100
   libavdevice     62.1.100
   libavfilter     11.4.100
   libavformat     62.3.100
   libavutil       60.8.100
   libswresample   6.1.100
   libswscale      9.1.100

Important Information

- Platform version: macOS 26.6.2 (not platform-specific, the cause is in demux/demux.c)
- GPU model, driver and version: Apple M1 Ultra (not involved, reproduced with --vo=null)
- Source of mpv: MacPorts
- Latest known working version: not tested; the cause, 33e414fa5d, first shipped in v0.39.0
- Issue started after the following happened: n/a

Reproduction Steps

ffmpeg -f lavfi -i testsrc2=size=1920x1080:rate=120 -t 60 -c:v libx265 -preset ultrafast a.mov
cp a.mov b.mov
mpv --no-config --vo=null --input-ipc-server=/tmp/mpv.sock --log-file=output.txt a.mov
echo '{"command":["video-add","b.mov","auto"]}' | socat - /tmp/mpv.sock
# let it play for 30 s without seeking, then:
echo '{"command":["set_property","vid",2]}' | socat - /tmp/mpv.sock

Expected Behavior

The new track shows within about a keyframe interval, as later switches to it do.

Actual Behavior

Video stalls until the new track has decoded everything from the start of its file: 645 ms here (switch at 30.185 s, first frame at 30.830 s in the log), and 2 to 4 s with real 120 fps camera footage. The stall grows with the time played before the switch; later switches take about 100 ms.

The external demuxer has read nothing since opening, so it still has after_seek and after_seek_to_start set from its initial state. refresh_track() skips the refresh seek for video streams right after a seek (33e414fa5d), so reading starts at the start of the file. Seeking once after adding the track avoids it. I implemented a fix in a PR I'm opening next.

Log File

output.txt

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.