37 lines
1005 B
Bash
Executable File
37 lines
1005 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Directory to scan for video files (default: current directory)
|
|
DIR=${1:-.}
|
|
|
|
# Supported video file extensions
|
|
EXTENSIONS=("mp4" "mkv" "avi" "mov" "wmv" "flv" "webm" "MP4" "MKV" "AVI" "MOV" "WMV" "FLV" "WEBM")
|
|
|
|
# Function to test a video file with ffmpeg
|
|
test_video() {
|
|
local file="$1"
|
|
echo "Testing video: $file"
|
|
# Run ffmpeg in error-detection mode
|
|
ffmpeg -v error -i "$file" -f null - 2> >(grep -E '.*' || true)
|
|
}
|
|
|
|
# Find and test video files
|
|
if [[ ! -d "$DIR" ]]; then
|
|
echo "Error: Directory '$DIR' does not exist."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Scanning directory: $DIR"
|
|
for ext in "${EXTENSIONS[@]}"; do
|
|
# Find files with the current extension
|
|
find "$DIR" -type f -iname "*.$ext" | while IFS= read -r file; do
|
|
# Quote the filename to handle spaces correctly
|
|
ERRORS=$(test_video "$file")
|
|
if [[ -n "$ERRORS" ]]; then
|
|
echo -e "\nErrors found in: $file"
|
|
echo "$ERRORS"
|
|
fi
|
|
done
|
|
done
|
|
|
|
echo -e "\nScan complete."
|