how to get video file fps using ffmpeg?

how to get video file fps using ffmpeg?

## get FPS
ffprobe 'Upstream Color 2013 1080p x264.mkv' -v 0 -select_streams v -print_format flat -show_entries stream=r_frame_rate

ffprobe -v 0 -of csv=p=0 -select_streams V:0 -show_entries stream=r_frame_rate infile
##return 2997/100

## get avg FPS
fraction=$(ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=nw=1:nk=1 "${input}")
python -c "print (round(${fraction}))"

# Get duration and fps
duration=$($FFMPEG -i $input 2>&1 | sed -n "s/.* Duration: \([^,]*\), start: .*/\1/p")
fps=$($FFMPEG -i $input 2>&1 | sed -n "s/.*, \(.*\) tb.*/\1/p")

hours=$(echo $duration | cut -d":" -f1)
minutes=$(echo $duration | cut -d":" -f2)
seconds=$(echo $duration | cut -d":" -f3)
# For some reason, we have to multiply by two (no idea why...)
# Get the integer part with cut
frames=$(echo "($hours*3600+$minutes*60+$seconds)*$fps*2" | bc | cut -d"." -f1)

Leave a Reply

Your email address will not be published. Required fields are marked *