From dc4ed4678b338f8f45bb7e9a4c1d8857bcd6b38d Mon Sep 17 00:00:00 2001 From: Jelle Jansen Date: Sat, 12 Apr 2025 16:40:23 +0200 Subject: [PATCH] Add watch.sh --- watch.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 watch.sh diff --git a/watch.sh b/watch.sh new file mode 100644 index 0000000..6843ffc --- /dev/null +++ b/watch.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Functie om audio te extraheren +extract_audio() { + INPUT="$1" + OUTPUT="${INPUT%.*}.mp3" + ffmpeg -i "$INPUT" -q:a 0 "$OUTPUT" +} + +# Begin de loop om de map in de gaten te houden +inotifywait -m -r -e create /watched --format '%w%f' | while read FILE +do + # Wacht tot het bestand volledig is geschreven + sleep 1 + + # Controleer of het bestand een video- of audio-bestand is + if [[ "$FILE" == *.mp4 || "$FILE" == *.MP4 || "$FILE" == *.avi ]]; then + echo "Nieuw bestand gedetecteerd: $FILE" + extract_audio "$FILE" + fi +done \ No newline at end of file