6 hours ago
Hi all
I've been trying to find out where to both put a postprocessing.sh script in docker and finding out how to process transcode my recordings
As far as I am aware, I need to turn off auto record and then stick it in /config/scripts
I'd like to process differently based on resolution - Can someone help me review?
I've been trying to find out where to both put a postprocessing.sh script in docker and finding out how to process transcode my recordings
As far as I am aware, I need to turn off auto record and then stick it in /config/scripts
I'd like to process differently based on resolution - Can someone help me review?
Code:
#!/bin/bash
RECORDING_PATH="$1"
OUTPUT_PATH="$(dirname "$RECORDING_PATH")"
# Get video resolution
RESOLUTION=$(ffmpeg -i "$RECORDING_PATH" 2>&1 | grep -oP '(?<=, )\d+x\d+(?=,)' | head -1)
# Define output file path
OUTPUT_FILE="$OUTPUT_PATH/$(basename "${RECORDING_PATH%.*}").ts"
echo "OUTPUT FILE: $OUTPUT_FILE"
# Remove commercials
comskip "$RECORDING_PATH"
# Check resolution and apply different processing
if [[ "$RESOLUTION" == "1920x1080" ]]; then
echo "Processing HD video"
ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset ultrafast -crf 51 -c:a copy "$OUTPUT_FILE"
elif [[ "$RESOLUTION" == "1280x720" ]]; then
echo "Processing 720p video"
ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset ultrafast -crf 51 -c:a copy "$OUTPUT_FILE"
else
echo "Processing SD video"
ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset ultrafast -crf 51 -c:a copy "$OUTPUT_FILE"
fi
# Check if transcoding was successful
if [[ $? -eq 0 && -f "$OUTPUT_FILE" ]]; then
echo "Transcoding successful, removing original file"
rm "$RECORDING_PATH"
else
echo "Transcoding failed, keeping original file"
fi
# Send notification
echo "Recording processed: $(basename "$RECORDING_PATH")"