Module: VNCRec::Writers

Defined in:
lib/vncrec/writers.rb

Overview

Writers are wrappers for video files.

Defined Under Namespace

Classes: FFmpeg, RawVideo

Class Method Summary collapse

Class Method Details

.get_writer(filename, opts = {}) ⇒ Object


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/vncrec/writers.rb', line 189

def self.get_writer(filename, opts = {})
  begin
    File.write(filename, '')
  rescue Errno::EACCES
    raise 'Cannot create output file'
  end
  @path, @filename = File.split filename
  @extname = File.extname filename
  return RawVideo.new(@path + '/' + @filename) if @extname == '.raw'
  if @extname.empty?
    if @path != '/dev'
      return RawVideo.new(@path + '/' + @filename + '.raw')
    else
      return FFmpeg.new(@path + '/' + @filename, opts)
    end
  else
    return FFmpeg.new(@path + '/' + @filename, opts)
  end
end