Skip to content

Instantly share code, notes, and snippets.

@glennzw
Last active April 28, 2016 14:45
Show Gist options
  • Save glennzw/11cbb1557665671473f350795116ef89 to your computer and use it in GitHub Desktop.
Save glennzw/11cbb1557665671473f350795116ef89 to your computer and use it in GitHub Desktop.
Video File Checker
#!/bin/bash
# Check all MP4 video files to see if they're corrupt, then merge into one file.
which avprobe
if [ $? -ne 0 ]; then echo "Please install avprobe"; exit; fi
find . -type f -iname "*.mp4" -print0 | while IFS= read -r -d $'\0' line; do
avprobe "$line" &> /dev/null
if [ $? -ne 0 ]; then
echo "Deleting corrupt file $line"
rm "$line"
fi
done
echo "Merging..."
filesList=""
for file in $(ls *.mp4|sort -n);do
filesList="$filesList -cat $file"
done
MP4Box $filesList -new merged_files_$(date +%Y%m%d_%H%M%S).mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment