Sony Camera API Wrapper
Clone or download
Latest commit d7ff120 Sep 9, 2014
Failed to load latest commit information.
bin init Jul 19, 2014
examples full screen via CSS Sep 9, 2014
lib bump version Sep 9, 2014
spec spec for device_description Sep 9, 2014
.gitignore add gitignore Aug 2, 2014
.rspec rspec -init Aug 2, 2014 add for note Aug 4, 2014 update readme Aug 5, 2014
Rakefile add bundler gem tasks Aug 2, 2014
sonycam.gemspec replace nokogiri with built-in library (rexml) Aug 4, 2014


A Sony Camera Remote API wrapper.


$ gem install sonycam

CLI Usage

$ sonycam api actTakePicture

The command above will prints the result as JSON format, you can process it with pipe, for example:

$ sonycam api actTakePicture | ruby -rjson -e "puts JSON.parse("

The best way to learn sonycam CLI is make use of sonycam help command.


If you've already known the API URL:

require 'sonycam'
api = ""
api.request :actTakePicture
# => [[""]]
api.request :actZoom, :in, :start
# => 0

Get API URL from device description:

device = ""
device.api_url         # => ""
device.api_url :camera # => ""
device.api_url :system # => ""
device.api_url :guide  # => ""

Get device description location:

location = Sonycam::Scanner.scan.first location

Sonycam::Scanner#scan returns an array of URL string where device description is located. Generally, it only contains 1 element unless you connect to more than 2 cameras.

Error Handling

api_client.request :actZoom, :in, :asdf
# => Sonycam::Error::IllegalArgument
api_client.request :actBoom
# => Sonycam::Error::NoSuchMethod: actBoom

Livestream do |packet|
  packet[:payload_data][:jpeg_data] # JPEG binary

For detail, read, lib/sonycam/packet.rb and examples/server.rb.

CLI Example

sonycam liveview will print JPEG data stream to STDOUT, it can be easily used in pipe with commands such as ffmpeg, for example:

Record to mp4:

$ sonycam liveview | ffmpeg -f image2pipe -c mjpeg -i pipe:0 -codec copy liveview.mp4
$ open examples/index.html

ffserver Stream:

$ ffserver -f examples/ffserver.conf
$ sonycam liveview | ffmpeg -f image2pipe  -c mjpeg -i pipe:0 -codec copy
$ open examples/index.html