Class: RVideo::Tools::Mencoder
Instance Attribute Summary collapse
#command, #options, #progress, #raw_result
Instance Method Summary
collapse
abstract_attribute_formatter, #audio_bit_rate, #audio_channels, #audio_sample_rate, #calculate_height, #calculate_width, #deinterlace, #do_execute, #execute, #fps, #get_audio_bit_rate, #get_audio_channels, #get_audio_sample_rate, #get_constrain_resolution, #get_deinterlace, #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_padding_resolution, #get_resolution, #get_specific_audio_bit_rate, #get_specific_audio_sample_rate, #get_specific_fps, #get_specific_resolution, #get_stereo_audio, #get_valid_height, #get_valid_width, #get_video_bit_rate, #get_video_bit_rate_max, #get_video_bit_rate_min, #get_video_bit_rate_tolerance, #get_video_quality, #initialize, #original, #original=, #resolution, #resolution_and_padding, #resolution_keep_aspect_ratio, #temp_dir, #valid_dimension?, #video_bit_rate, #video_bit_rate_max, #video_bit_rate_min, #video_bit_rate_tolerance, #video_quality
Instance Attribute Details
#audio_size ⇒ Object
Returns the value of attribute audio_size.
6
7
8
|
# File 'lib/rvideo/tools/mencoder.rb', line 6
def audio_size
@audio_size
end
|
#bitrate ⇒ Object
Returns the value of attribute bitrate.
6
7
8
|
# File 'lib/rvideo/tools/mencoder.rb', line 6
def bitrate
@bitrate
end
|
#frame ⇒ Object
Returns the value of attribute frame.
6
7
8
|
# File 'lib/rvideo/tools/mencoder.rb', line 6
def frame
@frame
end
|
#output_fps ⇒ Object
Returns the value of attribute output_fps.
6
7
8
|
# File 'lib/rvideo/tools/mencoder.rb', line 6
def output_fps
@output_fps
end
|
#size ⇒ Object
Returns the value of attribute size.
6
7
8
|
# File 'lib/rvideo/tools/mencoder.rb', line 6
def size
@size
end
|
#time ⇒ Object
Returns the value of attribute time.
6
7
8
|
# File 'lib/rvideo/tools/mencoder.rb', line 6
def time
@time
end
|
#video_size ⇒ Object
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
#do_execute_with_progress(command, &block) ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'lib/rvideo/tools/mencoder.rb', line 61
def do_execute_with_progress(command,&block)
@raw_result = ''
stderr_result, stdout_result = CommandExecutor::execute_with_block(command, "\r", false) do |line|
progress = parse_progress(line)
block.call(progress) if block && progress
@raw_result += line + "\r"
end
@raw_result += stderr_result
end
|
#execute_with_progress(&block) ⇒ Object
28
29
30
|
# File 'lib/rvideo/tools/mencoder.rb', line 28
def format_audio_bit_rate(params={})
" br=#{params[:bit_rate]}:"
end
|
24
25
26
|
# File 'lib/rvideo/tools/mencoder.rb', line 24
def format_audio_channels(params={})
" -channels #{params[:channels]}"
end
|
32
33
34
|
# File 'lib/rvideo/tools/mencoder.rb', line 32
def format_audio_sample_rate(params={})
" -srate #{params[:sample_rate]}"
end
|
12
13
14
|
# File 'lib/rvideo/tools/mencoder.rb', line 12
def format_fps(params={})
" -ofps #{params[:fps]}"
end
|
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
|
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
|
#parse_progress(line) ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/rvideo/tools/mencoder.rb', line 71
def parse_progress(line)
if line =~ /Pos:[^(]*\((\d+)\%\)/
$1.to_i > 100 ? 100 : $1.to_i
else
nil
end
end
|
8
9
10
|
# File 'lib/rvideo/tools/mencoder.rb', line 8
def tool_command
'mencoder'
end
|