Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ ! -d "$1" ]; then
- echo "Usage: `basename $0` <dir>"
- echo "Processes files in <dir>"
- exit 1
- fi
- ERROR=0
- NODE="192.168.1.100"
- TARGETDIR=$1
- DATE=`date +%s`
- find "$TARGETDIR" \( -name '*.mkv' -or -name '*.avi' \) -print0 | while read -d $'\0' VIDEO; do
- FOLDER=`dirname "$VIDEO"`
- FILE=`basename "$VIDEO"`
- cd "$FOLDER"
- FOLDERREMOTE=`echo "$FOLDER" | sed 's/\/media\/media/\/Volumes\/Media/g'`
- START1=`date +%s`
- echo `date +%H:%M:%S`": Processing ${FILE}..."
- if [ `mediainfo "${FILE}" | grep DTS | wc -l` -gt 0 ]; then
- echo `date +%H:%M:%S`": DTS track detected. Converting to AC3... "
- ~/Dropbox/bin/mkvdts2ac3.sh -n "${FILE}"
- if [ $? -eq 0 ]; then
- echo `date +%H:%M:%S`": DTS->AC3 conversion complete. Continuing with encoding... "
- else
- echo `date +%H:%M:%S`": DTS->AC3 conversion failed. Skipping file..."
- ERROR=1
- continue
- fi
- fi
- if [ "`ssh ${NODE} whoami`" = "magu" ]; then
- ssh $NODE "chmod 755 ~/Dropbox/bin/*; cd \"${FOLDERREMOTE}\" && ~/Dropbox/bin/convert_onepass.sh \"${FILE}\"" > "/tmp/convert.${FILE}.log" 2>&1
- if [ ! $? -eq 0 ]; then
- echo `date +%H:%M:%S`": Failed to convert ${FILE} to H.264"
- ERROR=1
- continue
- fi
- else
- echo `date +%H:%M:%S`": Processing node not available. Using local CPU."
- chmod 755 ~/Dropbox/bin/*
- cd "${FOLDER}"
- ~/Dropbox/bin/convert_onepass.sh "${FILE}" > "/tmp/convert.${FILE}.log" 2>&1
- if [ ! $? -eq 0 ]; then
- echo `date +%H:%M:%S`": Failed to convert ${FILE} to H.264"
- ERROR=1
- continue
- fi
- fi
- ~/Dropbox/bin/rename-file.py -a -f "${FILE%.*}.m4v" >> "/tmp/convert.${FILE}.log"
- if [ ! $ERROR -eq 0 ]; then
- echo "Failed to rename ${FILE%.*}.m4v"
- ERROR=1
- continue
- fi
- done
- if [ $ERROR -eq 0 ]; then
- cd "$TARGETDIR"
- find . -size +100M -name '*.m4v' -exec mv '{}' "/media/media/Library/Automatically Add to iTunes" \;
- exit 0
- else
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement