Compile ffmpeg with video stabilization (vidstab) support on Ubuntu 20.04 LTS


Below are the commands to build vid.stab and ffmpeg on Ubuntu 20.04LTS. (We did not include libaom).

sudo apt-get install build-essential cmake nasm libx264-dev libx265-dev libnuma-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev libunistring-dev
mkdir ~/ffmpeg_sources ~/ffmpeg_build ~/bin
cd ~/ffmpeg_sources
wget https://github.com/georgmartius/vid.stab/archive/master.zip
unzip master.zip
cd vid.stab-master
cmake -DCMAKE_INSTALL_PREFIX:PATH=~/ffmpeg_build .
make
make install
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
wget ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-gnutls \
--disable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-libvidstab && \
PATH="$HOME/bin:$PATH" make && \
make install && \
hash -r
source ~/.profile

https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

Using vid.stab with default parameters and two-step process.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/ffmpeg_build/lib
#Use these two commands for optimal results:
ffmpeg -i input.mp4 -vf vidstabdetect -f null -;
ffmpeg -i input.mp4 -vf vidstabtransform=zoom=5:input="transforms.trf" out_stabilized.mp4
#Use this command for a generic solution with the default values
ffmpeg -i input.mp4 -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 output.vid.stab.mp4;

https://github.com/georgmartius/vid.stab#usage-instructions

Using deshake filter for comparison.

ffmpeg -i input.mp4 -vf deshake output.deshake.mp4

https://ffmpeg.org/ffmpeg-filters.html#deshake

This post is also available in: Greek

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.