Find videos by FPS
I produced some videos in 60 FPS, but couldn’t remember which ones. Since, of course, I didn’t label their FPS at the time, I needed to find them in vast sea of 30 FPS videos. Rather than just use a simple grep with ffmpeg to find which ones, I thought it might be more useful to find all videos that have a certain FPS threshold.
Usage: ./60fps.sh [directory]
#!/bin/bash
SAVEIFS=$IFS
IFS=$'\n'
function fpscheck
{
FPS=$(ffmpeg -i "$1" 2>&1 | egrep -o '([0-9]*[.])?[0-9]+ fps' | egrep -o '([0-9]*[.])?[0-9]+')
if [ $? -eq 0 ]
then
TEST=$(echo "$FPS"'>'50 | bc -l)
if [ "$TEST" -eq 1 ]
then
echo "$FPS: $1"
# else
# echo "$FPS: $1"
fi
# else
# echo "Could not get fps from: $1" >&2
fi
}
for FILE in $(find "$1" -type f -name '*')
do
# echo "trying: $FILE..."
fpscheck "$FILE"
done
IFS=$SAVEIFS
If I thought I’d use it more, I’d move the hardcoded FPS test value to an optional argument for the script. Instead, I’ll leave that as an exercise for the reader.