Class: Rubycam::CLI::Commands::Snapshot

Inherits:
VideoCommand
  • Object
show all
Defined in:
lib/rubycam/cli.rb

Instance Method Summary collapse

Instance Method Details

#call(path: 'snapshot.jpg', **options) ⇒ Object



152
153
154
155
156
157
158
159
# File 'lib/rubycam/cli.rb', line 152

def call(path: 'snapshot.jpg', **options)
  with_device(options) do |dev|
    dev.set_format(width: options.fetch(:width).to_i,
                   height: options.fetch(:height).to_i, pixel_format: 'MJPG')
    File.binwrite(path, dev.capture_frame)
    puts "#{dev.card}: wrote #{path} (#{dev.width}x#{dev.height} #{dev.pixel_format})"
  end
end