Applications


Git: Remove or Delete file from Git repository

To remove a file from the Git repository but not delete it from your filesystem, execute the following:

git rm --cached file_to_keep.txt;
git commit -m "Removing file_to_keep.txt from Repository";

To remove a file from the Git repository and the filesystem, use the following:

git rm file_to_delete.txt;
git commit -m "Removing and Deleting file_to_delete.txt";

Latex/Beamer: Undefined control sequence. …meroption{show notes on second screen=right}

When trying to enable the option that shows presentation notes on a different monitor using:

\setbeameroption{show notes on second screen=right}

we got the following error:

Undefined control sequence. …meroption{show notes on second screen=right}
Missing \begin{document}. …meroption{show notes on second screen=right}

To fix this issue we enabled the package pgfpages

\usepackage{pgfpages}

To present this special built PDF presentation across two screens we used dspdfviewer.

dspdfviewer is a pre-rendering and caching (read: fast) full-screen pdf viewer specifically designed for latex-beamer presentations, that were created with the show notes on second screen=right option (\setbeameroption{show notes on second screen=right}).

https://dspdfviewer.danny-edel.de/
http://manpages.ubuntu.com/manpages/focal/man1/dspdfviewer.1.html

Special note: when we were testing dspdfviewer on Ubuntu 20.04LTS we thought that the secondary screen had to be on the left of the primary (because of the build command that specifies that notes need to be on the right). That was actually wrong, as you will see in the following picture even though we built the presentation to have the notes on the “right” dspdfviewer was able to work as expected even when the secondary screen was on top of the primary.


Latex / Beamer: Change footline for Boadilla theme

Having a presentation title that was too long, we wanted to change the middle part of the footline on the Boadilla theme to replace the command for the document title (\insertshorttitle) with the command for document subtitle (\insertshortsubtitle).

To do so, we added the following right before the \begin{document} command.

\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
      \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\ifblank\expandafter{\beamer@shortinstitute}{}{~(\insertshortinstitute)}
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
      \usebeamerfont{title in head/foot}\insertshortsubtitle%\insertshorttitle
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
      \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
      \usebeamertemplate{page number in head/foot}\hspace*{2ex} 
    \end{beamercolorbox}
  }%
  \vskip0pt%
}

When compiling the PDF, the result was as expected but we were getting a lot of errors for Undefined Control Sequence in various objects like the \begin{document} and \end{frame} commands. After modifying the following line (for the author name and institution) from this:

\usebeamerfont{author in head/foot}\insertshortauthor\expandafter\ifblank\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}

to this:

\usebeamerfont{author in head/foot}\insertshortauthor~~(\insertshortinstitute)

The errors were gone and the results were again the same. The final block that was properly working with no additional errors is the following:

\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
      \usebeamerfont{author in head/foot}\insertshortauthor~~(\insertshortinstitute)
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
      \usebeamerfont{title in head/foot}\insertshortsubtitle
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
      \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
      \usebeamertemplate{page number in head/foot}\hspace*{2ex} 
    \end{beamercolorbox}
  }%
  \vskip0pt%
}

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