Class: VideoConverter::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/video_converter/input.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, outputs = []) ⇒ Input

Returns a new instance of Input.

Raises:

  • (ArgumentError)


15
16
17
18
# File 'lib/video_converter/input.rb', line 15

def initialize input, outputs = []
  self.input = input or raise ArgumentError.new('Input requred')
  raise ArgumentError.new("#{input} does not exist") unless exists?
end

Class Attribute Details

.metadata_commandObject

Returns the value of attribute metadata_command.



6
7
8
# File 'lib/video_converter/input.rb', line 6

def 
  @metadata_command
end

.show_frames_commandObject

Returns the value of attribute show_frames_command.



6
7
8
# File 'lib/video_converter/input.rb', line 6

def show_frames_command
  @show_frames_command
end

.show_streams_commandObject

Returns the value of attribute show_streams_command.



6
7
8
# File 'lib/video_converter/input.rb', line 6

def show_streams_command
  @show_streams_command
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



13
14
15
# File 'lib/video_converter/input.rb', line 13

def input
  @input
end

#metadataObject

Returns the value of attribute metadata.



13
14
15
# File 'lib/video_converter/input.rb', line 13

def 
  @metadata
end

#output_groups(outputs) ⇒ Object

Returns the value of attribute output_groups.



13
14
15
# File 'lib/video_converter/input.rb', line 13

def output_groups
  @output_groups
end

Instance Method Details

#mean_volumeObject



73
74
75
# File 'lib/video_converter/input.rb', line 73

def mean_volume
  @mean_volume ||= Command.new(Ffmpeg.volume_detect_command, :bin => Ffmpeg.bin, :input => input).capture.match(/mean_volume:\s([-\d.]+)\sdB/).to_a[1]
end

#select_outputs(outputs) ⇒ Object



77
78
79
# File 'lib/video_converter/input.rb', line 77

def select_outputs(outputs)
  outputs.select { |output| !output.path || output.path == input }
end

#to_sObject



20
21
22
# File 'lib/video_converter/input.rb', line 20

def to_s
  input
end

#unescapeObject



24
25
26
# File 'lib/video_converter/input.rb', line 24

def unescape
  input.gsub(/\\+([^n])/, '\1')
end

#video_streamObject



69
70
71
# File 'lib/video_converter/input.rb', line 69

def video_stream
  [:video_streams].first
end