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
}

Using Wget to Download a Local Copy of a Website

Why would you want a local copy?

  • Developing and testing widgets: You’re creating a widget for a client and don’t have direct access to edit their website. You can download a copy and install your widget for testing before deployment.
  • Working offline: You’re about to be without internet connection and still want to work on a website that stored remotely on a CMS.
  • Web scraping: You want to download a website to extract data.

Wget

Wget is a fancy tool used to downloads files. This is the tool we’re going to use to download a local copy of a website. It has a ton of features that you can check out here. It comes pre-installed on most *nix systems and is available on OS X and Windows as well.

If you’re on OS X like I am you can download Wget via Homebrew.

brew install wget

The command:

wget \
    --adjust-extension \
    --convert-links \
    --mirror \
    --no-parent \
    --page-requisites \
    http://dead-simple.sorrentino.io

The Options:

adjust-extension Add ".html" to the end of the local filename if the content-type is html/xhtml and the .html extension is not present.
convert-links Make links suitable for local viewing. This will modify links within the HTML so that they point to local assets.
mirror Recursively download files with infinite depth. Use this option if you want to download the entire website.
no-parent Don't ascend to the parent directly. This is useful if you only want to download a subset of a website such as dead-simple.sorrentino.io/projects
page-requisites Download all assets necessary to view the site offline. This tells Wget to download images, sounds, stylesheets, etc so that your local copy is complete.

The result:

You should be able to open the index.html file in your browser and interact with the local copy of the website.