module Video2gif::Utils
Public Class Methods
duration_to_seconds(duration)
click to toggle source
Convert “[-][HH:]MM:SS” to “[-]S+”. ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
# 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)
click to toggle source
# 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