Resize mp4 with ffmpeg

Zoom didn’t want to accept a background video so I tried to find a way to shrink its size to 1080p. There is a simple command to do that with ffmpeg:

ffmpeg -i original.mp4 -vf scale=1920:1080 new_1080p.mp4

DaVinci Resolve 16 Linux mp4/h.264 encode/decode

DaVinci Resolve doesn’t support import or export of mp4 format on Linux. It is working on Windows 10, but I really don’t want to switch to boot into Windows for rendering.

So i looked around and found a workflow for using Resolve under Linux: ffmpeg is my tool of choice to change formats so that Resolve is able to load and write my videos.

My recordings from OBS are saved as mkv as proposed by an OBS warning in the recording settings.

mkv to mov

ffmpeg -i input.mkv -map 0:0 -map 0:1 -map 0:2 -vcodec dnxhd -acodec:0 pcm_s16le -acodec:1 pcm_s16le -s 1920x1080 -r 30000/1001 -b:v 36M -pix_fmt yuv422p -f mov output.mov

After converting the recording to the mov format DaVinci Resolve 16 is able to use the file with all audio tracks.

mp4 to mov

If I get videos from other sources most of the time its in mp4 format. With the following command I convert the mp4 to DaVinci Resolve usable mov:

ffmpeg -i input.mp4 -vcodec dnxhd -acodec pcm_s16le -s 1920x1080 -r 30000/1001 -b:v 36M -pix_fmt yuv422p -f mov output.mov

mov to mp4

In DaVinci Resolve 16 I export my videos with mov format and then convert them to youtube ready mp4 with this command:

ffmpeg -i input.mov -vf yadif -codec:v libx264 -crf 1 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart output.mp4

TLDR

DaVinci Resolve 16 does NOT support h.264 en-/decoding on Linux and you have to transcode your videos for example with ffmpeg as shown above. Transcoding is quite fast also on my 6 year old machine.

Windows ln style softlinks with mklink

You can use softlinks (linux: ln -s source target) under windows.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    Specifies the new symbolic link name.
        Target  Specifies the path (relative or absolute) that the new link
                refers to.

The example mklink /D jdk11 jdk-11.0.7.10-hotspot will create a softlink with name jdk11 to folder jdk-11.0.7.10-hotspot in the same directory.

Update

This page now also supports translations. I am going to try writing posts in English and German from now. Old pages won’t be translated unless somebody requests it.

How NOT to offer a product

Its quite common to offer freemium software with missing premium features but writing a paid product (without a free version at all) that targets to send personal data over a network and make users upgrade from the basic to pro version to at least have their private data encrypted is an absolute no-go in my opinion. I cut out the relevant part of the offer. Basic version is 29 and pro 39 USD.

Home Studio Setup

I just set up a new live-streaming/video-conferencing system for home office and I want to share my part list with you. If you decide to buy parts from my list please consider using my links which would support me a little bit.

Video

Audio

change wordpress url in database

if you need to move wordpress to a new url then the following sql script will be handy (update the urls in it of course):

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

Install OSM Nominatim in Ubuntu LTS 18.04 for private reverse geocoding

I recentely found out about OpenStreetMap Nominatim and its reverse geocoding feature. And same as OSM it can be installed on a local server. I followed the installation steps documented in online manual and everything runs very smoothly.

#!/bin/bash
# steps for 18.04 LTS with latest updates
# run as root

export USERNAME=nominatim
export USERHOME=/srv/nominatim
export NOMATIM_VERSION=3.4.1
export NOMINATIM_SOURCE_DIR=$USERHOME/Nominatim-${NOMATIM_VERSION}
export BUILD_LOCAL=$USERHOME/build/settings/local.php
export BUILD_UTILS=$USERHOME/build/utils
export PG_CONF=/etc/postgresql/10/main

# installation
apt update
apt dist-upgrade -y
apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
                   libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev \
                   libbz2-dev libpq-dev libproj-dev \
                   postgresql-server-dev-10 postgresql-10-postgis-2.4 \
                   postgresql-contrib-10 postgresql-10-postgis-scripts \
                   apache2 php php-pgsql libapache2-mod-php \
                   php-intl git python3-pip
apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# user
useradd -d ${USERHOME} -s /bin/bash -m ${USERNAME}

# apache
tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
<Directory "/srv/nominatim/build/website">
  Options FollowSymLinks MultiViews
  AddType text/html   .php
  DirectoryIndex search.php
  Require all granted
</Directory>
Alias /nominatim /srv/nominatim/build/website
EOFAPACHECONF
a2enconf nominatim
systemctl restart apache2

# nomatim
sudo -u $USERNAME -H sh -c "cd $USERHOME && wget https://nominatim.org/release/Nominatim-${NOMATIM_VERSION}.tar.bz2 && tar xf Nominatim-${NOMATIM_VERSION}.tar.bz2 && mkdir build && cd build && cmake $USERHOME/${NOMINATIM_SOURCE_DIR} && make"

tee $BUILD_LOCAL << EOFLOCAL
<?php
 @define('CONST_Website_BaseURL', '/nominatim/');
 @define('CONST_Osm2pgsql_Flatnode_File', '${USERHOME}/flatnode.file');
EOFLOCAL

# postgre
sudo -u postgres createuser -s $USERNAME
sudo -u postgres createuser www-data
cp postgresql_preimport.conf postgresql_postimport.conf ${PG_CONF}
mv ${PG_CONF}/postgresql.conf ${PG_CONF}/postgresql.conf.orig
ln -s ${PG_CONF}/postgresql_preimport.conf ${PG_CONF}/postgresql.conf
systemctl restart postgresql

#  wikipedia data
#cd $NOMINATIM_SOURCE_DIR/data
#wget https://www.nominatim.org/data/wikipedia_article.sql.bin
#wget https://www.nominatim.org/data/wikipedia_redirect.sql.bin
#wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
#wget https://www.nominatim.org/data/us_postcode_data.sql.gz

# streetmap data
export MAP_DATA_DIR=$USERHOME/mapdata
mkdir $MAP_DATA_DIR
cd $MAP_DATA_DIR
wget https://download.geofabrik.de/europe/austria-latest.osm.pbf

# fix permissions after getting all data
chmod -R a+x $USERHOME
chown -R ${USERNAME}:${USERNAME} $USERHOME

# install map data
sudo -u $USERNAME -H sh -c "$BUILD_UTILS/setup.php --osm-file $MAP_DATA_DIR/austria-latest.osm.pbf --all" 2>&1 | tee $USERHOME/setup-austria.log

# update process
sudo -u $USERNAME -H sh -c "pip3 install --user osmium"
echo " // update process" >> $BUILD_LOCAL
echo " @define('CONST_Pyosmium_Binary', '/srv/nominatim/.local/bin/pyosmium-get-changes');" >> $BUILD_LOCAL
echo " @define('CONST_Replication_Url', 'https://download.geofabrik.de/europe/austria-updates');" >> $BUILD_LOCAL
echo " @define('CONST_Replication_Update_Interval', '86400');" >> $BUILD_LOCAL
echo " @define('CONST_Replication_Recheck_Interval', '900');" >> $BUILD_LOCAL
sudo -u $USERNAME -H sh -c "$BUILD_UTILS/update.php --init-updates"

# enable fsync of postgre
rm ${PG_CONF}/postgresql.conf
ln -s ${PG_CONF}/postgresql_postimport.conf ${PG_CONF}/postgresql.conf
service postgresql restart

The mentioned files are also included here:

After installing it i was able to call the reverse geocoding API like this (replace the ip with the one of your server):

curl -X GET 'http://192.168.0.247/nominatim/reverse.php?lat=48&lon=15&osm_type=N&format=json&zoom=3'

{"place_id":3655636,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"relation","osm_id":16239,"lat":"47.2000338","lon":"13.199959","display_name":"Österreich","address":{"country":"Österreich","country_code":"at"},"boundingbox":["46.3722761","49.0205305","9.5307487","17.160776"]}