M4A to MP3

How to convert from M4A to MP3 using ffmpeg

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?)

Link to original

MP4 to GIF

How to convert from MP4 to GIF using ffmpeg

# 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" \
	                    $OUTPUT.gif
Link to original

MP4 to WebP

How to convert from MP4 to WebP using ffmpeg

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
Link to original