Sha256: 16c69a5135d689e119c587e1cf8cd2e0821840dc2778133ac73888d6f89e7c38

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

module VncTools
  class Recorder

    attr_reader :display, :output

    def initialize(display, output, opts = {})
      @display = display
      @output  = output
      @options = opts
    end

    def start
      @process = ChildProcess.build(
        "ffmpeg",
        "-an",                                      # no audio,
        "-f", "x11grab",                            # force format
        "-y",                                       # overwrite output files
        "-r", @options[:frame_rate] || "5",         # frame rate
        "-s", @options[:frame_size] || "1024x768",  # frame size
        "-i", "#{display}.0+0,0",                   # display :1
        "-vcodec", @options[:codec] || "mpeg4",     # video codec
        "-sameq", output                            # output
      )

      if $DEBUG
        @process.io.inherit!
      else
        @process.io.stdout = @process.io.stderr = File.open("/dev/null", "w")
      end

      @process.start

      # TODO: this may be too quick to actually catch the failure
      if @process.crashed?
        raise Error, "ffmpeg failed, run with $DEBUG = true for full output"
      end
    end

    def stop
      @process && @process.stop
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vnctools-0.1.1 lib/vnctools/recorder.rb
vnctools-0.1.0 lib/vnctools/recorder.rb
vnctools-0.0.9 lib/vnctools/recorder.rb
vnctools-0.0.9.pre1 lib/vnctools/recorder.rb
vnctools-0.0.8 lib/vnctools/recorder.rb
vnctools-0.0.7 lib/vnctools/recorder.rb
vnctools-0.0.6 lib/vnctools/recorder.rb
vnctools-0.0.5 lib/vnctools/recorder.rb
vnctools-0.0.4 lib/vnctools/recorder.rb
vnctools-0.0.3 lib/vnctools/recorder.rb