GNU/Linux


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.


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.


Ubuntu 18.04 and VOSK Speech Recognition API

Just some quick notes on how to install and use VOSK on Ubuntu 18.04 LTS.

  1. Install using: pip3 install vosk
  2. Get samples from https://github.com/alphacep/vosk-api/tree/master/python/example
  3. Using ffmpeg create input audio files ffmpeg -i video.mkv -c:a pcm_s16le -ac 1 output.wav
    It will create a file of the following type output.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 48000 Hz
  4. Export text to JSON python3 ./test_simple.py output.wav