Created
September 3, 2016 08:42
-
-
Save qruf/65f5ddda914b9f3854cd2c76bd8da70f to your computer and use it in GitHub Desktop.
ffmpeg progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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