Module: Video2gif::Utils
- Defined in:
- lib/video2gif/utils.rb
Class Method Summary collapse
Class Method Details
.duration_to_seconds(duration) ⇒ Object
Convert “[-][HH:]MM:SS” to “[-]S+”. ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
16 17 18 19 20 21 |
# File 'lib/video2gif/utils.rb', line 16 def self.duration_to_seconds(duration) return duration unless duration.include?(?:) m = duration.match(/(?<sign>-)?(?<hours>\d+:)?(?<minutes>\d+):(?<seconds>\d+)(?<millis>\.\d+)?/) seconds = m[:hours].to_i * 60 * 60 + m[:minutes].to_i * 60 + m[:seconds].to_i duration = "#{m[:sign]}#{seconds}#{m[:millis]}" end |
.is_executable?(command) ⇒ Boolean
6 7 8 9 10 11 12 |
# File 'lib/video2gif/utils.rb', line 6 def self.is_executable?(command) ENV['PATH'].split(File::PATH_SEPARATOR).map do |path| (ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']).map do |extension| File.executable?(File.join(path, "#{command}#{extension}")) end end.flatten.any? end |