Batch Converting FLV to MP4

Needed a quick way to convert all my FLV videos to MP4 so I pieced together this script from various Stack Overflow posts.

#! /bin/bash
function flv_to_mp4() {
  for file in $(find . -type f \( -name "*.FLV" -or -name "*.flv" \) ) ; do
    local bname=$(basename "${file%.*}")
    local mp4name="$bname.mp4"
    ffmpeg -i "$file" "$mp4name"
  done
}

Breakdown of the script:

#! /bin/bash

# Create a new function
function flv_to_mp4() {

  # Find all files ("-type f") that have the extension ".FLV" or ".flv"
  for file in $(find . -type f \( -name "*.FLV" -or -name "*.flv" \) ) ; do

    # Get the name of the file without the extension
    local bname=$(basename "${file%.*}")

    # Create a name for the new file
    local mp4name="$bname.mp4"

    # Use the ffmpeg package to convert the file
    ffmpeg -i "$file" "$mp4name"
  done
}