MusicPlayerDaemon / MPD

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

OpusTags metadata duplication on initial icecast2 push #609

Closed JustArchi closed 5 years ago

JustArchi commented 5 years ago

Bug report

Describe the bug

This issue is very similar to bug #347 but reproducible with audio_output of shout. I'm attaching my audio_output config below (eradicated out of personal, non-relevant bits):

audio_output {
    type "shout"
    encoder "opus"
    host "127.0.0.1"
    port "1337"
    mount "/test.opus"
    always_on "yes"
    quality "10.0"
    format "48000:16:2"
    opustags "true"
}

In particular, the bug is about metadata duplication on the first song when streaming through icecast2. I'm playing opus files through opus stream, in case input could have something to say here.

Expected Behavior

On connection to the icecast mount point during playing the first song, I should get correct non-duplicated metadata.

Actual Behavior

asdasdsaadsaads

I'm getting duplicated metadata, but only for the first song being played. As soon as the song switches to the next one, the metadata is updated correctly. Reconnecting to the stream after the first song is played is also producing the correct metadata. Only connecting to the stream while MPD is playing the initial file causes the issue.

Not all tags are duplicated, song title, artist and album seems to, but comment looks fine.

Version

Music Player Daemon 0.21.11 (0.21.11)
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
 [sidplay] sid mus str prg P00
 [wildmidi] mid
 [fluidsynth] mid
 [adplug] amd d00 hsc laa rad raw sa2
 [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 pulse jack httpd recorder

Encoder plugins:
 null vorbis opus lame 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

Icecast version: Icecast 2.4.4

Log

I didn't find anything relevant in the verbose log file.

Personal thoughts

This could be related to some initial push of metadata, I'm not entirely aware how opus tags chaining works, but it seems that there are 2 mechanisms pushing the initial metadata, but only one properly updating it after the song change. Finding out the duplicated one and turning it off when opustags is specified should probably solve the issue, but this is only my gut as a programmer, I don't know MPD internals well enough, just trying to help pinpoint the issue.

Before #347 was fixed, I was getting duplicated metadata constantly here (on first and every other played song), now it seems that it's only on initial push.

I'm attaching file sample in case you'd be unable to reproduce the issue and it depended in some way on the input files.

sample.zip

Thank you in advance for looking into the issue.

JustArchi commented 5 years ago

I've also reproduced the issue with httpd plugin, so it looks once again like core-related issue and nothing to do with icecast, I've checked through the same method as in #347 and MPD itself sees metadata as duplicated:

root@archi:~# nc 127.0.0.1 6600
OK MPD 0.21.11
currentsong
file: イオシス IOSYS/2008.08.16 [IO-0146] 東方想幽森雛 [C74]/Miracle∞Hinacle.ogg
Last-Modified: 2016-10-21T07:34:35Z
Artist: イオシス IOSYS
Title: Miracle∞Hinacle
Album: 東方想幽森雛
Date: 2008-08-16
Genre: Game
Artist: イオシス IOSYS
Album: 東方想幽森雛
Title: Miracle∞Hinacle
Track: 5
Genre: Game
Date: 2008-08-16
Performer: 3L
Comment: The Road of the Misfortune God ~ Dark Road
Time: 204
duration: 204.007
Pos: 87
Id: 88
OK
next
OK
currentsong
file: UNDEAD CORPORATION/2014.12.29 [ANCO-0011] 兵-つはもの- [C87]/火車の叫ぶ夜に.ogg
Last-Modified: 2016-11-20T04:34:28Z
Artist: UNDEAD CORPORATION
Title: 火車の叫ぶ夜に
Album: 兵-つはもの-
Date: 2014
Genre: Game
Artist: UNDEAD CORPORATION
Album: 兵-つはもの-
Title: 火車の叫ぶ夜に
Track: 4
Genre: Game
Date: 2014
Comment: Lullaby of Deserted Hell
Time: 248
duration: 247.847
Pos: 106
Id: 107
OK

But somehow #347 improved the problem by broadcasting correct tags on song update, interesting.

MaxKellermann commented 5 years ago

I can't reproduce the problem. You said #347 is fixed, but now you see the same symptoms again; but what I don't understand is what is the difference. Do you only see duplicate tags with some files, or with all Opus files?

JustArchi commented 5 years ago

@MaxKellermann I found the problem, it's because of persistent tag_cache database that didn't automatically get updated after the mpd update, so all previously-cached files still had old duplicate metadata, while newly added files were fine. I've manually did rm tag_cache, started mpd and I'm no longer seeing this issue.

Perhaps it'd be a good idea to introduce some kind of "metadata_reading_module_version" variable saved in the database, so in case you modify the metadata reading capability in the mpd source, newer mpd version could automatically schedule database update by seeing older database generated.

I don't know whether this is worth the effort, considering (probably super rare) occurances of metadata reading bugs and other source-related changes that would need tag_cache update, probably not, but you'll need to determine that yourself. In any case I'm happy with the solution and I no longer need anything to be done in regards to this issue, just pointing out why it happened and suggesting some solutions.

Thank you for your continuous support, I appreciate it a lot! 👍