ffmpeg:video:duration
This is an old revision of the document!
ffmpeg - Video - Duration
# Use perl-regex. ffmpeg -i "input.mkv" -c copy -f null /dev/null 2>&1 | tail -n 1 | grep -Po "(?<=time=)([0-9]{1,2}:[0-9]{2}:[0-9]{2})" or # Use extended-regex. ffmpeg -i "input.mkv" -c copy -f null /dev/null 2>&1 | tail -n 1 | grep -oE "[0-9]{1}:[0-9]{2}:[0-9]{2}" or ffmpeg -i "input.mkv" -c copy -f null /dev/null 2>&1 | grep -oE "[0-9]{1}:[0-9]{2}:[0-9]{2}" | tail -n 1 or ffmpeg -i "input.mkv" 2>&1 | grep -oE "[0-9]{1}:[0-9]{2}:[0-9]{2}" | head -n 1
NOTE: This returns an estimate of the duration based on the bitrate and size of the file.
ffmpeg/video/duration.1748369288.txt.gz · Last modified: 2025/05/27 18:08 by peter