Tips n’ Tricks

This page contains a collection of all the tips and tricks I use to get my work done faster. I use Debian as my distro as choice so all the commands here will be skewed in favor of it.

FFMPEG

Convert MKV to MP4

1
ffmpeg –i input.mkv –c:v h264 output.mp4

Convert MP4 to MP4

1
ffmpeg -i input.mp4 -vn -acodec mp3 -ab 320k -ar 44100 -ac 2 output.mp3

Convert MP4 to WAV

1
ffmpeg -i input.mp4 output.wav

Convert MP4 to PNGs

Output one image every second:

1
ffmpeg -i input.mp4 -vf fps=1 out%d.png

Output one image every minute:

1
ffmpeg -i test.mp4 -vf fps=1/60 thumb%04d.png

Output one image 10 minutes:

1
ffmpeg -i test.mp4 -vf fps=1/600 thumb%04d.png

Find and Replace

Find and replace a string with folder exclusions

1
find ./ -type f -not -path '/.' -not -path "./exclude/*" -readable -writable -exec sed -i "s/bad/good/g" {} \;

This will exclude all folders starting with ‘./‘ which includes stuff like .git and also other folders like ‘./exclude/‘, change to your liking accordingly.

Node and NPM

Install nvm

1
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Git

Initialize and update submodules

1
git submodule update --init

Remove a Submodule

1
2
3
4
git submodule deinit <path_to_submodule>
git rm <path_to_submodule>
git commit -m "Removed submodule"
rm -rf .git/modules/<path_to_submodule>

Cache Authentication token for 20 hours

1
2
3
git-credential-manager-core configure
git config --global credential.credentialStore cache
git config --global credential.cacheoptions "--timeout 72000"

Convert files

You need imagemagick for the convert command

1
sudo apt-get install imagemagick

PNGs to JPEGs

1
convert input.png -quality 90 output.jpg

To convert all the png files in a directory to jpegs:

1
mogrify -format jpg *.png

Miscellaneous

Get your current IP address

1
curl icanhazip.com

Rename all the files of an extension in sequential order

1
ls | cat -n | while read n f; do mv "$f" "$n.jpg"; done

Solving bluetooth woes on Debian 12

I was having a lot of trouble with my Sony WL-XB400 bluetooth headphones on Debian 12. I was able to pair them but only the handsfree option showed up which is not ideal as it’s not very good for listening to music. I tried a lot of things but nothing worked. Finally I found a solution that worked for me.

1
2
3
sudo apt purge pulseaudio-module-bluetooth bluetooth "bluez-*" bluez
rm -rf /var/lib/blueman && rm -rf /var/lib/bluetooth
sudo apt install blueman bluez pulseaudio-module-bluetooth --install-suggests

This made everything work almost instantly. I was able to pair my headphones and the A2DP option showed up. I was able to listen to music and watch videos without any issues.