Skip to content

Instantly share code, notes, and snippets.

@hilbix
Created February 1, 2015 04:11
Show Gist options
  • Save hilbix/97af7e815b40bd395530 to your computer and use it in GitHub Desktop.
Save hilbix/97af7e815b40bd395530 to your computer and use it in GitHub Desktop.
Print runtime length of a video (and number of estimated frames)
#!/bin/bash
avcheck()
{
avprobe "$1" -show_packets 2>/dev/null |
awk -F'=' -vN="$1" '
/^\[/ { if (arm && k["codec_type"]=="video") { last=k["dts_time"]; # printf "%s", k["flags"];
}; delete k; arm=1; next; }
arm { k[$1]=$2; }
$0=="codec_type=video" { frames++; }
END { printf("%-40s %d:%02d:%02d %s\n", N, last/3600, last/60%60, last%60, frames); }'
}
for a
do
avcheck "$a"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment