-
-
Save wilkinsbrian/11389254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################ | |
# Recursively peruses a directory and converts MKV files | |
# to MP4 for streaming to Xbox360. | |
# | |
# @author: Ticean Bennett | |
# @url: http://ticean.com | |
# @see: http://trac.handbrake.fr/wiki/CLIGuide#options | |
# | |
# @param file The complete file path. | |
# @param delete_mkv True if the original mkv will be deleted. | |
# | |
############################################################ | |
function convert_mkv { | |
file="$1" | |
filepath="${file%\/*}" | |
filename=$(basename "$file") | |
name=$(echo "$filename" | sed 's/\.[^\.]*$//') | |
delete_mkv=1 #$2||0; | |
echo "File: $file" | |
echo "filepath: $filepath" | |
echo "filename: $filename" | |
echo "name: $name" | |
HandBrakeCLI -i "${filepath}/${name}.mkv" -o "${filepath}/${name}.mp4" -e x264 -b 2000 -a 1 -E faac -B 160 -R 48 -6 dpl2 -f mp4 -x level=40:ref=2:mixed-refs:bframes=3:weightb:subme=9:direct=auto:b-pyramid:me=umh:analyse=all:no-fast-pskip:filter=-2,-1 | |
# @TODO Make sure that conversion was a success before deleting. | |
if [ -e "${filename}" -a ${delete_mkv}=1 ]; then | |
echo "Deleting source file: ${filename}" | |
rm "${filename}" | |
fi | |
} | |
function walk_tree { | |
local directory="$1" | |
local extension="$2" | |
local i | |
for i in "$directory"/*; | |
do | |
echo "Checking ${i}" | |
if [ "$i" = . -o "$i" = .. ]; then | |
continue | |
elif [ -d "$i" ]; then | |
walk_tree "$i" | |
elif [ "${i##*.}" = "mkv" ]; then | |
echo "Found mkv file" | |
file="$(basename $i)" | |
filename=$(echo "$i" | sed 's/\.[^\.]*$//') | |
echo "Invoking convert_mkv ${directory} ${filename}" | |
#echo "via sed: ${fn}" | |
convert_mkv "${i}" 0 | |
else | |
continue | |
fi | |
done | |
} | |
targetdir="$1" | |
extension="$2" | |
echo "Executing: convertMkv.sh ${targetdir} ${extension}" | |
walk_tree "$targetdir" "mkv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
########################################################## | |
# sabnzbd script that runs both sabToSickbeard | |
# and Mkv conversion. | |
# | |
# @author: Ticean Bennett | |
# @see: http://ticean.com | |
# @see: http://wiki.sabnzbd.org/user-scripts | |
# @requires: sabToSickbeard.py | |
# @requires: convertMkv.sh | |
# | |
# @param $l directory of the job (full path) | |
# @param $2 The original name of the NZB file | |
# @param $3 Clean version of the job name (no path info and ".nzb" removed) | |
# @param $4 Indexer's report number (if supported) | |
# @param $5 User-defined category | |
# @param $6 Group that the NZB was posted in e.g. alt.binaries.x | |
# @param $7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21 | |
# | |
########################################################### | |
scriptpath="$(cd ${0%/*} && pwd -P)" | |
"${scriptpath}/convertMkv" "$1" "$2" "$3" "$4" "$5" "$6" "$7" | |
"${scriptpath}/sabToSickBeard.py" "$1" "$2" "$3" "$4" "$5" "$6" "$7" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment