encode videos & images

This current COVID19 has given me ample of time to take backups and cleanup pics and videos from my camera. Just a few commands to convert between formats to save space and archive.

converting between containers:

ffmpeg -i <my-video.mkv> -c:v copy -c:a copy <my-video.mp4>

for bulk converting in a directory:

for %f in (*.mkv) do (echo "ffmpeg -i %f -c:v copy -c:a copy %~nf.mp4")

encoding m4v to mkv/mp4 (hbcli is handbrake-cli):

hbcli -i <my-video.m4v> -o <my-video.mkv/mp4>

extracting audio from video:

ffmpeg -i <my-video.mp4> -f mp3 -ab 192000 -vn <my-audio.mp3>

converting png as webp one image at a time:

cwebp -q 75 <image.png> -o <image.webp>

converting png as webp in bulk (be careful what the current directory is):

find ./ -type f -name '*.png' -exec sh -c 'cwebp -q 75 $1 -o "${1%.png}.webp"' _ {} \;