MusicPlayerDaemon / MPD

Music Player Daemon
https://www.musicpd.org/
GNU General Public License v2.0
2.18k stars 352 forks source link

Inaccurate seeking within ogg vorbis/opus files #720

Closed mwenzkowski closed 4 years ago

mwenzkowski commented 4 years ago

Bug report

Describe the bug

I noticed the following incorrect behavior while seeking some vorbis/opus files: When seeking to an absolute time (e.g. via mpc seek 2:00), MPD does not seek to the specified time, but instead it seeks to some seconds before or after the specified time. This happens only to certain files and if it happens to a file, this behavior occurs only to certain seek positions.

Expected Behavior

MPD seeks to the specified time.

Actual Behavior

With the file test.ogg from file.tar.gz in MPD's music directory (in my case ~/Audio) the following seek behavior can be observed:

$ mpc add test.ogg
$ mpc play 1
test.ogg
[playing] #1/1   0:00/20:30 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: on
$ mpc seek 10:00; for i in {1..10}; do mpc; sleep 0.2; done
test.ogg
[playing] #1/1  10:00/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:00/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:00/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:01/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:01/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:01/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:01/20:30 (48%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:16/20:30 (50%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:16/20:30 (50%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:17/20:30 (50%)
volume:100%   repeat: off   random: off   single: off   consume: on
test.ogg
[playing] #1/1  10:17/20:30 (50%)
volume:100%   repeat: off   random: off   single: off   consume: on

First Observation: MPD does not seek to 10:00 but near 10:17. Second Observation: Directly after sending the seek command, MPD reports the playback position which was requested by the seek command and shortly after that, the position changes to the position to which MPD actually was seeking.

I have seen similar behavior with opus files.

Version

Music Player Daemon 0.21.19 (0.21.19) Copyright 2003-2007 Warren Dukes warren.dukes@gmail.com Copyright 2008-2018 Max Kellermann max.kellermann@gmail.com This is free software; see the source for copying conditions. There is NO warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins: simple proxy upnp

Storage plugins: local smbclient udisks nfs curl

Neighbor plugins: smbclient upnp udisks

Decoders plugins: [mad] mp3 mp2 [mpg123] mp3 [vorbis] ogg oga [oggflac] ogg oga [flac] flac [opus] opus ogg oga [sndfile] wav aiff aif au snd paf iff svx sf voc w64 pvf xi htk caf sd2 [audiofile] wav au aiff aif [dsdiff] dff [dsf] dsf [hybrid_dsd] m4a [faad] aac [mpcdec] mpc [wavpack] wv [modplug] 669 amf ams dbm dfm dsm far it med mdl mod mtm mt2 okt s3m stm ult umx xm [mikmod] amf dsm far gdm imf it med mod mtm s3m stm stx ult uni xm [wildmidi] mid [fluidsynth] mid [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve [gme] ay gbs gym hes kss nsf nsfe sap spc vgm vgz [pcm]

Filters: libsamplerate soxr

Tag plugins: id3tag

Output plugins: shout null fifo pipe alsa ao oss openal solaris pulse jack httpd recorder

Encoder plugins: null vorbis opus lame twolame wave flac

Archive plugins: [bz2] bz2 [zzip] zip [iso] iso

Input plugins: file archive alsa tidal qobuz curl ffmpeg smbclient nfs mms cdio_paranoia

Playlist plugins: extm3u m3u pls xspf asx rss soundcloud flac cue embcue

Protocols: file:// alsa:// tidal:// qobuz:// http:// https:// gopher:// rtp:// rtsp:// rtmp:// rtmpt:// rtmps:// smb:// nfs:// mms:// mmsh:// mmst:// mmsu:// cdda://

Other features: avahi dbus udisks epoll icu inotify ipv6 systemd tcp un

Log

Jan 26 14:25 : client: [430] opened from [::1]:37394 Jan 26 14:25 : client: [430] process command list Jan 26 14:25 : client: process command "add "test.ogg"" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [430] process command list returned 0 Jan 26 14:25 : client: [430] closed Jan 26 14:25 : state_file: Saving state file /home/maximilian/.config/mpd/state Jan 26 14:25 : client: [431] opened from [::1]:37396 Jan 26 14:25 : client: [431] process command "play "0"" Jan 26 14:25 : playlist: play 0:"test.ogg" Jan 26 14:25 : decoder_thread: probing plugin vorbis Jan 26 14:25 : client: [431] command returned 0 Jan 26 14:25 : client: [431] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [431] process command list returned 0 Jan 26 14:25 : decoder: audio_format=44100:f:2, seekable=true Jan 26 14:25 : output: opened "My Pulse Output" (pulse) audio_format=44100:f:2 Jan 26 14:25 : client: [431] closed Jan 26 14:25 : replay_gain: replay gain mode has changed off->album Jan 26 14:25 : replay_gain: scale=1.000000 Jan 26 14:25 : state_file: Saving state file /home/maximilian/.config/mpd/state Jan 26 14:25 : client: [432] opened from [::1]:37398 Jan 26 14:25 : client: [432] process command "seekcur "600"" Jan 26 14:25 : client: [432] command returned 0 Jan 26 14:25 : client: [432] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [432] process command list returned 0 Jan 26 14:25 : client: [432] closed Jan 26 14:25 : client: [433] opened from [::1]:37400 Jan 26 14:25 : client: [433] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [433] process command list returned 0 Jan 26 14:25 : client: [433] closed Jan 26 14:25 : client: [434] opened from [::1]:37402 Jan 26 14:25 : client: [434] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [434] process command list returned 0 Jan 26 14:25 : client: [434] closed Jan 26 14:25 : client: [435] opened from [::1]:37404 Jan 26 14:25 : client: [435] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [435] process command list returned 0 Jan 26 14:25 : client: [435] closed Jan 26 14:25 : client: [436] opened from [::1]:37406 Jan 26 14:25 : client: [436] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [436] process command list returned 0 Jan 26 14:25 : client: [436] closed Jan 26 14:25 : client: [437] opened from [::1]:37408 Jan 26 14:25 : client: [437] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [437] process command list returned 0 Jan 26 14:25 : client: [437] closed Jan 26 14:25 : client: [438] opened from [::1]:37410 Jan 26 14:25 : client: [438] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [438] process command list returned 0 Jan 26 14:25 : client: [438] closed Jan 26 14:25 : client: [439] opened from [::1]:37412 Jan 26 14:25 : client: [439] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [439] process command list returned 0 Jan 26 14:25 : client: [439] closed Jan 26 14:25 : client: [440] opened from [::1]:37414 Jan 26 14:25 : client: [440] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [440] process command list returned 0 Jan 26 14:25 : client: [440] closed Jan 26 14:25 : client: [441] opened from [::1]:37416 Jan 26 14:25 : client: [441] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [441] process command list returned 0 Jan 26 14:25 : client: [441] closed Jan 26 14:25 : client: [442] opened from [::1]:37418 Jan 26 14:25 : client: [442] process command list Jan 26 14:25 : client: process command "status" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: process command "currentsong" Jan 26 14:25 : client: command returned 0 Jan 26 14:25 : client: [442] process command list returned 0 Jan 26 14:25 : client: [442] closed

MaxKellermann commented 4 years ago

This TODO comment needs to be implemented to fix this: https://github.com/MusicPlayerDaemon/MPD/blob/1e07d1542856d63f026448eb37e1276576d8381b/src/decoder/plugins/OggDecoder.cxx#L76-L80