trackduration 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/trackduration.rb +12 -4
- metadata +1 -1
data/lib/trackduration.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
class Trackduration
|
2
2
|
def self.get_duration(inputfile)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
if File.exists?(inputfile)
|
4
|
+
begin
|
5
|
+
system("ffmpeg -i '#{inputfile}' 2>&1 | grep Duration > duration")
|
6
|
+
duration = File.open("duration","r").read.split(" ")[1].gsub(",",'')
|
7
|
+
File.delete("duration")
|
8
|
+
duration
|
9
|
+
rescue Exception=>e
|
10
|
+
puts "#{e.massage}"
|
11
|
+
end
|
12
|
+
else
|
13
|
+
puts "#{inputfile} doesn't exist."
|
14
|
+
end
|
7
15
|
end
|
8
16
|
end
|