OK, yes so it was a combination of trying different folders. (it isn't /app/data/scripts (there is a file that says it is)), case sensitivity, script errors, cancelling early etc
For future use:
The folder to use is /config/scripts/
As stated above, cancelling a recording triggers PostCancel.sh. (You will want this one for testing) (NOTE CASE ON FILE - ALSO CHMOD +X)
Completed recordings trigger PostProcessing.sh (NOTE CASE ON FILE - ALSO CHMOD +X)
Here is my script to process differently based on resolution
I have yet to test comskip - Any input appreciated on that
I will monitor transcode times/quality and adjust as needed
Your input is apprecated as always, Martin
For future use:
The folder to use is /config/scripts/
As stated above, cancelling a recording triggers PostCancel.sh. (You will want this one for testing) (NOTE CASE ON FILE - ALSO CHMOD +X)
Completed recordings trigger PostProcessing.sh (NOTE CASE ON FILE - ALSO CHMOD +X)
Here is my script to process differently based on resolution
Code:
#!/bin/bash
RECORDING_PATH="$1"
OUTPUT_PATH="$(dirname "$RECORDING_PATH")"
LOG()
{
logLoc=/config/scripts/script.log
echo "$(date '+%d-%m-%Y %H:%M:%S') - $1" >> $logLoc
}
LOG "Post-processing started for file: $RECORDING_PATH"
# Get video resolution width
WIDTH=$(ffprobe -v error -select_streams v:0 -show_entries stream=width -of csv=p=0 "$RECORDING_PATH" | head -n 1)
LOG "Resolution width: $WIDTH"
# Define output file path
OUTPUT_FILE="$OUTPUT_PATH/$(basename "${RECORDING_PATH%.*}").mkv"
LOG "OUTPUT FILE: $OUTPUT_FILE"
# Remove commercials
comskip "$RECORDING_PATH"
# Check resolution width and apply different processing
if [[ "$WIDTH" -eq 1920 ]]; then
LOG "Processing HD video"
ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset veryfast -crf 26 -c:a copy "$OUTPUT_FILE"
elif [[ "$WIDTH" -eq 1280 ]]; then
LOG "Processing 720p video"
ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset fast -crf 25 -c:a copy "$OUTPUT_FILE"
else
LOG "Processing SD video"
ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset medium -crf 24 -c:a copy "$OUTPUT_FILE"
fi
# Check if transcoding was successful
if [[ $? -eq 0 && -f "$OUTPUT_FILE" ]]; then
LOG "Transcoding successful, removing original file"
rm "$RECORDING_PATH"
else
LOG "Transcoding failed, keeping original file"
fi
# Send notification
LOG "Recording processed: $(basename "$RECORDING_PATH")"
I have yet to test comskip - Any input appreciated on that
I will monitor transcode times/quality and adjust as needed
Your input is apprecated as always, Martin