Class: RVideo::Tools::Mencoder

Inherits:
Object
  • Object
show all
Includes:
AbstractTool::InstanceMethods
Defined in:
lib/rvideo/tools/mencoder.rb

Instance Attribute Summary collapse

Attributes included from AbstractTool::InstanceMethods

#command, #options, #original, #raw_result

Instance Method Summary collapse

Methods included from AbstractTool::InstanceMethods

#audio_bit_rate, #audio_channels, #audio_sample_rate, #calculate_height, #calculate_width, #execute, #fps, #get_audio_bit_rate, #get_audio_channels, #get_audio_sample_rate, #get_fit_to_height_resolution, #get_fit_to_width_resolution, #get_fps, #get_letterbox_resolution, #get_mono_audio, #get_original_fps, #get_original_resolution, #get_resolution, #get_specific_audio_bit_rate, #get_specific_audio_sample_rate, #get_specific_fps, #get_specific_resolution, #get_stereo_audio, #get_video_quality, #initialize, #resolution, #temp_dir, #valid_dimension?, #video_quality

Instance Attribute Details

#audio_sizeObject (readonly)

Returns the value of attribute audio_size.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def audio_size
  @audio_size
end

#bitrateObject (readonly)

Returns the value of attribute bitrate.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def bitrate
  @bitrate
end

#frameObject (readonly)

Returns the value of attribute frame.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def frame
  @frame
end

#output_fpsObject (readonly)

Returns the value of attribute output_fps.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def output_fps
  @output_fps
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def size
  @size
end

#timeObject (readonly)

Returns the value of attribute time.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def time
  @time
end

#video_sizeObject (readonly)

Returns the value of attribute video_size.



6
7
8
# File 'lib/rvideo/tools/mencoder.rb', line 6

def video_size
  @video_size
end

Instance Method Details

#format_audio_bit_rate(params = {}) ⇒ Object



28
29
30
# File 'lib/rvideo/tools/mencoder.rb', line 28

def format_audio_bit_rate(params={})
  " br=#{params[:bit_rate]}:"
end

#format_audio_channels(params = {}) ⇒ Object



24
25
26
# File 'lib/rvideo/tools/mencoder.rb', line 24

def format_audio_channels(params={})
  " -channels #{params[:channels]}"
end

#format_audio_sample_rate(params = {}) ⇒ Object



32
33
34
# File 'lib/rvideo/tools/mencoder.rb', line 32

def format_audio_sample_rate(params={})
  " -srate #{params[:sample_rate]}"
end

#format_fps(params = {}) ⇒ Object



12
13
14
# File 'lib/rvideo/tools/mencoder.rb', line 12

def format_fps(params={})
  " -ofps #{params[:fps]}" 
end

#format_resolution(params = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rvideo/tools/mencoder.rb', line 16

def format_resolution(params={})
  p = " -vf scale=#{params[:scale][:width]}:#{params[:scale][:height]}"
  if params[:letterbox]
    p += ",expand=#{params[:letterbox][:width]}:#{params[:letterbox][:height]}"
  end
  p += ",harddup"
end

#format_video_quality(params = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rvideo/tools/mencoder.rb', line 36

def format_video_quality(params={})
  bitrate = params[:video_bit_rate].blank? ? nil : params[:video_bit_rate]
  factor = (params[:scale][:width].to_f * params[:scale][:height].to_f * params[:fps].to_f)
  case params[:video_quality]
  when 'low'
    bitrate ||= (factor / 12000).to_i
    " -x264encopts threads=auto:subq=1:me=dia:frameref=1:crf=30:bitrate=#{bitrate} "
  when 'medium'
    bitrate ||= (factor / 9000).to_i
    " -x264encopts threads=auto:subq=3:me=hex:frameref=2:crf=22:bitrate=#{bitrate} "
  when 'high'
    bitrate ||= (factor / 3600).to_i
    " -x264encopts threads=auto:subq=6:me=dia:frameref=3:crf=18:bitrate=#{bitrate} "
  else
    ""
  end
end

#tool_commandObject



8
9
10
# File 'lib/rvideo/tools/mencoder.rb', line 8

def tool_command
  'mencoder'
end