Class: RVideo::Tools::Mencoder
- Inherits:
-
Object
- Object
- RVideo::Tools::Mencoder
- Includes:
- AbstractTool::InstanceMethods
- Defined in:
- lib/rvideo/tools/mencoder.rb
Instance Attribute Summary collapse
-
#audio_size ⇒ Object
readonly
Returns the value of attribute audio_size.
-
#bitrate ⇒ Object
readonly
Returns the value of attribute bitrate.
-
#fps ⇒ Object
readonly
Returns the value of attribute fps.
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#video_size ⇒ Object
readonly
Returns the value of attribute video_size.
Attributes included from AbstractTool::InstanceMethods
#command, #options, #raw_result
Instance Method Summary collapse
- #original_fps ⇒ Object
- #parse_result(result) ⇒ Object
- #sanitary_match(regexp, string) ⇒ Object
- #tool_command ⇒ Object
Methods included from AbstractTool::InstanceMethods
#execute, #initialize, #interpolate_variables, #matched_variable
Instance Attribute Details
#audio_size ⇒ Object (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 |
#bitrate ⇒ Object (readonly)
Returns the value of attribute bitrate.
6 7 8 |
# File 'lib/rvideo/tools/mencoder.rb', line 6 def bitrate @bitrate end |
#fps ⇒ Object (readonly)
Returns the value of attribute fps.
6 7 8 |
# File 'lib/rvideo/tools/mencoder.rb', line 6 def fps @fps end |
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
6 7 8 |
# File 'lib/rvideo/tools/mencoder.rb', line 6 def frame @frame end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/rvideo/tools/mencoder.rb', line 6 def size @size end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
6 7 8 |
# File 'lib/rvideo/tools/mencoder.rb', line 6 def time @time end |
#video_size ⇒ Object (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
#original_fps ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rvideo/tools/mencoder.rb', line 12 def original_fps inspect_original if @original.nil? if @original.fps "-r #{@original.fps}" else "" end end |
#parse_result(result) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rvideo/tools/mencoder.rb', line 21 def parse_result(result) if m = /Exiting.*No output file specified/.match(result) raise TranscoderError::InvalidCommand, "no command passed to mencoder, or no output file specified" end if m = /Sorry, this file format is not recognized\/supported/.match(result) raise TranscoderError::InvalidFile, "unknown format" end if m = /Cannot open file\/device./.match(result) raise TranscoderError::InvalidFile, "I/O error" end if m = /File not found:$/.match(result) raise TranscoderError::InvalidFile, "I/O error" end video_details = result.match /Video stream:(.*)$/ if video_details @bitrate = sanitary_match(/Video stream:\s*([0-9.]*)/, video_details[0]) @video_size = sanitary_match(/size:\s*(\d*)\s*(\S*)/, video_details[0]) @time = sanitary_match(/bytes\s*([0-9.]*)/, video_details[0]) @frame = sanitary_match(/secs\s*(\d*)/, video_details[0]) @fps = (@frame.to_f / @time.to_f).round_to(3) elsif result =~ /Video stream is mandatory/ raise TranscoderError::InvalidFile, "Video stream required, and no video stream found" end audio_details = result.match /Audio stream:(.*)$/ if audio_details @audio_size = sanitary_match(/size:\s*(\d*)\s*(\S*)/, audio_details[0]) else @audio_size = 0 end @size = (@video_size.to_i + @audio_size.to_i).to_s end |
#sanitary_match(regexp, string) ⇒ Object
58 59 60 61 |
# File 'lib/rvideo/tools/mencoder.rb', line 58 def sanitary_match(regexp, string) match = regexp.match(string) return match[1] if match end |
#tool_command ⇒ Object
8 9 10 |
# File 'lib/rvideo/tools/mencoder.rb', line 8 def tool_command 'mencoder' end |