Class: FFMPEG::ScreenRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/ffmpeg/screenrecorder.rb,
lib/ffmpeg/version.rb

Overview

Since:

  • 1.0.0-beta

Constant Summary collapse

VERSION =
'1.0.0'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ScreenRecorder

Returns a new instance of ScreenRecorder.

Since:

  • 1.0.0-beta



12
13
14
15
16
17
# File 'lib/ffmpeg/screenrecorder.rb', line 12

def initialize(options = {})
  @options = RecorderOptions.new(options)
  @video   = nil
  @process = nil
  initialize_logger(@options.log_level)
end

Instance Attribute Details

#optionsObject (readonly)

Since:

  • 1.0.0-beta



10
11
12
# File 'lib/ffmpeg/screenrecorder.rb', line 10

def options
  @options
end

#videoObject (readonly)

Since:

  • 1.0.0-beta



10
11
12
# File 'lib/ffmpeg/screenrecorder.rb', line 10

def video
  @video
end

Instance Method Details

#discardObject Also known as: delete

Discards the recorded file. Useful in automated testing when a test passes and the recorded file is no longer needed.

Since:

  • 1.0.0-beta



48
49
50
# File 'lib/ffmpeg/screenrecorder.rb', line 48

def discard
  FileUtils.rm options.output
end

#startObject

Starts the recording

Since:

  • 1.0.0-beta



22
23
24
25
26
27
28
29
30
# File 'lib/ffmpeg/screenrecorder.rb', line 22

def start
  @video     = nil # New file

  start_time = Time.now
  @process   = start_ffmpeg
  elapsed    = Time.now - start_time
  FFMPEG.logger.debug "Process started in #{elapsed}s"
  FFMPEG.logger.info 'Recording...'
  @process
end

#stopObject

Stops the recording

Since:

  • 1.0.0-beta



35
36
37
38
39
40
41
# File 'lib/ffmpeg/screenrecorder.rb', line 35

def stop
  FFMPEG.logger.debug 'Stopping ffmpeg.exe...'
  elapsed = kill_ffmpeg
  FFMPEG.logger.debug "Stopped ffmpeg.exe in #{elapsed}s"
  FFMPEG.logger.info 'Recording complete.'
  @video = Movie.new(options.output)
end