FFmpeg

Encoding video/audio straight from the command line

Tuesday, Apr 28, 2020

FFmpeg

ffmpeg

Getting Started

brew install ffmpeg

Conversion between filetypes

Making GIFs

Useful Arguments

Examples of flag usage

Merging audio files

ls *.mp3 | sort | sed 's/^/file /g' > 'files.txt'
ffmpeg -f 'concat' -i 'files.txt' -c copy 'merged.mp3'

Convert .aax files to .m4a

Assuming you know the activation bytes of your file…

Extract cover art from a media file

Convert mkv to mp4

for file in ~/episodes/*.mkv; do
  ffmpeg -i ${file} ${file:0:(-4)}.mp4;
done

Concatenate Multiple .mp3 Files

# Create a string to specify which files to concatenate
typeset ifile="concat:one.mp3|two.mp3|three.mp3"

# Concatenate the files
ffmpeg -i ${ifile} -c:a copy -map_metadata 0:1 ofile.mp3

Taking a Photo using only a Command Line

  ffmpeg \
      -f 'avfoundation' \
      -video_size '1280x720' \
      -framerate 30 \
      -i 0 \
      -vframes 1 \
  ./output.jpg

Convert an MP3 Audiobook to an M4B Audiobook

# For each audiobook in the folder
for audiobook in *.mp3; do
  ffmpeg -i ${audiobook} -c:a aac -c:v copy ${audiobook:r}.m4b;
done