File obs-studio.spec of Package obs-studio
#
# spec file for package obs-studio
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define libdatachannel_src libdatachannel-0.20.2
# Using a current snapshot because releases are 2yr old.
%define QR_Code_generator_src QR-Code-generator-99f057910d0146ff1de07ad65a15ebb5ce527397
%define install_dir %{buildroot}/opt/obs-studio/
Name: obs-studio
Version: 30.1.2
Release: 0
Summary: Free and open source software for live streaming and screen recording
License: GPL-2.0-or-later
URL: https://obsproject.com/
Source0: %{name}-%{version}.tar.zst
Source1: %{libdatachannel_src}.tar.zst
Source2: %{QR_Code_generator_src}.tar.zst
Source3: obs-studio-bin.sh
Source4: %{name}.rpmlintrc
# Makes x264 optional for building and allows running OBS without libx264 present.
Patch1: obs-studio-disable-x264.patch
# Needed for unpacking sources
BuildRequires: zstd
BuildRequires: cmake
# git needed during build, see https://github.com/obsproject/obs-studio/issues/7705
BuildRequires: git
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: swig
BuildRequires: ffmpeg-6-libavcodec-devel
BuildRequires: ffmpeg-6-libavdevice-devel
BuildRequires: ffmpeg-6-libavformat-devel
BuildRequires: qt6-base-devel
BuildRequires: qt6-svg-devel
BuildRequires: qt6-gui-private-devel
BuildRequires: mbedtls-devel
BuildRequires: libXss-devel
BuildRequires: Mesa-devel
BuildRequires: pipewire-devel
BuildRequires: vlc-devel
BuildRequires: pciutils-devel
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(jansson)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(speexdsp)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(libv4l2)
BuildRequires: pkgconfig(xcomposite)
BuildRequires: pkgconfig(xinerama)
BuildRequires: pkgconfig(xrandr)
BuildRequires: pkgconfig(luajit)
BuildRequires: pkgconfig(python3)
BuildRequires: pkgconfig(freetype2)
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(jack)
BuildRequires: pkgconfig(vpl)
BuildRequires: pkgconfig(libva)
BuildRequires: pkgconfig(nlohmann_json)
BuildRequires: pkgconfig(librist)
BuildRequires: pkgconfig(srt)
BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(websocketpp)
BuildRequires: pkgconfig(asio)
# Dependency for bundled libdatachannel
BuildRequires: pkgconfig(gnutls)
# Needed to fix dynamic linking on obs-websocket
BuildRequires: patchelf
# Needed to replace duplicate files with soft/hard links
BuildRequires: fdupes
# Needed to properly install desktop file
BuildRequires: update-desktop-files
%description
OBS Studio is software designed for capturing, compositing, encoding, recording,
and streaming video content, efficiently.
%package devel
Summary: Development files for obs-studio
Requires: %{name} = %{version}
%description devel
OBS Studio is software designed for capturing, compositing, encoding, recording,
and streaming video content, efficiently. Development files.
%prep
%setup -q -a1 -a2
# Remove version from directory names
mv '%{libdatachannel_src}' libdatachannel
mv '%{QR_Code_generator_src}' QR-Code-generator
%autopatch -p1
%build
# Build libdatachannel, not available in Tumbleweed
cmake -S libdatachannel/ -B libdatachannel/build/ \
-DUSE_GNUTLS=1 \
-DUSE_MBEDTLS=0 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=libdatachannel/install-prefix/
make -C libdatachannel/build/ %{?_smp_mflags}
make -C libdatachannel/build/ install
# Build libqrcodegencpp. libqrcodegencpp1 is in Tumbleweed but without the
# -devel version that is needed here.
env CXXFLAGS='-fPIC' make -C QR-Code-generator/cpp/ qrcodegen.o
# Makefile doesn't have an option to build a shared library, build one manually.
gcc -shared -o QR-Code-generator/cpp/libqrcodegencpp.so QR-Code-generator/cpp/qrcodegen.o
# Build obs-studio
# cmake can't find luajit on its own and needs to be fed the includedir.
cmake -B build/ \
-DCMAKE_INSTALL_PREFIX=%{install_dir} \
-DCMAKE_BUILD_TYPE=Release \
-DLINUX_PORTABLE=ON \
-DBUILD_BROWSER=OFF \
-DENABLE_AJA=OFF \
-DENABLE_X264=OFF \
-DENABLE_JACK=ON \
-DLUAJIT_INCLUDE_DIR="$(pkg-config --variable=includedir luajit)" \
-DLibDataChannel_ROOT=libdatachannel/install-prefix/ \
-Dqrcodegencpp_INCLUDE_DIR=QR-Code-generator/cpp/ \
-DOBS_VERSION_OVERRIDE="$(echo "%{version}" | grep -oE "^[^+]+")" \
-Dqrcodegencpp_LIBRARY=QR-Code-generator/cpp/libqrcodegencpp.so
make -C build/ %{?_smp_mflags}
%install
make -C build/ install
# Copy the bundled shared libraries into the plugin directory so obs-studio can
# find them during runtime.
cp libdatachannel/install-prefix/lib64/libdatachannel.so* %{install_dir}/obs-plugins/64bit/
cp QR-Code-generator/cpp/libqrcodegencpp.so %{install_dir}/obs-plugins/64bit/
# Replace absolute shared library import path with a searchable one.
patchelf --replace-needed "$(pwd)/QR-Code-generator/cpp/libqrcodegencpp.so" \
libqrcodegencpp.so \
%{install_dir}/obs-plugins/64bit/obs-websocket.so
# Replace duplicate files with soft/hard links, makes rpmlint happy
# shared libraries, .so
%fdupes -s %{install_dir}/obs-plugins/
# svg and png
%fdupes %{install_dir}/data/obs-studio/themes/
# cmake files
%fdupes %{install_dir}/cmake/
# locales
%fdupes -s %{install_dir}/data/obs-plugins/
# Strip debugging symbols from binaries and libraries
find %{install_dir} -name '*.so*' -exec strip '{}' \;
strip %{install_dir}/bin/64bit/obs
strip %{install_dir}/bin/64bit/obs-ffmpeg-mux
# Fix pkgconfig paths, remove the RPM install prefix.
sed -i -e 's:%{buildroot}::' %{install_dir}/lib64/pkgconfig/libobs.pc
# obs-studio uses paths relative to the CWD when executed. A script is needed
# to change CWD to the obs-studio bin directory before executing obs-studio.
%{__install} -D -m0755 %{S:3} %{buildroot}%{_bindir}/obs-studio
%{__install} -D -m0644 \
UI/xdg-data/com.obsproject.Studio.desktop \
%{buildroot}/usr/share/applications/com.obsproject.obs-studio.desktop
sed -i -e 's:Exec=obs:Exec=obs-studio:' \
%{buildroot}/usr/share/applications/com.obsproject.obs-studio.desktop
%suse_update_desktop_file com.obsproject.obs-studio
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%license COPYING COMMITMENT
%doc README.rst CONTRIBUTING.rst COC.rst AUTHORS
%dir /opt/obs-studio/
/opt/obs-studio/bin/
/opt/obs-studio/data/
/opt/obs-studio/obs-plugins/
%{_bindir}/obs-studio
/usr/share/applications/com.obsproject.obs-studio.desktop
%files devel
/opt/obs-studio/cmake/
/opt/obs-studio/include/
/opt/obs-studio/lib64/
%changelog