FFMPEG - Convert WebM (or other) to X264 (BASH)

There are a lot of video codecs out there, and some of them are far, far more efficient than H.264. But, as efficient as HEVC or WebM might be, they're frustrating to stumble across if your playback device is a Raspberry pi which has neither the hardware support, nor the processing capabilities required to deal with those codecs without stuttering

It is, however, incredibly simple to convert to X264 with ffmpeg, the below snippet creates a utility script to do so by just passing in the input filename and the destination file to create

Details

  • Language: BASH

Snippet

#!/bin/bash
#
# Swap something to X264 with AAC audio

IN=$1
OUT=$2

if [ "$1" == "" ] || [ "$2" == "" ]
then
    echo "$0 [in file] [out file]"
    exit 1
fi

ffmpeg -i "$IN" -c:v libx264 -codec:a aac -strict -2 "$OUT"

Usage Example

to_x264.sh foo_bar.webm foo_bar.mp4