Introduction
Let's get the maximum performance and install ImageMagick
and ffmpeg
on Gentoo.
I will use WSL
for demo, hence some functionalities will be limited.
Setup Gentoo
Let's get the latest stage3
tarball from the Gentoo Downloads
powershell:
Invoke-WebRequest -Uri "https://distfiles.gentoo.org/releases/amd64/autobuilds/20241027T164832Z/stage3-amd64-openrc-20241027T164832Z.tar.xz" -OutFile "$env:USERPROFILE\Downloads\stage3-amd64-openrc-20241027T164832Z.tar.xz"
mkdir "$env:LOCALAPPDATA\WSL\Gentoo" -Force
wsl --import Gentoo "$env:LOCALAPPDATA\WSL\Gentoo" "$env:USERPROFILE\Downloads\stage3-amd64-openrc-20241027T164832Z.tar.xz"
Let's enter Gentoo:
wsl -d Gentoo
Follow the Gentoo in WSL to setup a user! I will skip this part and will continue with root
(not secure).
Hi ChatGPT, could you please suggest the compiler flags and USE flags for Gentoo to have the maximum performance, my use case is ffmpeg with HEVC and ImageMagick with HEIC. Short answer, thank you !
Now let's set compiler and USE flags, I have entered as root
:
cat /etc/portage/make.conf
A bit of magic:
echo -e "COMMON_FLAGS=\"-O2 -pipe\"\nCFLAGS=\"-march=native \${COMMON_FLAGS}\"\nCXXFLAGS=\"\${CFLAGS}\"\nFCFLAGS=\"\${COMMON_FLAGS}\"\nFFLAGS=\"\${COMMON_FLAGS}\"\nLC_MESSAGES=C.utf8" | tee /etc/portage/make.conf > /dev/null
Setting USE
flags:
echo 'USE="ffmpeg hevc imagemagick heic x264 vaapi vdpau opencl threads jpeg png tiff gpl libx264 libx265 libfdk-aac libmp3lame libopus libvpx nonfree"' | tee -a /etc/portage/make.conf > /dev/null
echo "media-gfx/imagemagick heic libheif" | tee /etc/portage/package.use/imagemagick > /dev/null
echo "media-video/ffmpeg gpl libx264 libx265 libfdk-aac libmp3lame libopus libvpx nonfree" | tee /etc/portage/package.use/ffmpeg > /dev/null
Let's sync and update, at this point you will likely embrace the philosophy of Gentoo
:
emerge --sync
emerge --update --deep --newuse @world
emerge --depclean
emerge dev-vcs/git
At this point we have a media server, let's pack it.
ImageMagick on Gentoo
With the USE
flags set from the setup:
emerge media-libs/libheif media-libs/libpng gnome-base/librsvg
git clone https://github.com/ImageMagick/ImageMagick.git
cd ImageMagick
./configure --with-heic=yes
make
make install
ldconfig
magick -list format | grep HEIC
ffmpeg on Gentoo
With the USE
flags set from the setup:
emerge media-libs/x264 media-libs/x265 media-libs/fdk-aac media-sound/lame media-libs/opus media-libs/libvpx
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libvpx --enable-nonfree
make
make install
ffmpeg -codecs | grep hevc
Final step
It is the time you have wasted for your Gentoo that makes your Gentoo so important.
Let's add new user:
useradd -m -G users -s /bin/bash <username>
passwd <username>
And reboot Gentoo, now you can enter as <username>
:
wsl -u <username> -d Gentoo
Summary
If you are afraid to use Gentoo
, come back when you are not afraid or use it while being afraid.
Top comments (1)
This is a great guide! I'm interested in trying this out on my own Gentoo system. I especially appreciate the detailed steps for configuring the compiler flags and USE flags. I'm sure it will be a huge performance boost for my media processing.