Module: ScreenRecorder::Screenshot Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
All screenshot related code
Instance Method Summary collapse
-
#screenshot(filename, resolution = nil) ⇒ Object
private
Takes a screenshot in the current context (input) - desktop or current window.
-
#screenshot_cmd(filename:, resolution: nil) ⇒ Object
private
Parameters to capture a single frame.
Instance Method Details
#screenshot(filename, resolution = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Takes a screenshot in the current context (input) - desktop or current window
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/screen-recorder/screenshot.rb', line 7 def screenshot(filename, resolution = nil) ScreenRecorder.logger.debug "Screenshot filename: #{filename}, resolution: #{resolution}" cmd = screenshot_cmd(filename: filename, resolution: resolution) process = execute_command(cmd) exit_code = wait_for_process_exit(process) # 0 (success) or 1 (fail) if exit_code&.zero? ScreenRecorder.logger.info "Screenshot: #{filename}" return filename end ScreenRecorder.logger.error 'Failed to take a screenshot.' nil end |
#screenshot_cmd(filename:, resolution: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parameters to capture a single frame
23 24 25 26 27 |
# File 'lib/screen-recorder/screenshot.rb', line 23 def screenshot_cmd(filename:, resolution: nil) resolution = resolution ? resolution_arg(resolution) : nil # -f overwrites existing file "#{ffmpeg_bin} -f #{.capture_device} -i #{.input} -framerate 1 -frames:v 1 #{resolution}#{filename}" end |