go-mp3
go-mp3 copied to clipboard
Audio distortion on playback of lower bitrate files
I'm working on a toy resource-viewer for a well known game and I have a set of mp3s (BGM) that I'm trying to play using go-mp3
+ oto
which all have audible distortion. ffplay
is able to play them all just fine.
I'm running on MacOS Catalina (10.15.6).
ffmpeg -i 01.mp3
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.3 (clang-1103.0.32.62)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mp3, from '01.mp3':
Metadata:
encoder : Lavf58.45.100
Duration: 00:01:14.66, start: 0.023991, bitrate: 80 kb/s
Stream #0:0: Audio: mp3, 22050 Hz, stereo, fltp, 80 kb/s
It plays fine when I re-encoded it with libmp3lame
at a higher bitrate via: fmpeg -i 01.mp3 -codec:a libmp3lame -qscale:a 2 output.mp3
, and re-encoding (with libmp3lame
again) it again at a low bitrate causes the issues to reappear.
Relevant playback code on my side:
...
d, err := mp3.NewDecoder(bytes.NewBuffer(b))
if err != nil {
return err
}
c, err := oto.NewContext(d.SampleRate(), 2, 2, 4096)
if err != nil {
return err
}
...
Any tips on what the issue might be given that these play fine on other mp3 players? Tuning the sample rate and buffer size in bytes parameters have not helped.
I've uploaded the file here if you'd like to take a look.
Ah - this might be because MPEG2 is not fully supported yet, per the description in: https://github.com/hajimehoshi/go-mp3/pull/35
Just an update: it might be stereo intensity related per the above PR description and some very light debug logging that I added. I'll see if I can figure out how to fix it
Hey any news on this? There are still distortions when playing lower frequency files. Re-encoding to 44100 works perfectly but I was hoping for low frequency support too.