Using “ffmpeg”

M4A to MP3

ffmpeg -i ${INPUT}.m4a -c:v copy -c:a libmp3lame \
       -q:a 0 ${OUTPUT}.mp3

The -q:a parameters correspond to LAME’s -V option, so 0 is the highest quality and 9 is the lowest quality. While everyone says to use 3 or 4 for this parameter, in my experience even using 0 will often result in a smaller file than an m4a original. (What’s up with that? I thought that m4a was supposed to be more efficient than mp3?)

MP4 to GIF

# Generate an optimized palette.
ffmpeg -i $INPUT.mp4 \
       -filter_complex "[0:v] palettegen" $PALETTE.png

# Convert the MP4 to GIF (using the palette above).
ffmpeg -i $INPUT.mp4 -i $PALETTE.png \
       -filter_complex "[0:v][1:v] paletteuse" \

MP4 to WebP

ffmpeg -i $INPUT.mp4 \
       -vf "fps=10,scale=720:-1:flags=lanczos" \
       -vcodec libwebp -lossless 0 -compression_level 6 \
       -q:v 50 -loop 0 -preset picture -an \
       -vsync 0 $OUTPUT.webp