Skip to content

Instantly share code, notes, and snippets.

@Kusmeroglu
Last active January 21, 2022 23:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Kusmeroglu/ef81c4f96369f890fcdc0616652430ad to your computer and use it in GitHub Desktop.
Save Kusmeroglu/ef81c4f96369f890fcdc0616652430ad to your computer and use it in GitHub Desktop.
Notes on Installing SRT with OBS on Ubuntu / Debian / Linux

Notes on Installing SRT with OBS on Ubuntu / Debian / Linux

Feedback welcomed - if this becomes old or contains misleading information please let me know.

OBS provides some instructions on how to get SRT, but I found that they didn't quite work for me on a fresh minimal install of Ubuntu 20 (Focal). OBS on linux doesn't appear to come with SRT support out of the box.

The OBS Discord community was really helpful, but in the end it took a lot of futzing and following are my notes, in case this is helpful to anyone else.

By the way, if you are considering SRT with OBS, it was extremely painful to install correctly, but then it worked beautifully. The error correction SRT provides was very nice when my wireless signal was poor.

Install Instructions

Disclaimer! These are not tested on a fresh install as presented (I ended up doing a lot of reinstalls and I'm sure I have missed or duplicated instructions).

Disclaimer 2! I wrote this almost 2 months after solving it, so my memory is a bit fuzzy.

I'll loosely base my ffmpeg build off of these directions official ffmpeg wiki and a blogpost and this book

The official compilation guide makes some folders in your home dir, ffmpeg_sources and ffmpeg_build. The idea here was to keep it clean, so it doesn't disrupt the rest of the system, which I abandoned toward the end of my struggle. I didn't care about messing up the rest of my system as it was a dedicated install for streaming SRT.

Install and build SRT

You'll need the libsrt library, which you can build following their instructions, but that will conflict with how ffmpeg styles their instructions, so we change it up a bit. Notice the shared libraries settings.

sudo apt-get install libssl-dev git cmake
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone --depth 1 https://github.com/Haivision/srt.git
mkdir srt/build
cd ~/ffmpeg_sources/srt/build && \
cmake -DENABLE_C_DEPS=ON -DENABLE_SHARED=ON -DENABLE_STATIC=OFF -fPIC .. && \
make && \
make install

Install a bunch of ffmpeg dependencies

This list is smaller than your average ffmpeg dependency list, but I literally only cared about what I thought was the minimum to test SRT and OBS.

sudo apt-get update -qq && sudo apt-get -y install \
  autoconf \
  automake \
  build-essential \
  cmake \
  git-core \
  libass-dev \
  libfreetype6-dev \
  libgnutls28-dev \
  libsdl2-dev \
  libtool \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  pkg-config \
  texinfo \
  wget \
  yasm \
  zlib1g-dev \
  libx264-dev \
  libx265-dev \
  libnuma-dev \
  libfdk-aac-dev \
  libmp3lame-dev

Build ffmpeg from scratch

Notice the --enable-libsrt and --enable-protocol=libsrt lines. Also, --enable-shared was important, and getting the cflags and ldflags correct was what I spent the most time on.

cd ~/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2
cd ~/ffmpeg_sources/ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix=/usr \
            --enable-gpl         \
            --enable-version3    \
            --enable-nonfree     \
            --disable-static     \
            --enable-shared      \
            --disable-debug      \
            --enable-avresample  \
            --enable-libfdk-aac  \
            --enable-libfreetype \
            --enable-libx264     \
            --enable-libx265     \
            --enable-protocol=libsrt \
            --enable-libsrt && \
make && \
make install && \
hash -r

sudo checkinstall -y --deldoc=yes

My notes include running ldconfig at this point.

sudo ldconfig

Install OBS Dependencies and build OBS

Maybe you can get away with the above and installing OBS from a package, but if not, these were the commands I used to build OBS based on the official instructions.

cd ~
git clone --recursive https://github.com/obsproject/obs-studio.git
cd obs-studio
mkdir build && cd build
cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo checkinstall --default --pkgname=obs-studio --fstrans=no --backup=no --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes

Troubleshooting

A big part of the challenge of all of this was not accidentally installing ffmpeg from a package, and the other part was getting libraries compiled with the correct sharing and flags so that ffmpeg would see the srt library and OBS would be using the same set of libraries.

Basic ffmpeg support troubleshooting is ffmpeg -protocols. If libsrt isn't there, you aren't getting anywhere.

The most helpful thing in this whole process was using ldd to determine what libraries (and where) ffmpeg and OBS were using. At times, I broke down and copied .so files places. I'm not sure if that helped, and I'm almost positive it was a terrible idea, but it took me a very long time and trying many many things to get this working and desperation had set in.

First find out where your ffmpeg lives with which -a, then plug that into ldd. (Also, if you have two ffmpegs listed, you may have already lost.) The goal is to get ffmpeg and OBS using the same set of libav* libraries.

Working system artifacts

So, with everything working, this is what I ended up with. I hope you can compare your own install and hopefully see something that gives you a clue.

ldd on ffmpeg

Full results afterwards, but I found it helpful to grep for what I was looking for:

$ ldd /usr/bin/ffmpeg | grep libav
	libavdevice.so.58 => /lib/libavdevice.so.58 (0x00007f43a1472000)
	libavfilter.so.7 => /lib/libavfilter.so.7 (0x00007f43a10d7000)
	libavformat.so.58 => /lib/libavformat.so.58 (0x00007f43a0e75000)
	libavcodec.so.58 => /lib/libavcodec.so.58 (0x00007f439f95a000)
	libavresample.so.4 => /lib/libavresample.so.4 (0x00007f439f939000)
	libavutil.so.56 => /lib/libavutil.so.56 (0x00007f439f5a2000)
$ ldd /usr/bin/ffmpeg | grep libsrt
	libsrt.so.1 => /usr/local/lib/libsrt.so.1 (0x00007fe7e875b000)
$ which ffmpeg
/usr/bin/ffmpeg
$ ldd /usr/bin/ffmpeg
	linux-vdso.so.1 (0x00007ffeaa1e2000)
	libavdevice.so.58 => /lib/libavdevice.so.58 (0x00007f57ba0bf000)
	libavfilter.so.7 => /lib/libavfilter.so.7 (0x00007f57b9d24000)
	libavformat.so.58 => /lib/libavformat.so.58 (0x00007f57b9ac2000)
	libavcodec.so.58 => /lib/libavcodec.so.58 (0x00007f57b85a7000)
	libavresample.so.4 => /lib/libavresample.so.4 (0x00007f57b8586000)
	libpostproc.so.55 => /lib/x86_64-linux-gnu/libpostproc.so.55 (0x00007f57b8564000)
	libswresample.so.3 => /lib/x86_64-linux-gnu/libswresample.so.3 (0x00007f57b8540000)
	libswscale.so.5 => /lib/x86_64-linux-gnu/libswscale.so.5 (0x00007f57b84ab000)
	libavutil.so.56 => /lib/libavutil.so.56 (0x00007f57b81ef000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f57b80a0000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f57b807d000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57b7e8b000)
	libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f57b7e5f000)
	libxcb-shape.so.0 => /lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007f57b7e5a000)
	libxcb-xfixes.so.0 => /lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007f57b7e50000)
	libasound.so.2 => /lib/x86_64-linux-gnu/libasound.so.2 (0x00007f57b7d59000)
	libSDL2-2.0.so.0 => /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (0x00007f57b7c04000)
	libsndio.so.7.0 => /lib/x86_64-linux-gnu/libsndio.so.7.0 (0x00007f57b7bf3000)
	libXv.so.1 => /lib/x86_64-linux-gnu/libXv.so.1 (0x00007f57b79ec000)
	libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f57b78af000)
	libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f57b789a000)
	libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f57b77db000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f57b77bf000)
	libsrt.so.1 => /usr/local/lib/libsrt.so.1 (0x00007f57b76e4000)
	libfdk-aac.so.1 => /lib/x86_64-linux-gnu/libfdk-aac.so.1 (0x00007f57b7424000)
	libx264.so.155 => /lib/x86_64-linux-gnu/libx264.so.155 (0x00007f57b7166000)
	libx265.so.179 => /lib/x86_64-linux-gnu/libx265.so.179 (0x00007f57b61f8000)
	libsoxr.so.0 => /lib/x86_64-linux-gnu/libsoxr.so.0 (0x00007f57b618d000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f57ba139000)
	libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f57b6187000)
	libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f57b617d000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57b6177000)
	libpulse.so.0 => /lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f57b6122000)
	libXcursor.so.1 => /lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f57b6115000)
	libXinerama.so.1 => /lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f57b6110000)
	libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007f57b60fe000)
	libXrandr.so.2 => /lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f57b60ef000)
	libXss.so.1 => /lib/x86_64-linux-gnu/libXss.so.1 (0x00007f57b60ea000)
	libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f57b60e3000)
	libwayland-egl.so.1 => /lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f57b60de000)
	libwayland-client.so.0 => /lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f57b60cd000)
	libwayland-cursor.so.0 => /lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f57b60c2000)
	libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f57b607e000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f57b6073000)
	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f57b6059000)
	libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f57b6021000)
	libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f57b5d4b000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f57b5b68000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f57b5b4d000)
	libnuma.so.1 => /lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f57b5b40000)
	libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f57b5afe000)
	libpulsecommon-13.99.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-13.99.so (0x00007f57b5a7e000)
	libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f57b5a2b000)
	libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f57b5821000)
	libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f57b5819000)
	libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f57b580d000)
	libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f57b5760000)
	libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f57b5752000)
	libsndfile.so.1 => /lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f57b56d5000)
	libasyncns.so.0 => /lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f57b54cf000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f57b54a8000)
	liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f57b5487000)
	libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f57b5369000)
	libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f57b534a000)
	libFLAC.so.8 => /lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f57b530c000)
	libogg.so.0 => /lib/x86_64-linux-gnu/libogg.so.0 (0x00007f57b52ff000)
	libvorbis.so.0 => /lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f57b52d1000)
	libvorbisenc.so.2 => /lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f57b5226000)
	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f57b520a000)
	libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f57b51e5000)

ldd on OBS

$ ldd /usr/bin/obs
	linux-vdso.so.1 (0x00007fff17f43000)
	libQt5Svg.so.5 => /lib/x86_64-linux-gnu/libQt5Svg.so.5 (0x00007f49a122d000)
	libQt5Xml.so.5 => /lib/x86_64-linux-gnu/libQt5Xml.so.5 (0x00007f49a11eb000)
	libobs-frontend-api.so.0 => /lib/libobs-frontend-api.so.0 (0x00007f49a11e3000)
	libavcodec.so.58 => /lib/libavcodec.so.58 (0x00007f499fcc8000)
	libavutil.so.56 => /lib/libavutil.so.56 (0x00007f499fa0c000)
	libavformat.so.58 => /lib/libavformat.so.58 (0x00007f499f7aa000)
	libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f499f717000)
	libQt5X11Extras.so.5 => /lib/x86_64-linux-gnu/libQt5X11Extras.so.5 (0x00007f499f710000)
	libQt5Widgets.so.5 => /lib/x86_64-linux-gnu/libQt5Widgets.so.5 (0x00007f499f075000)
	libobs.so.0 => /lib/libobs.so.0 (0x00007f499ef98000)
	libQt5Gui.so.5 => /lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f499e9ad000)
	libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f499e464000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f499e281000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f499e132000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f499e117000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f499e0f4000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f499df02000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f49a1526000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f499dee6000)
	libswresample.so.3 => /lib/x86_64-linux-gnu/libswresample.so.3 (0x00007f499dec2000)
	libfdk-aac.so.1 => /lib/x86_64-linux-gnu/libfdk-aac.so.1 (0x00007f499dc04000)
	libx264.so.155 => /lib/x86_64-linux-gnu/libx264.so.155 (0x00007f499d946000)
	libx265.so.179 => /lib/x86_64-linux-gnu/libx265.so.179 (0x00007f499c9d8000)
	libsrt.so.1 => /usr/local/lib/libsrt.so.1 (0x00007f499c8fd000)
	libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f499c8d4000)
	libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f499c8b1000)
	librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f499c891000)
	libssh.so.4 => /lib/x86_64-linux-gnu/libssh.so.4 (0x00007f499c823000)
	libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f499c810000)
	libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f499c77d000)
	libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f499c4a7000)
	libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f499c458000)
	libldap_r-2.4.so.2 => /lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f499c402000)
	liblber-2.4.so.2 => /lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f499c3f1000)
	libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f499c3e2000)
	libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f499c391000)
	libX11-xcb.so.1 => /lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f499c38a000)
	libpulse.so.0 => /lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f499c335000)
	libjansson.so.4 => /lib/x86_64-linux-gnu/libjansson.so.4 (0x00007f499c326000)
	libswscale.so.5 => /lib/x86_64-linux-gnu/libswscale.so.5 (0x00007f499c291000)
	libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f499c209000)
	libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f499c1d1000)
	libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f499c0ca000)
	libicui18n.so.66 => /lib/x86_64-linux-gnu/libicui18n.so.66 (0x00007f499bdcb000)
	libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f499bbe5000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f499bbdf000)
	libpcre2-16.so.0 => /lib/x86_64-linux-gnu/libpcre2-16.so.0 (0x00007f499bb5c000)
	libdouble-conversion.so.3 => /lib/x86_64-linux-gnu/libdouble-conversion.so.3 (0x00007f499bb46000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f499ba1b000)
	libsoxr.so.0 => /lib/x86_64-linux-gnu/libsoxr.so.0 (0x00007f499b9b0000)
	libnuma.so.1 => /lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f499b9a3000)
	libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f499b821000)
	libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f499b64b000)
	libhogweed.so.5 => /lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007f499b611000)
	libnettle.so.7 => /lib/x86_64-linux-gnu/libnettle.so.7 (0x00007f499b5d7000)
	libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f499b553000)
	libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f499b476000)
	libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f499b445000)
	libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f499b43c000)
	libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f499b42d000)
	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f499b411000)
	libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f499b3f4000)
	libgssapi.so.3 => /lib/x86_64-linux-gnu/libgssapi.so.3 (0x00007f499b3af000)
	libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f499b38c000)
	libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f499b2dd000)
	libpulsecommon-13.99.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-13.99.so (0x00007f499b25d000)
	libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f499b1a5000)
	libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f499b171000)
	libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f499b0b2000)
	libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f499b085000)
	libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f49995c2000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f499954f000)
	libgomp.so.1 => /lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f499950d000)
	libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f49993d7000)
	libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f49993c1000)
	libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f49993b8000)
	libheimntlm.so.0 => /lib/x86_64-linux-gnu/libheimntlm.so.0 (0x00007f49993ac000)
	libkrb5.so.26 => /lib/x86_64-linux-gnu/libkrb5.so.26 (0x00007f4999319000)
	libasn1.so.8 => /lib/x86_64-linux-gnu/libasn1.so.8 (0x00007f4999272000)
	libhcrypto.so.4 => /lib/x86_64-linux-gnu/libhcrypto.so.4 (0x00007f499923a000)
	libroken.so.18 => /lib/x86_64-linux-gnu/libroken.so.18 (0x00007f499921f000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f4999214000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f49991ed000)
	liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f49991cc000)
	libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f49990ae000)
	libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f4999084000)
	libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f4999078000)
	libsndfile.so.1 => /lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f4998ff9000)
	libasyncns.so.0 => /lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f4998df3000)
	libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f4998cb6000)
	libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f4998caa000)
	libwind.so.0 => /lib/x86_64-linux-gnu/libwind.so.0 (0x00007f4998c80000)
	libheimbase.so.1 => /lib/x86_64-linux-gnu/libheimbase.so.1 (0x00007f4998c6c000)
	libhx509.so.5 => /lib/x86_64-linux-gnu/libhx509.so.5 (0x00007f4998c1e000)
	libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f4998af5000)
	libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f4998aba000)
	libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f4998a97000)
	libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f4998a8f000)
	libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f4998a87000)
	libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f4998a6a000)
	libFLAC.so.8 => /lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f4998a2c000)
	libogg.so.0 => /lib/x86_64-linux-gnu/libogg.so.0 (0x00007f4998a1f000)
	libvorbis.so.0 => /lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f49989f1000)
	libvorbisenc.so.2 => /lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f4998944000)
	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f499892a000)
@OscarParzon
Copy link

Hi. I came from reading your answer on the OBS forum, thanks for that!
I quickly read this post. I already have a machine ready and with an empty disk to test the case this afternoon.
Thank you very much for your contribution.

@OscarParzon
Copy link

OscarParzon commented Jul 24, 2020

Okay. for whoever comes behind in the same attempt:

Build ffmpeg error in make:

"make: *** [ffbuild / common.mak: 67: libavformat / libsrt.o] Error 1"
paste output as is:

libavformat/libsrt.c: In function ‘libsrt_set_options_pre’:
libavformat/libsrt.c:317:66: error: ‘SRTO_STRICTENC’ undeclared (first use in this function); did you mean ‘SRTO_STATE’?
317 | (s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_STRICTENC, "SRTO_STRICTENC", &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) ||
| ^~~~~~~~~~~~~~
| SRTO_STATE
libavformat/libsrt.c:317:66: note: each undeclared identifier is reported only once for each function it appears in
libavformat/libsrt.c:336:50: error: ‘SRTO_SMOOTHER’ undeclared (first use in this function); did you mean ‘SRTO_SENDER’?
336 | (s->smoother && libsrt_setsockopt(h, fd, SRTO_SMOOTHER, "SRTO_SMOOTHER", s->smoother, strlen(s->smoother)) < 0) ||
| ^~~~~~~~~~~~~
| SRTO_SENDER
libavformat/libsrt.c: In function ‘libsrt_setup’:
libavformat/libsrt.c:409:5: warning: ‘srt_socket’ is deprecated [-Wdeprecated-declarations]
409 | fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0);
| ^~
In file included from libavformat/libsrt.c:24:
/usr/local/include/srt/srt.h:723:41: note: declared here
723 | SRT_ATR_DEPRECATED_PX SRT_API SRTSOCKET srt_socket(int, int, int) SRT_ATR_DEPRECATED;
| ^~~~~~~~~~
make: *** [ffbuild/common.mak:67: libavformat/libsrt.o] Error 1


doing research...

@Kusmeroglu
Copy link
Author

Hmm, is it finding the srt library? It looks like it sees an srt header, but I'm not sure if that's the whole picture.

@OscarParzon
Copy link

OscarParzon commented Jul 24, 2020

I have it compiled in another machine! In a very dirty and bad installation! Ja!
I'm trying to do a clean install to compile OBS.
I found this tip on Haivision:

Haivision/srt#1413

even without solution. the same error in all versions.

@OscarParzon
Copy link

Hello !.

Regarding the compilation error:
It seems that there is a change in the last SRT code that does not let make compile the last FFmpeg code.

While FFmpeg and / or SRT fix it:
Tests with SRT 1.4.0 and FFmpeg 4.2.2 compile without error.

I still have to compile OBS. Then I comment.

Regarding your help, only two nonsense: "make install" needs "sudo", and, in my case, I had to install "checkinstall".

Tested to install FFmpeg 4.2.2 on "Ubuntu 20.04.1 LTS" (basic installation).

Thank you very much for your help.!!!

@OscarParzon
Copy link

OscarParzon commented Jul 27, 2020

Another comment. Just to clarify.

In the comment above note that FFmpeg compiled without error. I soon discovered that SRT was not working!

$ ffmpeg -protocols
...
srt He was not.
...

After a few laps I reviewed my notes on my previous installation and the SRT orders were somewhat different:

cd ~/ffmpeg_sources/srt/

$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

and

$ ffmpeg -protocols
...
srt (ok !!)

then ffmpeg correctly transmitted srt to my server.

now it remains to try to compile OBS !.

@OscarParzon
Copy link

Listo. OBS Tx sobre SRT.
Gracias !.

@Kusmeroglu
Copy link
Author

Yay! 🎊 🎉 I'm so glad that you got it working! Thanks for adding your notes here, hopefully that helps others going through the same process.

@harfinch
Copy link

Any update to these instructions?

I seemed to have managed to muck things up very much. Now I can't compile ffmpeg

./ffmpeg: symbol lookup error: ./ffmpeg: undefined symbol: av_opt_child_class_iterate, version LIBAVUTIL_56

Could they make ffmpeg any more of a pain to compile?

@harfinch
Copy link

I think I've been able to figure this out. I'll try to give a walk through as to what I did to get this to work.

For what it's worth - my end goal was to create a completely separate copy of OBS that would work with SRT. Since the Ubuntu and OBS provided OBS does not come with SRT support built-in, I did not really want to mess with overwriting any system-level binaries or libraries. My purpose was to create an OBS that has SRT but also allowing me to fall back to the Ubuntu and OBS provided OBS should problem arise. Your end goal may be different.

To that end... I want to avoid using sudo make install (or running make install as root). The reason being, I don't want to install system level binaries or libraries that may otherwise interfere with other operations. For example: I use kdenlive for video editing. Well, apparently in some of my patch-work meddling with this, I installed a version of ffmpeg and it's libraries in /usr/local - Now the argument can be made that I did not compile ffmpeg with a full list of directives and that's certainly a possibility. But the end result was, kdenlive could no longer render MP4 files. This was because kdenlive was looking for dynamic libraries in /usr/local/lib and it found some, but it did not necessarily pertain to the FFMPEG that kdenlive was linking to. Ultimately, moving /usr/local/lib out of the way and reinstalling the Ubuntu provided ffmpeg resolved all of this.

The point I'm trying to make in all of this - be very careful when using sudo make install (or running make install as root), because you're probably telling the compiled application or library to install itself in a system-level folder. If the application has a distro-provided version (i.e. ffmpeg) then this may interfere with other applications that depend on this distro-provided. The system of least privileges generally comes into play with this. Since I only need this specific version of OBS for a specific reason, installing it at the system-level doesn't make a lot of sense to me.

Now installing distro-provided packages (i.e. with apt-get) requires sudo and this is reasonable. Unless a library or application isn't provided by the distribution you are using, then I would encourage you to avoid installing (with sudo make install) it within the system directories (i.e., probably anything under /usr).

This is just my opinion - but hopefully helps paint a picture of why I'm doing what I'm doing.

Another note - I'm assuming that any home directory for any user is in /home - now it's possible that your user's home directories may be in something other that /home - maybe /home2 or something. If that's the case then you may have to adjust the absolute paths accordingly. The environment variable ${HOME} will always refer to the current user's home directory regardless of it's absolute path.

To begin with - Ubuntu 20 has a libsrt install candidate within it's repository. So compiling libsrt is not necessary. To begin you are going to need to install the dependencies needed for an ffmpeg compile. This list may vary depending on exactly what you are compiling in with FFMPEG, but this is what I used:

sudo apt-get install libavutil-dev libcurl4-openssl-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libgl1-mesa-dev libjack-jackd2-dev libjansson-dev libluajit-5.1-dev libpulse-dev libqt5x11extras5-dev libspeexdsp-dev libswresample-dev libswscale-dev libudev-dev libv4l-dev libvlc-dev libx11-dev libx264-dev libxcb-shm0-dev libxcb-xinerama0-dev libxcomposite-dev libxinerama-dev pkg-config python3-dev qtbase5-dev libqt5svg5-dev swig libxcb-randr0-dev libxcb-xfixes0-dev libx11-xcb-dev libxcb1-dev nasm yasm libpng-dev librtmp-dev libssh-dev libsrt-dev libx265-dev libmbedtls-dev zlib1g-dev

Now, one thing you might want to consider doing is creating a completely new user just to handle the compiling of FFMPEG and OBS - you'll install the that version of FFMPEG and OBS in that user's home directory. But other users will still be able to use the compiled program, they'll just have to use a full path to the binaries in the user's home directory. If you desire to do that, just create a new user and then log in as that user. This isn't necessary - but it's what I did.

The first step is to compile a version of FFMPEG with libsrt:

mkdir -p ~/sources
cd ~/sources
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar -xf ffmpeg-snapshot.tar.bz2
cd ffmpeg
./configure --prefix=${HOME}/local/ffmpeg --enable-gpl --enable-version3 --enable-nonfree --disable-static --enable-shared --disable-debug --enable-libfdk-aac --enable-libfreetype --enable-libx264 --enable-libx265 --enable-protocol=libsrt --enable-libsrt --enable-librtmp --enable-libv4l2 --enable-libssh
make
make install

Here I am creating a sources folder in the user's home directory and I'm going to keep all of the sources in here. This is going to install ffmpeg in the directory /home/%user%/local/ffmpeg - that's what ${HOME}/local/ffmpeg as the prefix is standing for. Note also, make install does not require sudo here - because you're not writing anything into any system level folders.

Now, you may want different things compiled in with this version of FFMPEG, so you're configure line may differ and you may require additional libraries to be sudo apt-get install

Once FFMPEG is compiled and install, we move on to compiling OBS:

mkdir -p ~/sources
cd ~/sources
git clone --recursive https://github.com/obsproject/obs-studio.git
cd obs-studio
mkdir build
cd build
cmake -DUNIX_STRUCTURE=1 -DFFmpegPath=${HOME}/local/ffmpeg -DCMAKE_INSTALL_PREFIX=${HOME}/local/obs ..
make -j4
make install

Here the two options that stand out - DFFmpegPath - refers to the path of the FFMPEG you just compiled that is in ${HOME}/local/ffmpeg - DCMAKE_INSTALL_PREFIX is telling cmake where to install the final version of obs - which in this case is going to be /home/%user%/local/obs - Again note, there is no sudo in the make install here because you're not installing it in any system level folders.

Now, running this version of OBS is going to be a little tricky because you did not install any of these libraries in any system level folders. So you're going to have to specify the path to these libraries directly by modifying the LD_LIBRARY_PATH variable before any execution. To insure that this version of OBS is installed with srt, you can use ldd to check for the dynamic library, but again, you'll have to add the respective paths to LD_LIBRARY_PATH when executing:

LD_LIBRARY_PATH=${HOME}/local/ffmpeg/lib:${HOME}/local/obs/lib:${LD_LIBRARY_PATH} ldd ${HOME}/local/bin/obs | grep srt

Now, if another user wants to run this version of OBS, they will have to execute it as:

LD_LIBRARY_PATH=/home/%user%/local/ffmpeg/lib:/home/%user%/local/obs/lib:${LD_LIBRARY_PATH} /home/%user%/local/bin/obs

Or what I do is I create a bash script to execute this command-line and place it in ~/bin:

echo "LD_LIBRARY_PATH=/home/%user%/local/ffmpeg/lib:/home/%user%/local/obs/lib:${LD_LIBRARY_PATH} /home/%user%/local/bin/obs" >~/bin/obssrt.sh
chmod 700 ~/bin/obssrt.sh
obssrt.sh

The environment variable ${HOME} is going to refer to the home directory of the current user. So if you compiled this as one user, then logged in and want to run this version of OBS as another user, then you'll have to provide an absolute path to these libraries and binaries - that's why ${HOME} won't work in this scenario.

Now if you need to run OBS with SRT, you can just simple run:

obssrt.sh

Or if you want to run the Ubuntu/OBS provided version of OBS from their repository (but it won't have SRT support):

obs

This seems to work for me. Although, I haven't done extensive testing, so I may have missed something that is greatly required in the FFMPEG compile. But I think this gives a general explanation of how to accomplish this.

Again, this gives me the freedom to keep a known good copy of OBS running at the system level while also giving me the benefit of running a version of OBS with SRT support if I need that. And I don't have to worry about any package upgrades messing with the OBS SRT version because it's not linked to any system-level FFMPEG package.

@Kusmeroglu
Copy link
Author

@harfinch Fantastic - having a separate OBS install with SRT is going to be helpful when interoperability problems forces using an older version of any of these libraries. Thanks for adding to the conversation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment