Class: ScreenRecorder::Options Private

Inherits:
Object
  • Object
show all
Defined in:
lib/screen-recorder/options.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0-beta11

Constant Summary collapse

DEFAULT_LOG_FILE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0-beta11

'ffmpeg.log'.freeze
DEFAULT_FPS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0-beta11

15.0
DEFAULT_MAC_INPUT_PIX_FMT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

For avfoundation

Since:

  • 1.0.0-beta11

'uyvy422'.freeze
DEFAULT_PIX_FMT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0-beta11

'yuv420p'.freeze
YUV420P_SCALING =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0-beta11

'"scale=trunc(iw/2)*2:trunc(ih/2)*2"'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Options

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Options.

Since:

  • 1.0.0-beta11



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/screen-recorder/options.rb', line 15

def initialize(options)
  # @todo Consider using OpenStruct
  @all = verify_options options
  advanced[:input] = default_advanced_input.merge(advanced_input)
  advanced[:output] = default_advanced_output.merge(advanced_output)
  advanced[:log] ||= DEFAULT_LOG_FILE

  # Fix for using yuv420p pixel format for output
  # @see https://www.reck.dk/ffmpeg-libx264-height-not-divisible-by-2/
  advanced_output[:vf] = YUV420P_SCALING if advanced_output[:pix_fmt] == 'yuv420p'
end

Instance Attribute Details

#allObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0-beta11



7
8
9
# File 'lib/screen-recorder/options.rb', line 7

def all
  @all
end

Instance Method Details

#advancedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns given values that are optional

Since:

  • 1.0.0-beta11



51
52
53
# File 'lib/screen-recorder/options.rb', line 51

def advanced
  @all[:advanced] ||= {}
end

#capture_deviceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns capture device in use

Since:

  • 1.0.0-beta11



37
38
39
# File 'lib/screen-recorder/options.rb', line 37

def capture_device
  determine_capture_device
end

#framerateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns given framerate

Since:

  • 1.0.0-beta11



58
59
60
61
# File 'lib/screen-recorder/options.rb', line 58

def framerate
  ScreenRecorder.logger.warn '#framerate will not be available in the next release. Use #advanced instead.'
  advanced[:output][:framerate]
end

#inputObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns given input file or input

Since:

  • 1.0.0-beta11



30
31
32
# File 'lib/screen-recorder/options.rb', line 30

def input
  @all[:input]
end

#logObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns given log filename

Since:

  • 1.0.0-beta11



66
67
68
# File 'lib/screen-recorder/options.rb', line 66

def log
  advanced[:log]
end

#outputObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns given output filepath

Since:

  • 1.0.0-beta11



44
45
46
# File 'lib/screen-recorder/options.rb', line 44

def output
  @all[:output]
end

#parsedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a String with all options parsed and ready for the ffmpeg process to use

Since:

  • 1.0.0-beta11



74
75
76
77
78
79
80
81
# File 'lib/screen-recorder/options.rb', line 74

def parsed
  vals = "-f #{capture_device} "
  vals << parse_advanced(advanced_input)
  vals << "-i #{input} " unless advanced_input[:i] # Input provided by user
  vals << parse_advanced(advanced)
  vals << parse_advanced(advanced_output)
  vals << output
end