Check for Corrupt Media

The only reliable way that I've found (without an exhaustive search) to to actually render the media and see if you get any errors.


# Almost all distros are back to using ffmpeg, but you can sub in
# in avconv here if needed

# enable spaces in file names with IFS, and find any of the popular extensions
IFS=$(echo -en "\n\b")
LIST=`find  -type f -regex '\(.*avi$\|.*mp4$\|.*m4v$\|.*mkv\)'`

# clean up any existing error log
touch error.log

for I in $LIST; do

        RESULT=$("$FFMPEG" -v error -i "$I" -f null - 2>&1)

    if [ ! -z "$RESULT" ] ; then
            echo "Error: $I ($RESULT)"
        echo "OK   : $I"

# If you wanted a quicker check, say just to make sure the file itself was intact
# you can use a stream copy, rather than a render
# "$FFMPEG" -v error -i "$i" -f null -c:v copy -c:a copy - 2> error.log

# An older version I wrote touched a file for each bad media item so you
# could see at a glance in file explorer any problems