Almamu / linux-wallpaperengine

Wallpaper Engine backgrounds for Linux!
GNU General Public License v3.0
1.69k stars 61 forks source link

Cannot initialize SDL audio system, SDL_GetError: Mixer not built with MP3 support #83

Closed EchoEllet closed 2 years ago

EchoEllet commented 2 years ago

I'm trying to load wallpaper of wallpaper engine steam program I execute the following command ./wallengine /home/username/.local/share/Steam/steamapps/workshop/content/431960/1674972620

but I get this error:

Detected scene.pkg file at /home/1772346090/.local/share/Steam/steamapps/workshop/content/431960/1674972620/scene.pkg. Adding to list of searchable pathsCannot initialize SDL audio system, SDL_GetError: Mixer not built with MP3 support

mihawk90 commented 2 years ago

Can confirm the same here.

Compiled on Fedora 33 (yes I know it's EOL :see_no_evil: ), example background from README also without success:

[tarulia@localhost]/usr/bin/linux-wallpaperengine% ./wallengine /home/tarulia/Games/SteamLibrary/steamapps/workshop/content/431960/1845706469/
Detected scene.pkg file at /home/tarulia/Games/SteamLibrary/steamapps/workshop/content/431960/1845706469/scene.pkg. Adding to list of searchable paths
Cannot initialize SDL audio system, SDL_GetError: Mixer not built with MP3 support%

Window opens for a moment before it shuts down.

Running with --silent does fix the issue (obviously no audio then):

[tarulia@localhost]/usr/bin/linux-wallpaperengine% ./wallengine /home/tarulia/Games/SteamLibrary/steamapps/workshop/content/431960/1845706469/ --silent
Detected scene.pkg file at /home/tarulia/Games/SteamLibrary/steamapps/workshop/content/431960/1845706469/scene.pkg. Adding to list of searchable paths
[tarulia@localhost]/usr/bin/linux-wallpaperengine%

edit: also possible duplicate of #10

Almamu commented 2 years ago

I don't know why I thought SDLmixer initialization failing was a good reason to completely stop the process.

On 3ed1459568c97caf8e1869d21d6dd71e5e37255a I've added an error message so the background will run and display a warning in the console. I'm still not sure how to fix the issue on distros that do not ship mp3 support in SDLmixer, maybe a different library would be a better candidate? or is there any extra steps to enable mp3 support in SDLmixer?

mihawk90 commented 2 years ago

maybe a different library would be a better candidate

Aren't we already depending on ffmpeg anyway? Couldn't that be used? Maybe mp3 support in ffmpeg is more common among distro packages?

On Fedora at least ffmpeg comes with mp3 support (via RPM Fusion):

[tarulia@localhost]~% ffmpeg -codecs | grep mp3
 DEAIL. mp3                  MP3 (MPEG audio layer 3) (decoders: mp3float mp3 ) (encoders: libmp3lame )
mihawk90 commented 2 years ago

or is there any extra steps to enable mp3 support in SDLmixer?

OK so... I did some digging because I was curious.

TL;DR: Currently not possible to build SDL_mixer with mp3 support on Fedora because of a missing lib.


Long version:

If Stackoverflow is to be believed, in order to get MP3 support, SDL_mixer needs to be built with libmpg123 headers available:

https://stackoverflow.com/questions/55442738/sdl-mixer-2-0-4-mp3-support-not-available-even-though-libmpg123-is-installed

Unfortunately the documentation on SDL_mixer is frankly :hankey: so I can't verify whether that is true or not. However, in SDL_mixer's configure there are various flags that can be supplied regarding mp3:

https://github.com/libsdl-org/SDL_mixer/blob/c238c1b2dd6107367b1de579e2efd5b54a9a97fb/configure#L939-L943

Which ones should be used in which situation is anyone's guess, since again I can't find anything on their documentation.

Regardless, I checked the Fedora RPM spec of SDL_mixer, and from what I can tell they don't enable mp3 support explicitely and neither do they provide libmpg123 as a Build-dependency:

https://src.fedoraproject.org/rpms/SDL_mixer/blob/rawhide/f/SDL_mixer.spec

So I went ahead and built that spec locally, and - surprise surprise - no MP3 support:

[...]
checking for smpeg-config... no
checking for SMPEG - version >= 0.4.3... no
*** The smpeg-config script installed by SMPEG could not be found
*** If SMPEG was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the SMPEG_CONFIG environment variable to the
*** full path to smpeg-config.
configure: WARNING: *** Unable to find SMPEG library (http://icculus.org/smpeg/)
configure: WARNING: MP3 support disabled
configure: creating ./config.status
config.status: executing libtool commands
configure: creating ./config.status
config.status: creating Makefile
config.status: creating SDL_mixer.spec
config.status: creating SDL_mixer.qpg
config.status: creating SDL_mixer.pc
config.status: executing libtool commands
config.status: executing default commands

The fact that it is referring to SMPEG also made me realise that for some reason Fedora packages 1.2.12 of SDL_mixer, which is based off a commit from 2012: https://github.com/libsdl-org/SDL_mixer/tree/release-1.2.12

Can't find an explanation on that on the RedHat bugtracker either.

Anyway, it seems the 1.2.12 configure is looking for smpeg.h among others (which makes sense), but unfortunately no package on Fedora seems to provide that file:

[tarulia@localhost]~/Development/SDL_mixer.spec% dnf provides smpeg.h
Last metadata expiration check: 0:58:46 ago on Wed 06 Apr 2022 15:46:34 CEST.
Error: No Matches found

So long story short, it's currently impossible to build an mp3-enabled SDL_mixer on Fedora.

I'm going to file a bug on the RedHat bugzilla and ask for a recent version of SDL_mixer (or a second package akin to Python), or provide an explanation for why it has never been updated (license issues or otherwise).

edit: For reference, the RedHat bug is filed under 2072596. We'll see what comes back. If they update the package, we'll see how mp3-support will work out.

mihawk90 commented 2 years ago

Already got a response on the bug report, well turns out I'm just stupid and there is already an SDL2 package :roll_eyes:

So I tried building with that, but CMake can't find the SDL libs:

[...]
-- Found Threads: TRUE  
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindSDL.cmake:216 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:17 (find_package)

-- Configuring incomplete, errors occurred!
See also "/builddir/build/BUILD/linux-wallpaperengine/build/CMakeFiles/CMakeOutput.log".
See also "/builddir/build/BUILD/linux-wallpaperengine/build/CMakeFiles/CMakeError.log".
error: Bad exit status from /var/tmp/rpm-tmp.Bo5QZs (%build)
    Bad exit status from /var/tmp/rpm-tmp.Bo5QZs (%build)

So that makes me wonder are you using SDL 1.x or 2.x as a dependency? I guess 1 judging by it not finding the SDL2 lib?

Almamu commented 2 years ago

It should be using SDL1 as I also require the normal SDL library, as far as I know SDL2 packages have to start with "SDL2", mainly because there's a lot of software that relies on SDL1 being there.

The issue with using ffmpeg to play audio is that it only takes care of decoding the audio (as far as I know at least), and I do not have any experience with audio play on linux. I only know of OpenAL but I haven't really used it for anything yet...

mihawk90 commented 2 years ago

It should be using SDL1 as I also require the normal SDL library

Mh OK that's what I thought. So I imagine Debian has the same issue where the SMPEG library isn't available so SDL_Mixer can't be compiled with it.

The issue with using ffmpeg to play audio is that it only takes care of decoding the audio (as far as I know at least)

Sounds about right, although ffplay is also part of ffmpeg, maybe that could be used?

Almamu commented 2 years ago

I'll take a look into ffplay because, being honest, I completely forgot about it.

Almamu commented 2 years ago

Looks like ffplay uses SDL2 so It should be fairly trivial to extract the audio-playing part of the code and implement it myself. For now looks like a promising option, so I'll keep looking into it.

EchoEllet commented 2 years ago

Looks like ffplay uses SDL2 so It should be fairly trivial to extract the audio-playing part of the code and implement it myself. For now looks like a promising option, so I'll keep looking into it.

Thank you very much for solving the bug, I tried to set the wallpaper as background using --screen-root but it didn't work and nothing change, you say "Only screens configured with the XRandr extension are supported" but I'm not sure how to configure my screen with xrandr in order to support Running as a screen's background

Almamu commented 2 years ago

Most distros using Xserver should automatically handle that for you through the settings app.

The main issue why --screen-root fails is most likely the desktop environment you're using. Some of them like to draw over the Xserver background, covering what this software draws.

Almamu commented 2 years ago

If there's any issue with the new audio playing code please feel free to open a new issue with the specific error.

mihawk90 commented 2 years ago

Works perfectly for at least all these:

z% wallengine --fps 30 ~/.local/share/Steam/steamapps/workshop/content/431960/
Completing file
1391033800/  1845706469/  1883921173/  2274845251/  2429324929/  2787033447/  2788420872/

So nice one :+1: