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>

encoding mov to mp4 with hbcli:

hbcli -i asdf.mov -e qsv_h264 -q 20 -B 160 -o asdf.mp4 

encoding mov to mp4 with ffmpeg:

ffmpeg -i asdf.mov -c:v libx264 -c:a aac -movflags +faststart asdf.mp4
ffmpeg -i asdf.mov -preset slow -c:v libx264 -a:a aac -b:a 128k -b:v 2500k -pix_fmt yuv420p -minrate 1500k -maxrate 4000k -vf scale:-1:720 asdf.mp4

copying mov to mp4 without encoding, basically just changing container:

ffmpeg -i asdf.mov -qscale 0 asdf.mp4
ffmpeg -i asdf.mov -q:v 0 asdf.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:

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

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

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

links: