mpv
mpv copied to clipboard
Bug: Playback seeks backwards when speed is increased, and seeks forwards when speed is decreased
Important Information
Provide following Information:
- mpv version:
> mpv --version
mpv v0.37.0-337-gbd5b80ba Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
built on Feb 18 2024 00:09:08
libplacebo version: v6.338.0-77-g3ba18d5-dirty
FFmpeg version: N-113670-g0895ef0d6
FFmpeg library versions:
libavutil 58.39.100
libavcodec 60.39.101
libavformat 60.21.100
libswscale 7.6.100
libavfilter 9.17.100
libswresample 4.13.100
- Platform and Version: Windows 11
- Source of the mpv binary: https://sourceforge.net/projects/mpv-player-windows/files/64bit-v3/mpv-x86_64-v3-20240218-git-bd5b80b.7z/download
- If known which version of mpv introduced the problem: unknown
- GPU model, driver and version: GTX 1080
- Possible screenshot or video of visual glitches: none
Reproduction steps
- Start with clean config/profile
- add this debug script to the profile under the scripts directory
require 'mp.msg'
mp.set_property("msg-level", string.format("%s=debug", mp.get_script_name()))
local function s1()
local before = mp.get_property_native('audio-pts')
mp.msg.debug(string.format("before: %f", before))
mp.set_property_native("speed", 1)
local after = mp.get_property_native('audio-pts')
mp.msg.debug(string.format("after : %f", after))
mp.msg.debug(string.format("diff : %f", after-before))
end
local function s2()
local before = mp.get_property_native('audio-pts')
mp.msg.debug(string.format("before: %f", before))
mp.set_property_native("speed", 4)
local after = mp.get_property_native('audio-pts')
mp.msg.debug(string.format("after : %f", after))
mp.msg.debug(string.format("diff : %f", after-before))
end
mp.add_key_binding("1", "slow", s1)
mp.add_key_binding("2", "fast", s2)
- play a video or audio file from the console (e.g.
mpv.com video.mkv) to show debug messages - toggle the speed with the keys
1and2during playback.1sets speed to 1x and2sets speed to 4x - If necessary, use screen capture software or a phone to record the screen to capture video seeking behavior
Expected behavior
Playback time should not change (no seeking). audio-pts before and after the speed change should be identical or very close. Ideally the console should show something like
[debug] before: 12.071627
[debug] after : 12.071627
[debug] diff : 0
Actual behavior
The player actually seems to seek backwards and forwards by a set duration when the speed changes, as seen on the OSD. There is a large difference in audio-pts before and after the speed change.
[debug] before: 12.071627
[debug] after : 11.263086
[debug] diff : -0.808541
The time difference increases as the speed difference increases. In severe cases, when the speed changes a lot (e.g. from 1x to 16x), audio-pts can actually be negative, seeking beyond the boundaries of the file. Here is the output for a 1x to 16x speed change.
[debug] before: 1.047906
[debug] after : -3.047085
[debug] diff : -4.094991
mpv seeks the file to -3.047085 and the difference is over 4 seconds!
Why this matters: I have scripts that depend on always having accurate playback time
Log file
Sample files
Any video or audio file will work, but if you use this diagnostic video https://www.youtube.com/watch?v=szoOsG9137U (download with yt-dlp), you can clearly see the video seeking on a screen recording