ubuntu


Quick note on setting up our programming environment for Coursera.org “DeepLearning.AI TensorFlow Developer Professional Certificate” on Ubuntu 18.04LTS

Recently we were working on some local Jupyter notebooks for the “DeepLearning.AI TensorFlow Developer Professional Certificate“.

To prepare for the setup with GPU, we followed the instructions at https://www.tensorflow.org/install/gpu. But as we were going through the notebooks we noticed the following error at the terminal:

W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory

Even though libcublas.so.10 was installed it was not loading. Using find was saw that it was installed and available at the folder /usr/local/cuda-10.2/targets/x86_64-linux/lib/ but it was ignored.

To fix this, we added a new entry in ~/.profile as follows:

if [ -d "/usr/local/cuda-10.2/targets/x86_64-linux/lib/" ]; then
    export LD_LIBRARY_PATH=/usr/local/cuda-10.2/targets/x86_64-linux/lib/:${LD_LIBRARY_PATH}
fi

And then executed source ~/.profile from the terminal which we would start the jupyter-notebook command.

After this, library was loaded as expected.


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