Module: FfmpegProgress::Utils
- Included in:
- Ffmpeg
- Defined in:
- lib/ffmpeg_progress.rb
Overview
Helper methods.
Instance Method Summary collapse
-
#colorize(string, color) ⇒ String
Colorize a string for the terminal (256-color mode).
-
#parse_ffmpeg_time(time_string) ⇒ Integer
Parse a time string in the
ffmpegHH:MM:SS.ms format and return seconds.
Instance Method Details
#colorize(string, color) ⇒ String
Colorize a string for the terminal (256-color mode).
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.
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 |