Making high quality GIF from video in Ubuntu 20.04LTS

First install gif.ski using snap.

snap install gifski;

Then use ffmpeg to break down your video to frames:

ffmpeg -i video.mp4 frame%05d.png;

Finally use gif.ski to create your gif from the frames:

gifski -o clip.gif frame*.png;

Delete the frames if you do not need them, they will be taking a lot of space.


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 -O 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 -O 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
ffmpeg -i input.mp4 -vf vidstabdetect -f null -;
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


Rough note on ffmpeg: Merge Two Videos Side by Side

The following command will create a video from two input files and place them side by side using the hstack filter.

ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4;

More information on the hstack filter:

11.104 hstack
Stack input videos horizontally.
All streams must be of same pixel format and of same height.
Note that this filter is faster than using overlay and pad filter to create same output.
The filter accepts the following option:
inputs
Set number of input streams. Default is 2.
shortest
If set to 1, force the output to terminate when the shortest input terminates. Default value is 0

You can use the vstack filter in case you want to place the one video above the other.


ffmpeg: Convert HikVision H.265+ videos to MKV

The following command will find all mp4 files that are in the current directory and in all sub-folders and convert them to mkv.

Recently we needed to share some footage from a HikVision NVR which was recording to H.265+ which was a proprietary format of the company. To do so, we converted them in another format that more players could recognize the videos.

for FILE in *.mp4; do
  echo -e "Processing video '\e[32m$FILE\e[0m'";
  ffmpeg -i "${FILE}" -analyzeduration 2147483647 -probesize 2147483647 -c:v libx265 -an -x265-params crf=0 "${FILE%.mp4}.mkv";
done;

The filename of the mkv file will be the same as the mp4 video with the correct extension. The mp4 extension will be removed and replaced by the mkv extension e.g hi.mp4 will become hi.mkv

A few notes, the compression they use seems really good, the size of the original video is very small in comparison to the generated result.


Cyprus Radio Frequencies for cars imported from Japan

If you are having trouble with the radio of your car that was imported from Japan and you cannot tune in to your favorite radio stations you might have to do a little math!

On many cars that were imported from Japan it seems that to tune in to the station you like you need to subtract from the frequency 16Mhz. For example, if the station you are interested in is broadcasting at 97.2Mhz you will have to set your car radio to 81.2Mhz to listen to it.

A list of frequencies will follow soon.