Module: FFmpegProgress::Utils

Included in:
FFmpeg
Defined in:
lib/ffmpeg_progress/utils.rb

Overview

Helper methods.

Constant Summary collapse

BELL =

The bell file to be used to signal completion.

"#{File.expand_path('../../..', __FILE__)}/" \
'assets/LucasGonze_StLouisWaltz.ogg'

Instance Method Summary collapse

Instance Method Details

#bellInteger

Play the bell sound.

Returns:

  • (Integer)

    the PID of the bell process.



11
12
13
14
15
16
# File 'lib/ffmpeg_progress/utils.rb', line 11

def bell
  ffplay =
    spawn "ffplay -nodisp -autoexit '#{BELL}' &> /dev/null"
  Process.detach(ffplay)
  ffplay
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)


23
24
25
26
27
# File 'lib/ffmpeg_progress/utils.rb', line 23

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

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