Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active September 6, 2021 22:08
Show Gist options
  • Save jniltinho/dbc8071e5a727862703d0cd962b25ba8 to your computer and use it in GitHub Desktop.
Save jniltinho/dbc8071e5a727862703d0cd962b25ba8 to your computer and use it in GitHub Desktop.
Install FFMPEG GIT + NVENC + OBS -- OpenSUSE 42.2
#!/bin/bash
## Install FFMPEG GIT + OBS GIT OpenSUSE 42.2 64Bits
## http://www.diolinux.com.br/2016/07/como-instalar-o-ffmpeg-nvenc-no-ubuntu.html
## Pacote Compilado no GITHUB: https://github.com/jniltinho/oficinadotux/tree/master/ffmpeg_nvenc/opensuse
## Run as root (sudo su)
## Links
## http://www.regataos.com.br/
## https://gist.github.com/Brainiarc7/4b49f463a08377530df6cecb8171306a
## https://developer.nvidia.com/ffmpeg
## Check Nvidia ENC
## nvidia-smi dmon -i 0
## Test FFMPEG ENCODER NVENC
## ffmpeg -y -i INPUT -vcodec h264_nvenc -b:v 10M -acodec copy OUTPUT.mp4
## ffmpeg -y -i INPUT -vcodec h264_nvenc -pix_fmt nv12 -tier high -b:v 13M -qmin 17 -qmax 40 -profile:v high -preset slow -cq 10 -bf 2 -g 150 -delay 0 -acodec copy OUTPUT4.mp4
## ffmpeg -y -i INPUT -vcodec h264_nvenc -pix_fmt yuv444p -b:v 13M -qmin 17 -qmax 40 -profile:v high -preset slow -cq 10 -bf 2 -g 150 -delay 0 -acodec copy OUTPUT4.mp4
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo"
exit 1
fi
cd /root/
mkdir -p /root/files_bin/
## Update
zypper up -y
### Install ffmpeg support nvenc
zypper ar -fc http://download.opensuse.org/repositories/home:/regataos/openSUSE_Leap_42.2/home:regataos.repo
zypper ar -fc http://download.opensuse.org/repositories/utilities/openSUSE_Leap_42.2/utilities.repo
zypper ar -fc http://download.opensuse.org/repositories/home:/adra/openSUSE_Leap_42.2/home:adra.repo
zypper --gpg-auto-import-keys refresh
## Installing dependencies for FFMPEG
zypper si -d ffmpeg
zypper in -y checkinstall dpkg rpmbuild alien unzip
#zypper in -y autoconf automake libass-devel libfreetype6 libfdk-aac1
#zypper in -y libSDL-devel libtheora-devel libtool libva-devel libvdpau-devel libvorbis-devel
#zypper in -y libxcb-devel pkg-config libxcb-shm0 libvlc5 vlc-devel xcb-util-devel
#zypper in -y libv4l-devel v4l-utils-devel-tools texi2html zlib-devel nasm libcurl-devel
## Install dependencies for OBS-PORTABLE Support NVENC
zypper in -y cmake fontconfig-devel freetype2-devel gcc gcc-c++ libcurl-devel libudev-devel
zypper in -y libjansson-devel libpulse-devel libqt5-qtbase-devel libqt5-qtx11extras-devel
zypper in -y libv4l-devel libXcomposite-devel libXinerama-devel libXrandr-devel
cd /root/
wget -c https://github.com/FFmpeg/FFmpeg/archive/master.zip
unzip master.zip && rm -f master.zip
cd FFmpeg-master
./configure --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg \
--extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g' \
--optflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g' \
--disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --disable-openssl \
--enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa --enable-libx264 --enable-libx265 --enable-nonfree \
--enable-nvenc --enable-libfdk-aac --enable-libbluray --enable-libcdio --enable-libdc1394 --enable-libfreetype --enable-libgsm \
--enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis \
--enable-libvpx --enable-encoders --enable-decoders --enable-muxers --enable-demuxers \
--enable-decoder='mpeg1video,mpeg2video,mpeg4,h264,vc1' \
--enable-encoder='apng,ass,ayuv,bmp,ffv1,ffvhuff,flac,gif,huffyuv,jpegls,libgsm,libopenjpeg,libopus,libschroedinger,libspeex,libtheora,libvorbis,libvpx_vp8,libvpx_vp9,libwebp,libwebp_anim,mjpeg,pam,pbm,pcm_alaw,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,pcx,pgm,pgmyuv,png,ppm,sgi,srt,ssa,sunrast,targa,text,tiff,v210,v308,v408,v410,vorbis,nvenc,h264,h264_vaapi,h264_nvenc,nvenc_h264,nvenc_hevc,hevc_nvenc,xbm,xwd,y41p,yuv4,zlib,' \
--enable-decoder='ansi,apng,ass,ayuv,bmp,dirac,exr,ffv1,ffvhuff,ffwavesynth,flac,gif,gsm,huffyuv,libcelt,libgsm,libopenjpeg,libopus,libschroedinger,libspeex,libvorbis,libvpx_vp8,libvpx_vp9,mjpeg,,,,opus,pam,pbm,pcm_alaw,pcm_bluray,pcm_dvd,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,pcx,pgm,pgmyuv,pgssub,png,ppm,rawvideo,sgi,srt,ssa,sunrast,targa,text,theora,tiff,v210,v210x,v308,v408,v410,vorbis,vp3,vp5,vp6,vp6a,vp6f,vp8,vp9,h264,h264_vdpau,nvenc,webp,xbm,xwd,y41p,yuv4,zlib,' \
--enable-x11grab
make -j$(nproc)
checkinstall --pkgname=FFmpeg --deldoc=yes --deldoc=yes --nodoc --fstrans=no --backup=no --install=no \
--maintainer=linuxpro@linuxpro.com.br --pkgversion="5:$(date +%Y%m%d)-git" --type=debian -y
alien -r -c -v *_amd64.deb
cp *.x86_64.rpm /root/files_bin/
cp *_amd64.deb /tmp/
cd /tmp/
ar vx *_amd64.deb
rm -f *_amd64.deb control.tar.gz debian-binary
tar -vxf data.tar.xz
rm -rf usr/share/doc
rm -rf usr/share/man
rm -f data.tar.xz
tar -vcJf ffmpeg-git_sdk7_OpenSUSE422_64Bits.xz usr
mv ffmpeg-git_sdk7_OpenSUSE422_64Bits.xz /root/files_bin/
cp -aR usr/* /usr/
rm -rf /tmp/usr
## Compile OBS-PORTABLE from Github
cd /root/
wget -c https://github.com/jp9000/obs-studio/archive/master.zip
unzip master.zip && rm -f master.zip
cd obs-studio-master
cp UI/forms/images/obs.png /usr/share/icons/hicolor/256x256/apps/obs-portable.png
mkdir build && cd build
cmake -DUNIX_STRUCTURE=0 -DCMAKE_INSTALL_PREFIX="/opt/obs-studio-portable" ..
make -j$(nproc) && make -j$(nproc) install
checkinstall --pkgname=obs-studio-portable --deldoc=yes --deldoc=yes --nodoc --fstrans=no --backup=no --install=no \
--maintainer=linuxpro@linuxpro.com.br --type=debian -y
alien -r -c -v *_amd64.deb
cp *.x86_64.rpm /root/files_bin/
echo '#! /bin/sh
cd /opt/obs-studio-portable/bin/64bit/
./obs &' > /usr/local/bin/obs-portable
chmod +x /usr/local/bin/obs-portable
echo '[Desktop Entry]
Version=1.0
Name=OBS-PORTABLE
GenericName=Streaming/Recording Software
Comment=Free and Open Source Streaming/Recording Software
Exec=obs-portable
Icon=obs-portable
Terminal=false
Type=Application
Categories=AudioVideo;Recorder;
StartupNotify=true' > /usr/share/applications/obs-portable.desktop
cd /root/
cp -aR /opt/obs-studio-portable /root/files_bin/
cd /root/files_bin/
tar -zcvf obs-studio-portable_`date +"%Y%m%d"`.tgz obs-studio-portable
rm -rf /root/files_bin/obs-studio-portable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment