Module: FfmpegProgress::Utils

Included in:
Ffmpeg
Defined in:
lib/ffmpeg_progress.rb

Overview

Helper methods.

Instance Method Summary collapse

Instance Method Details

#colorize(string, color) ⇒ String

Colorize a string for the terminal (256-color mode).

Parameters:

  • string (String)
  • color (Integer)

Returns:

  • (String)


42
43
44
# File 'lib/ffmpeg_progress.rb', line 42

def colorize(string, color)
  "\x1b[38;5;#{color}m#{string}\x1b[0m"
end

#parse_ffmpeg_time(time_string) ⇒ Integer

Parse a time string in the ffmpeg HH:MM:SS.ms format and return seconds.

Parameters:

  • time_string (String)

Returns:

  • (Integer)


50
51
52
53
54
# File 'lib/ffmpeg_progress.rb', line 50

def parse_ffmpeg_time(time_string)
  array = time_string.rpartition('.').first.split(':').map(&:to_i)

  array[0] * 3600 + array[1] * 60 + array[2]
end