Skip to content

Instantly share code, notes, and snippets.

@gitfer
Created September 26, 2014 10:10
Show Gist options
  • Save gitfer/723b42c06c79f4906a8d to your computer and use it in GitHub Desktop.
Save gitfer/723b42c06c79f4906a8d to your computer and use it in GitHub Desktop.
ripWithSubtitles.sh
#!/bin/bash
command -v mencoder >/dev/null 2>&1 || { echo >&2 "I require mencoder but it's not installed. Aborting."; exit 1; }
command -v mplayer >/dev/null 2>&1 || { echo >&2 "I require mplayer but it's not installed. Aborting."; exit 1; }
if [[ $# -eq 0 ]]; then
echo "ripWithSubtitles.sh a.avi a.sub o.avi 1"
exit 1;
fi
IFS='%'
FILENAME=$1
echo "FILENAME: " ${FILENAME:-"a.avi"}
SUBTITLE_FILENAME=$2
echo "SUBTITLE: " ${SUBTITLE_FILENAME:-"a.sub"}
OUTPUT_FILENAME=$3
echo "OUTPUT: " ${OUTPUT_FILENAME:-"o.avi"}
AUDIO_ID=$4
echo "AUDIO_ID: " ${AUDIO_ID:-1}
mplayer -identify -frames 0 ${FILENAME}
mencoder -aid ${AUDIO_ID} -oac copy -ovc copy ${FILENAME} -sub ${SUBTITLE_FILENAME} -o ${OUTPUT_FILENAME}
unset IFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment