General command-line stuff

Image manipulation

Animated images
Animated gif with Imagemagick:
convert -delay 1.5 -loop 0 image.00*.bmp out.gif
note that I used the ancient bmp format to dismiss transparency.
The same with ffmpeg:
ffmpeg -f image2 -i fractureTest.%04d.bmp out.mp4
And reverse:
ffmpeg -i "input.mov" -an -f image2 "output.%05d.png"
Convert movie to gif:
ffmpeg -i dragon.mov -f image2pipe -vcodec ppm - | convert - -delay 0 -loop 0 dragon_pipe.gif

Proper Quicktime from image sequences:
ffmpeg -f image2 -i frame%01d.png -pix_fmt yuv420p out.mov

Really small screen captures:

ffmpeg -i input.mov -s 1600x900 -b 3000k -vcodec h264 -acodec none out.mp4

Change resolution of course to get a smaller size, and adjust bitrate accordingly.

Small gif from movie:
(main switches are -r for rate and -colors for #colors)

ffmpeg -i untitled.mov -r 10 -f image2pipe -vcodec ppm - | convert - -dither none -matte -depth 8 -deconstruct  -layers optimizePlus -colors 64 output.gif

from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html:

#!/bin/sh
palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2

Lazy one-liner:
(just change file)

file=mymovie.mov;filters="fps=15,scale=640:-1:flags=lanczos"; palette="/tmp/palette.png"; ffmpeg -i $file -vf "$filters,palettegen" -y $palette; ffmpeg -i $file -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y ${file%.*}.gif

misc

delete empty folders recursively

# check...
find . -type d -empty -print
# do it
find . -type d -empty -delete

Recursive find and replace Use sed in-place editing on a set of files:

find . -name "*.log" -exec sed -i '' 's/string\/with\/slash/replaced_with_this/g' {} \;

renumbering

n=1;for i in *.png ; do mv $i flock$n.png; ((n=n+1)) ; done

Find out the combined size of a type:

find folder/ -name "*.jpg" -print0 | xargs -0 du -hc | tail -n1

Collapse whitespaces
echo "hey you" | tr -s ' ' | cut -d ' ' -f 2

Files modified in the last 120 min

find . -mmin -120

bash

Lazy Tab completion
in .inputrc:
set show-all-if-ambiguous on

screen

Detach screen
CTRL-a, then d
Name screen
screen -S name

dl youtube audio

youtube-dl -f bestaudio --extract-audio --audio-format wav http://URL_TO_VID
(or use mp3...)

general

an easy xargs example
find . -name "*.h" | xargs grep good_stuff