Sha256: e4f5c02be5bbfa192226ddb9a715b61767da7d427f724e1351e60237e6c4e977

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module X11Recorder
  class Display

    DEFAULT_OPTIONS = {
      :filename => './test.mp4',
      :codec => 'mpeg4',
      :display => ENV['DISPLAY'],
      :frame_rate => '5',
      :frame_size => '1024x768'
    }

    def initialize(opts = {})
      @options = DEFAULT_OPTIONS.dup.merge(opts)
    end

    def start
      @recorder = create_process
      @recorder.start
    end

    def stop
      @recorder && @recorder.stop
      @recorder = nil
    end

    private

    def create_process
      @output = @options[:filename]

      process = ChildProcess.build(
        'ffmpeg',
        '-an',
        '-y',
        '-f', 'x11grab',
        '-r', @options[:frame_rate],
        '-s', @options[:frame_size],
        '-i', @options[:display],
        '-vcodec', @options[:codec],
        @options[:filename]
      )

      process.io.stdout = process.io.stderr = File.open('/dev/null', 'w')
      process
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
x11_recorder-0.0.1 lib/x11_recorder/display.rb