Skip to content

Instantly share code, notes, and snippets.

@qruf
Created September 3, 2016 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save qruf/65f5ddda914b9f3854cd2c76bd8da70f to your computer and use it in GitHub Desktop.
Save qruf/65f5ddda914b9f3854cd2c76bd8da70f to your computer and use it in GitHub Desktop.
ffmpeg progress
#! /usr/bin/env gawk
function seconds(h, m, s) {
return h * 3600 + m * 60 + s
}
BEGIN {
RS = "[\r\n]"
}
/^\[/ {
print $0
}
match($0, /^ Duration: (\w+):(\w+):(\w+)/, m) {
duration = seconds(m[1], m[2], m[3])
}
match($0, /^frame=.*time=(\w+):(\w+):(\w+)/, m) {
if (!duration) {
printf("%s\r", $0)
} else {
progress = seconds(m[1], m[2], m[3]) / duration * 100
printf("%d%%\r", progress)
}
}
/^video:/ {
print ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment