I have made most of the suggestions that were listed here and I'm still having issues, so I'm assuming that the issue is further on in my script. I'm not going to post the whole thing, but will hopefully post the part where I think the issue is happening. From the 'main' method I'm calling another function that inspects the media file using mediainfo and basically creates a list of parameters to use with Handbrake cli. These parameters are all being created properly as I can see from the logs AND also Handbrake cli is being called correctly as it is logging and generating the correct output file. The problem is that after the Handbrake command runs (in the case of a directory being added), the program never returns to the calling loop (pasted below, with mofications based on the responses).
Code:
main() {
....
find "$inputFile" -depth -iname "*.mkv" -o -iname "*.avi" -o -iname "*.mp4" -print0 | while read -r -d $'\0' temp; do
curl -s -d "apikey=$NMA_KEY" -d "&application=Video Encode" -d "&event=Started - $temp" -d "&description=Directory mode" https://www.notifymyandroid.com/publicapi/notify
CUR_TIME=$(date +"%m-%d-%y %T")
echo "$CUR_TIME - Input file path $temp .." >> $LOG_FILE
runHandbrake "$temp"
if [[ "$?" -ne 0 ]]; then
path="${temp##*/}"
fileName="${path%%.*}"
curl -s -d "apikey=$NMA_KEY" -d "&application=Video Encode" -d "&event=Error - $fileName.mkv" -d "&description=Error Code $?" https://www.notifymyandroid.com/publicapi/notify
else
path="${temp##*/}"
fileName="${path%%.*}"
curl -s -d "apikey=$NMA_KEY" -d "&application=Video Encode" -d "&event=Completed - $fileName.mkv" -d "&description=" https://www.notifymyandroid.com/publicapi/notify
fi
done
....
}
And here's is the snippet of 'runHandbrake' function that is being called, which I believe is causing the issue. The question is after I call Handbrake at the end of this function why isn't it the code continuing to loop through the rest of the .mkv, .avi or .mp4 files in the directory? TIA.
Code:
runHandbrake() {
....
CUR_TIME=$(date +"%m-%d-%y %T")
echo "$CUR_TIME - Handbrake options .." >> $LOG_FILE
echo "$CUR_TIME - -v -i $inputFile -o $OUTPUT_FILE -f $OUTPUT_FORMAT -e $VIDEO_FORMAT -r $FRAMERATE --cfr -q $QUALITY $AUDIO_TRACKS $AUDIO_CODEC $AUDIO_BIT $AUDIO_MIX --decomb --strict-anamorphic --display-width $WIDTH --keep-display-aspect --crop --loose-crop $SUB_OPTIONS" &>> $LOG_FILE
HandBrakeCLI -v -i "$inputFile" -o "$OUTPUT_FILE" -f "$OUTPUT_FORMAT" -e "$VIDEO_FORMAT" -r "$FRAMERATE" --cfr -q "$QUALITY" $AUDIO_TRACKS $AUDIO_CODEC $AUDIO_BIT $AUDIO_MIX --decomb --strict-anamorphic --display-width "$WIDTH" --keep-display-aspect --crop --loose-crop "$SUB_OPTIONS" &>> $LOG_FILE
if [[ "$?" -ne 0 ]]; then
echo "$CUR_TIME - Error executing Handbrake. Error Code $? .." >> $LOG_FILE
exit "$?"
fi
}
Bookmarks