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, log = 'ffmpeg.log') ⇒ 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, log = 'ffmpeg.log') ⇒ 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 19 20 |
# File 'lib/screen-recorder/screenshot.rb', line 7 def screenshot(filename, resolution = nil, log = 'ffmpeg.log') ScreenRecorder.logger.debug "Screenshot filename: #{filename}, resolution: #{resolution}" cmd = screenshot_cmd(filename: filename, resolution: resolution) process = execute_command(cmd, log) # exits when done process.poll_for_exit(5) if process.exited? 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
25 26 27 28 29 |
# File 'lib/screen-recorder/screenshot.rb', line 25 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 |