MPD icon indicating copy to clipboard operation
MPD copied to clipboard

Audio glitches when seeking on mp3 files

Open xfzv opened this issue 3 years ago • 6 comments

Bug report

Describe the bug

When seeking either backward or forward on an mp3 file (from my music directory specified in ~/.config/mpd/mpd.conf or from a drag'n'drop in my MPD client, Cantata), I'm getting weird audio glitches, as if the sound was distorted.

  • It only happens with .mp3 files. I can seek on any .ape, .flac, .opus, .wav or .wv file without any issue.
  • I don't have the issue with other players such as Clementine, DeaDBeeF, mpv, Strawberry...

I can reproduce with:

  • Linux distros: Arch Linux and Gentoo (on the same machine)
  • MPD Clients: Cantata or ncmpcpp and probably all of them I guess.

Expected Behavior

I shouldn't hear any audio glitch when seeking on an mp3 file.

Actual Behavior

I do hear an audio glitch every time I seek on an mp3 file.

Version

% mpd --version

Music Player Daemon 0.23.5 (0.23.5)
Copyright 2003-2007 Warren Dukes <[email protected]>
Copyright 2008-2021 Max Kellermann <[email protected]>
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 udisks nfs curl

Neighbor plugins:
 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
 [openmpt] mptm mod s3m xm it 669 amf ams c67 dbm digi dmf dsm dtm far imf ice j2b m15 mdl med mms mt2 mtm nst okt plm psm pt36 ptm sfx sfx2 st26 stk stm stp ult wow gdm mo3 oxm umx xpk ppm mmcmp
 [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
 [sidplay] sid mus str prg P00
 [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 rtp:// rtsp:// rtsps://
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

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

Encoder plugins:
 null vorbis opus lame twolame wave flac

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

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

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

Protocols:
 file:// alsa:// cdda:// ftp:// ftps:// gopher:// hls+http:// hls+https:// http:// https:// mms:// mmsh:// mmst:// mmsu:// nfs:// qobuz:// rtmp:// rtmpe:// rtmps:// rtmpt:// rtmpte:// rtmpts:// rtp:// rtsp:// rtsps:// scp:// sftp:// smb:// srtp://

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

# ~/.config/mpd/mpd.conf

db_file             "~/.config/mpd/mpd.db"
music_directory     "/media/Data/Music/"
pid_file            "~/.config/mpd/mpd.pid"
playlist_directory  "~/.config/mpd/playlists/"
state_file          "~/.config/mpd/mpdstate"

bind_to_address     "any"
port                "6600"
auto_update         "yes"

audio_output {
    type            "pulse"
    name            "pulseaudio"
}

Log

Nothing relevant in

% mpd --verbose
% journalctl | rg mpd
% systemctl --user status mpd.service

when playing an mp3 file and trying to seek.

xfzv avatar Jan 09 '22 14:01 xfzv

The log is important.

MaxKellermann avatar Jan 10 '22 16:01 MaxKellermann

The log is important.

% mpd --verbose:

config_file: loading file /home/xfzv/.config/mpd/mpd.conf
server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
vorbis: Xiph.Org libVorbis 1.3.7
opus: libopus 1.3.1
hybrid_dsd: The Hybrid DSD decoder is disabled because it was not explicitly enabled
simple_db: reading DB
curl: version 7.80.0
curl: with OpenSSL/1.1.1m

% systemctl --user status mpd.service (while playing an .mp3 file and seeking):

gentoo systemd[3316]: Starting Music Player Daemon...
gentoo mpd[8487]: server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
gentoo systemd[3316]: Started Music Player Daemon.
gentoo mpd[8487]: exception: Unsupported URI scheme
gentoo mpd[8487]: exception: Failed to open '/home/xfzv/.config/mpd/playlists/[Radio Streams].m3u': No such file or directory
gentoo mpd[8487]: exception: No such playlist

% journalctl | rg mpd (different PID because I restarted the service with % systemctl --user restart mpd.service):

gentoo mpd[7567]: server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
gentoo mpd[7567]: exception: Unsupported URI scheme
gentoo mpd[7567]: exception: Failed to open '/home/xfzv/.config/mpd/playlists/[Radio Streams].m3u': No such file or directory
gentoo mpd[7567]: exception: No such playlist

xfzv avatar Jan 10 '22 17:01 xfzv

Your log shows that MPD never plays anything.

MaxKellermann avatar Jan 10 '22 18:01 MaxKellermann

Your log shows that MPD never plays anything.

Indeed, my bad. :man_facepalming:

The following was after another restart of the systemd user service and an .mp3 playback ended (I sought backward and forward during the playback):

% systemctl --user status mpd.service

jan. 10 20:26:15 gentoo systemd[3316]: Starting Music Player Daemon...
jan. 10 20:26:15 gentoo mpd[47651]: server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
jan. 10 20:26:16 gentoo systemd[3316]: Started Music Player Daemon.
jan. 10 20:26:17 gentoo mpd[47651]: exception: Unsupported URI scheme
jan. 10 20:26:17 gentoo mpd[47651]: exception: Failed to open '/home/xfzv/.config/mpd/playlists/[Radio Streams].m3u': No such file or directory
jan. 10 20:26:17 gentoo mpd[47651]: exception: No such playlist
jan. 10 20:26:35 gentoo mpd[47651]: player: played "Metal/Arkaik/2019 - Supernal Flame/01 - Supernal Flame.mp3"

With an .mp3 file which isn't part of my MPD library that I drag'ndropped manually in Cantata (I'm having the same problem regardless):

% systemctl --user status mpd.service

jan. 10 20:12:50 gentoo systemd[3316]: Starting Music Player Daemon...
jan. 10 20:12:50 gentoo mpd[46759]: server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
jan. 10 20:12:51 gentoo systemd[3316]: Started Music Player Daemon.
jan. 10 20:12:58 gentoo mpd[46759]: exception: Unsupported URI scheme
jan. 10 20:12:58 gentoo mpd[46759]: exception: Failed to open '/home/xfzv/.config/mpd/playlists/[Radio Streams].m3u': No such file or directory
jan. 10 20:12:58 gentoo mpd[46759]: exception: No such playlist
jan. 10 20:14:30 gentoo mpd[46759]: player: played "http://127.0.0.1:42329/media/Data/Downloads/Open%20Music%20Archive%20-%2020150609%20-%20Golden%20Days%20-%20Mario%20Lanza%20[209552456].mp3?album=The%20Edges%20of%20the%20Public%20Domain&artist=Open%20Music%20Archive&title=Golden%20Days%20-%20Mario%20Lanza&genre=SongDivision&year=2015&time=90&id=-1&cantata=song"

xfzv avatar Jan 10 '22 19:01 xfzv

Your log shows no start of playback. Or you didn't read the bug reporting template properly and forgot to enable verbose logging.

MaxKellermann avatar Jan 10 '22 19:01 MaxKellermann

I'm sorry. I enabled log_level verbose in ~/.config/mpd/mpd.conf and restarted the service.

% journalctl | rg mpd:

...skipping...
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:13 gentoo mpd[50499]: client: [1] process command "idle"
jan. 10 20:43:13 gentoo mpd[50499]: client: [1] command returned 1
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] process command "seekid "54" "330""
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] process command "replay_gain_status"
jan. 10 20:43:13 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:13 gentoo mpd[50499]: client: [1] process command "idle"
jan. 10 20:43:13 gentoo mpd[50499]: client: [1] command returned 1
jan. 10 20:43:14 gentoo mpd[50499]: client: [0] process command "seekid "54" "333""
jan. 10 20:43:14 gentoo mpd[50499]: decoder_thread: probing plugin mad
jan. 10 20:43:14 gentoo mpd[50499]: mad: detected LAME version 3.99 ("LAME3.99r")
jan. 10 20:43:14 gentoo mpd[50499]: mad: LAME peak found: 0
jan. 10 20:43:14 gentoo mpd[50499]: mad: encoder delay is 576, encoder padding is 1534
jan. 10 20:43:14 gentoo mpd[50499]: decoder: audio_format=44100:24:2, seekable=true
jan. 10 20:43:14 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:14 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:14 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:14 gentoo mpd[50499]: client: [0] process command "replay_gain_status"
jan. 10 20:43:14 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:14 gentoo mpd[50499]: client: [1] process command "idle"
jan. 10 20:43:14 gentoo mpd[50499]: client: [1] command returned 1
jan. 10 20:43:18 gentoo mpd[50499]: player: played "Metal/Arkaik/2019 - Supernal Flame/01 - Supernal Flame.mp3"
jan. 10 20:43:18 gentoo mpd[50499]: playlist: stop
jan. 10 20:43:18 gentoo mpd[50499]: output: closed "pulseaudio" (pulse)
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "plchangesposid "2""
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "playlistinfo"
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "replay_gain_status"
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:18 gentoo mpd[50499]: client: [1] process command "idle"
jan. 10 20:43:18 gentoo mpd[50499]: client: [1] command returned 1
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] process command "currentsong"
jan. 10 20:43:18 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:24 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:24 gentoo mpd[50499]: client: [0] command returned 0
jan. 10 20:43:29 gentoo mpd[50499]: client: [0] process command "status"
jan. 10 20:43:29 gentoo mpd[50499]: client: [0] command returned 0

Not sure if ...skipping... is displayed because there are too many output lines before, maybe there is some interesting stuff before that.

As per user's manual:

# Sometimes, it is helpful to run MPD in a terminal and follow what happens. This is how to do it:
mpd --stderr --no-daemon --verbose

Noob question: how can I achieve that (like mpd --stderr --no-daemon --verbose > mpd_log.txt) considering nothing happens in the console while I'm reproducing the issue in Cantata?

xfzv avatar Jan 10 '22 20:01 xfzv

The issue disappeared after recompiling mpd without mad USE flag in order to use ffmpeg as decoder for mp3:

❯  mpd --version
Music Player Daemon 0.23.13 (0.23.13)
Copyright 2003-2007 Warren Dukes <[email protected]>
Copyright 2008-2021 Max Kellermann <[email protected]>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[..]

Decoders plugins:
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [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 rtp:// rtsp:// rtsps://
 [pcm]

[..]

Edit: Just for reference, fixed on my Arch Linux install too by disabling mad and mpg123 encoders in ~/.config/mpd/mpd/conf:

decoder {
     plugin  "mad"
     enabled "no"
}

decoder {
     plugin  "mpg123"
     enabled "no"
}

xfzv avatar Jul 29 '23 11:07 xfzv