sublime-music / sublime-music

A native Gonic/Subsonic/Airsonic/*sonic client for Linux. Built using Python and GTK+.
https://sublimemusic.app
GNU General Public License v3.0
93 stars 9 forks source link

[BUG] Scrambled audio with some MP3s #333

Open sumnerevans opened 2 years ago

sumnerevans commented 2 years ago

In GitLab by @yossarian on Mar 13, 2022, 14:18

First of all, thanks a ton for writing Sublime Music! It's a fantastic client, and I've been a very happy user on Linux (via a Navidrome server).

I've noticed some badly scrambled audio on a couple of playbacks. At first I thought the files themselves were corrupted, but mp3val reports no errors and all other playback techniques work (Navidrome's web player, using mpv directly).

Subjectively, the audio glitch sounds like very rapid, medium pitched static. None of the song's actual audio is perceptible. The entire album doesn't play correctly (and sounds like the same scrambling), making me think that it's a case of Sublime Music mis-caching the files (although clearing the downloads doesn't change things).

I'm attaching a sample capture of the output (be warned, it's very loud): glitch

I'm also happy to share the offending MP3s themselves, if you think it'll help. I can do that over a direct channel, to avoid any potential IP infringement.

sumnerevans commented 2 years ago

In GitLab by @yossarian on Mar 13, 2022, 14:20

Update: I managed to locate the file in Sublime Music's cache (under ~/.local/share/sublime-music/LONG-ID/c/music/ARTIST/ALBUM/SONG.mp3), and it played correctly in mpv. So it's probably something about how Sublime Music is feeding the song into libmpv.

Edit:

And some relevant decoder information from ffprobe:

  Duration: 00:05:14.17, start: 0.025056, bitrate: 324 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
    Metadata:
      encoder         : LAME3.99r
    Side data:
      replaygain: track gain - -6.500000, track peak - unknown, album gain - unknown, album peak - unknown,
    Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 1200x1200 [SAR 300:300 DAR 1:1], 90k tbr, 90k tbn, 90k tbc (attached pic)
    Metadata:
      comment         : Cover (front)
sumnerevans commented 2 years ago

In GitLab by @yossarian on Mar 13, 2022, 14:41

I also tried reproducing with python-mpv + libmpv directly:

>>> import mpv
>>> player = mpv.MPV(ytdl=True)

Both direct playback and loadfile-style loading work correctly:

>>> # works
>>> player.play('file:////home/william/.local/share/sublime-music/REST-OF-PATH/FILE.mp3')

>>> player.pause = True
>>> player.command("playlist-clear")

>>> # also works
>>> player.command("loadfile", 'file:////home/william/.local/share/sublime-music/REST-OF-PATH/FILE.mp3')
>>> player.pause = False

...so it's probably something about one of these two options:

https://gitlab.com/sublime-music/sublime-music/-/blob/f1300758/sublime_music/players/mpv.py#L133-136

sumnerevans commented 2 years ago

Have you tried with those two options via python-mpv + libmpv? I'd be interested if you are able to reproduce with those options enabled.

sumnerevans commented 2 years ago

Thanks for the report, that's some strange behavior there.

sumnerevans commented 2 years ago

In GitLab by @yossarian on Mar 17, 2022, 23:08

I tried start (I wasn't sure what exactly to try it with, so I fuzzed it with a few educated guesses: 0, 1, -1, 0.00001, etc.), and the playback was still fine.

I can try force-seekable today or tomorrow.

sumnerevans commented 2 years ago

In GitLab by @yossarian on Mar 17, 2022, 23:09

(I just tried --force-seekable from the MPV command line; playback is fine.)

sumnerevans commented 2 years ago

In GitLab by @yossarian on May 27, 2022, 21:58

Just looping back to say that I'm still seeing this, sadly, with other albums in my collection. Other Subsonic-style clients play the songs correctly.

Do you have any other tips for debugging this? I'm happy to contribute more time to it, I'm just a little stuck at the moment.