Skip to content

Instantly share code, notes, and snippets.

@ryanwild
Forked from datashaman/transcode
Created May 5, 2017 08:41
Show Gist options
  • Save ryanwild/d84dcad37186a58d79545c0405ec5f62 to your computer and use it in GitHub Desktop.
Save ryanwild/d84dcad37186a58d79545c0405ec5f62 to your computer and use it in GitHub Desktop.
Convert anything to x264 .mp4
#!/usr/bin/env bash
#
# Usage:
# transcode filename [filename...]
#
# Video: anything -> x264
# Audio: copy
# Output: .mp4 alongside the source file(s)
#
# I live here: https://gist.github.com/datashaman/6866879e4ad07b0483e6efd9ea49d8a2
#
trap 'exit -1' INT
BINARY=ffmpeg
PRESET=slow
CRF=23
for INPUT in "$@"
do
DIRNAME=$(dirname "${INPUT}")
BASENAME=$(basename "${INPUT}")
# EXTENSION="${BASENAME##*.}"
FILENAME="${BASENAME%.*}"
OUTPUT="${DIRNAME}/${FILENAME}.mp4"
$BINARY -i "${INPUT}" -c:v libx264 -preset ${PRESET} -crf ${CRF} -c:a copy "${OUTPUT}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment