• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

[Guide] How to get Apple Music working on Alma Linux 9(.1)

Jun 2, 2022
301 (0.62/day)
System Name Dell Latitude 7490 a.k.a. the poor man's NUC
Processor Intel Core i5-8250U 1.6 GHz quad core (3.4 GHz max boost)
Motherboard Dell proprietary
Cooling rather lousy
Video Card(s) Intel UHD 620
Storage internal Kioxia XG6 1 TB NVMe SSD
Display(s) HP P22h G4 21.5" 1080p (& 1080p internal LG Display LCD)
Case Dell proprietary magnesium case
Audio Device(s) Realtek ALC3246 -> JDS Labs Atom (headphone) amp -> Panasonic RP-HT770
Power Supply Dell-branded LiteOn AC adapter | worn BYD battery removed
Mouse Steelseries Rival 310
Keyboard Cherry G84-5200
Software Alma Linux 9.1
I decided to install Alma Linux 9 (specifically the latest 9.1) on my ProBook 645 G1. One of the reasons (won't get into the other ones in this thread) was that it already has Pipewire (turns out even installed and enabled by default; pulseaudio is not installed anymore), which means you can easily use applications that support/require Pulseaudio (or more specifically libpulse), including web browsers, without having to use the lousy Pulseaudio itself. This means that you can use the Apple Music web interface to stream music on Linux (I was using spotifyd before (with ALSA) when I had Spotify Premium). Unfortunately, due to software patent related legal issues (only applicable in the US and a handful of other countries) Alma Linux, like Fedora and other RHEL clones, does not come with an AAC decoder (or encoder or H.264 codec, for that matter), nor can you find one in the official repositories. However, Firefox (and I believe also Chromium) can use the ffmpeg library to decode patent encumbered multimedia formats, for which it has no built-in decoders. Of course, ffmpeg is not in the official repositories either but you can compile the latest version from source relatively easily and I had done so before to obtain a custom build with stuff that I deem unnecessary stripped out and support for additional features included.

First, a warning: Neither I nor TPU is responsible if you are located in the United States of America or another jurisdiction where software patents are recognized and you are sued by MPEG LA or any similar entity for not paying the required royalties for the use of patent encumbered codecs. This, however, is unlikely to happen if you are building ffmpeg strictly for personal use on a system that you do not intend to resell with ffmpeg. If you are in a jurisdiction where software patents are recognized and you wish to provide and/or utilize patent encumbered codecs on Linux with a guarantee of avoiding legal issues, I recommend that you research the Fluendo codec pack.

The information in this guide was sourced from Compile FFmpeg on CentOS, https://trac.ffmpeg.org/wiki/CompilationGuide/Generic and How-to: h264 etc. Support for Firefox (including ffmpeg install) and combined with my own knowledge/modifications. Without further ado:

  1. run
    dnf install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make pkgconfig zlib-devel pulseaudio-libs-devel fribidi-devel gnutls-devel
    as root to install the required dependencies that can be installed from the repositories. Some of these dependencies (and their related configure options) may not be strictly necessary but are recommended to install and enable just in case and may be very useful if you ever use the ffmpeg command line utility for other purposes.
  2. create a directory "ffmpeg_sources" in your home directory (the home directory of an unprivileged user)
  3. run
    cd ~/ffmpeg_sources
    curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2
    tar xvjf nasm-2.15.05.tar.bz2
    cd nasm-2.15.05
    ./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin"
    make install #with sudo or as root user using su command
  4. run
    cd ~/ffmpeg_sources
    curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
    tar xvzf yasm-1.3.0.tar.gz
    cd yasm-1.3.0
    ./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/local/bin"
    make install #with sudo or as root user using su command
  5. run
    cd ~/ffmpeg_sources
    curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
    tar xvjf ffmpeg-snapshot.tar.bz2
    cd ffmpeg
    ./configure \
    --prefix="/usr/local" \
    --enable-shared \
    --extra-libs=-lpthread \
    --extra-libs=-lm \
    --enable-gpl \
    --enable-libfreetype \
    --enable-libfribidi \
    --enable-libpulse \
    --enable-gnutls \
    make install #with sudo or as root user using su command
  6. finally, run
    echo /usr/local/lib >> /etc/ld.so.conf #as root using su command, or "sudo su" if the root account is disabled
    ldconfig #with sudo or as root user using (sudo) su command
    echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.config/firefox.conf #as root using su command, or "sudo su" if the root account is disabled
  7. Make sure to restart Firefox if it was already running so it will detect the ffmpeg (libavcodec) libraries. Firefox should suggest that you enable DRM-locked media playback in Preferences when you browse to Apple Music (or a similar streaming site). If it does not, do not forget to go to Preferences to enable it.
Since ffmpeg contains decoders (and even encoders, although of varying quality) for a great many of formats, this guide will not only be useful for streaming Apple Music but also for many other web applications/sites using a variety of audio and video formats. For example, you will not need Cisco's binary OpenH264 plugin anymore to watch H.264 videos (e.g. on YouTube and similar sites) and you will be able to listen to internet radio (e.g. TuneIn) that relies on HE-AAC. Furthermore, you can use the ffmpeg command line utility to convert or split files of many formats and even to capture internet audio streams over HTTPS/TLS thanks to the GNUTLS support we included. Bidirectional (mixed LTR (e.g. Latin script languages) and RTL (e.g. Arabic, Persian and Hebrew)) text (i.e. filenames) is supported thanks to the fribidi library support we included.

This guide has not been tested but should work on Rocky Linux and RHEL 9 as well.
Last edited: