Created
June 1, 2017 09:59
-
-
Save kencoba/9324010cff7dc62e930678420c0265da to your computer and use it in GitHub Desktop.
Listing duration of mp4s.
This file contains hidden or 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
#! /bin/sh | |
exec ruby -S -x "$0" "$@" | |
#! ruby | |
def h_mm_ss(sec) | |
min, ss = sec.to_i.divmod(60) | |
hh , mm = min.divmod(60) | |
"%dh%02dm%02ds" % [hh, mm, ss] | |
end | |
while $file = gets | |
$file.chomp! | |
$result = `ffprobe #{$file} -hide_banner -show_entries format=duration` | |
$duration = $result.gsub(/(\s)/,"").match(%r{\[FORMAT\]duration=(.+?)\[/FORMAT\]})[1].to_i | |
print $duration, "\t" , h_mm_ss($duration), "\t", $file, "\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment