ffmpeg-watch/watch.sh

21 lines
630 B
Bash
Raw Normal View History

2025-04-12 16:40:23 +02:00
#!/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
2025-04-12 16:57:51 +02:00
inotifywait -m -r -e create --format '%w%f' /watched | while read FILE
2025-04-12 16:40:23 +02:00
do
# Wacht tot het bestand volledig is geschreven
sleep 1
# Controleer of het bestand een video- of audio-bestand is
2025-04-12 16:57:51 +02:00
if [[ "$FILE" == *.mp4 || "$FILE" == *.MP4 || "$FILE" == *.avi || "$FILE" == *.mov || "$FILE" == *.flv || "$FILE" == *.wmv ]]; then
2025-04-12 16:40:23 +02:00
echo "Nieuw bestand gedetecteerd: $FILE"
extract_audio "$FILE"
fi
done