Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Installing ffmpeg >=4 on CentOS 7 for Jellyfin

tl;dr

Fetched ffmpeg spec from Chinforpms pasture, fixed some rpm macros, compiled it, and installed it.

Overview

I use Jellyfin server on CentOS 7, which I install from a local yum repository after downloading the correct files from the upstream page. I recently upgraded from 10.7.6 to 10.8.9 and media playback broke for almost all video content.

The start

To start the process, I made a backup of the data after stopping jellyfin.

# systemctl stop jellyfin
# tar -C /var/lib -zcf /tmp/jellyfin.$( date "+%F" ).$( rpm -qf ).tgz jellyfin

Then I yum updated and started jellyfin.

The problem was indicated in the server logs (journalctl -n500 -f -u jellyfin): Jellyfin needs the path set for ffmpeg. That's slightly believable. I ensured I had /usr/bin/ffmpeg, and set that as the path in the web admin console, but the web ui indicated it could not find ffmpeg. The server logs indicated specifically that it could not find ffmpeg 4, so it was a version problem. I realize CentOS 7 is now 9 years old; vm4's hardware RAID controller does not have a driver for the Linux kernel used by RHEL8 and above, at least at the time I installed that system.

The search

Turns out rpmfusion only has ffmpeg version 3. I spent time looking for a way to get ffmpeg >= 4 on CentOS 7. I first investigated the famous negativo17 repository. I have used it in the past, with minor problems as some of the packages want to own the same files from other packages in the OS. negativo17's "epel-multimedia" repository has ffmpeg 5 in it!

I wanted to find another way to get ffmpeg without having to use that repository, if I could. I can use that repository if I have to. I checked another Fedora custom repackager that I follow, PhantomX, who did indeed package ffmpeg in the past! In fact, PhantomX had stopped about 3 years ago at version 4.2.2, which was perfect! This spec file needed only minor adjustments for rpm macros that do not exist in the version of rpm in CentOS 7 (PhantomX targets Fedora, and 3 years ago would have been Fedora 32 approximately), and thankfully all the dependencies were in rpmfusion or the base repositories.

So I manually built this ffmpeg 4 rpm on a CentOS 7 build node (I needed too), and then deployed the files to my local yum repository, and ran yum upgrade ffmpeg. And then I could set the path to the program in the Jellyfin web ui, and then my users can view videos again!

Details of spec file changes

--- ffmpeg.spec 2023-02-26 12:12:22.250386837 -0500
+++ ffmpeg.spec.new 2023-02-25 22:45:15.043571569 -0500
@@ -4,6 +4,15 @@
 #global date    20180419
 #global rel     rc1

+%define ldconfig_post(n:)  %{?ldconfig:%post -p %ldconfig %{?*} %{-n:-n %{-n*}}
+%end}
+%define ldconfig_postun(n:)   %{?ldconfig:%postun -p %ldconfig %{?*} %{-n:-n %{-n*}}
+%end}
+%define ldconfig_scriptlets(n:)  %{?ldconfig:
+%ldconfig_post %{?*} %{-n:-n %{-n*}}
+%ldconfig_postun %{?*} %{-n:-n %{-n*}}
+}
+
 # Cuda and others are only available on some arches
 %global cuda_arches x86_64

Conclusion

Probably eventually, I will need ffmpeg 5. Perhaps I just won't update Jellyfin again. It does exactly what I want already, and upgrading it now didn't even make anything better.

Additional thoughts

I needed to update my webhook template for new field names. Oh, and the app server needed to be restarted a few times to iterate through fetching the newer version of the webhook plugin, and enabling it, and using it, but it was painless.

Related files

All srpms and rpms in /mnt/public/www/internal/repo/rpm/jellyfin-ffmpeg/.

Comments