Skip to content

Instantly share code, notes, and snippets.

@cstroie
Created December 28, 2011 12:09
Show Gist options
  • Save cstroie/1527749 to your computer and use it in GitHub Desktop.
Save cstroie/1527749 to your computer and use it in GitHub Desktop.
MMCH comverter to MP4
#!/bin/bash
D="output"
mkdir -p "$D"
if [ ! "$1" ]
then
echo "Usage: $0 <file>"
exit 1
fi
I="$1"
B="${I##*/}"
N="${B%.*}"
X="${B##*.}"
A="$D/$N.wav"
T="$D/$N.$X"
O="$D/$N.mp4"
# Extract audio
ffmpeg -i "$I" "$A"
# Normalize audio
normalize-audio "$A"
# Create temporary video
ffmpeg -i "$I" -i "$A" -acodec copy -vcodec copy "$T"
# Encode the output video
HandBrakeCLI -e x264 -S 175 -2 -E faac -B 160 -X 640 -5 -i "$T" -o "$O"
# Remove temporary files
rm "$A" "$T"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment