Bulk extract audio files from video files using FFMPEG

Do you ever have a bunch of videos but you really only want the audio from them? This article shows a very fast and free method using FFMPEG to losslessly extract AAC (m4a) audio from videos (mp4). This is a bash function.
function ffextractaudiofromvideos() {
  if [[ $# -eq 0 ]] ; then
    echo 'Please specify a folder containing .mp4 videos that have an AAC audio stream. ie: "ffextractaudiofromvideos ~/Movies/videos"'
  else
    cd "$1"
    for i in "$1"*.mp4; do
        [ -f "$i" ] || break
      ffmpeg -i "$i" -vn -acodec copy "${i%.mp4}".m4a
    done
  fi
}

Internal References

External References

Article Type

General