Class: FFMPEG::Transcoder
- Inherits:
-
Object
- Object
- FFMPEG::Transcoder
- Defined in:
- lib/ffmpeg/transcoder.rb
Constant Summary collapse
- @@timeout =
30
Class Attribute Summary collapse
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #encoded ⇒ Object
- #encoding_succeeded? ⇒ Boolean
-
#initialize(input, output_file, options = EncodingOptions.new, transcoder_options = {}) ⇒ Transcoder
constructor
A new instance of Transcoder.
- #run(&block) ⇒ Object
- #timeout ⇒ Object
Constructor Details
#initialize(input, output_file, options = EncodingOptions.new, transcoder_options = {}) ⇒ Transcoder
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ffmpeg/transcoder.rb', line 13 def initialize(input, output_file, = EncodingOptions.new, = {}) if input.is_a?(FFMPEG::Movie) @movie = input @input = input.path end @output_file = output_file if .is_a?(Array) || .is_a?(EncodingOptions) = elsif .is_a?(Hash) = EncodingOptions.new() else raise ArgumentError, "Unknown options format '#{options.class}', should be either EncodingOptions, Hash or Array." end = @errors = [] @input = [:input] unless [:input].nil? = [:input_options] || [] iopts = [] .each { |k, v| iopts += ['-' + k.to_s, v] } @command = [FFMPEG.ffmpeg_binary, '-y', *iopts, '-i', @input, *.to_a, @output_file] end |
Class Attribute Details
.timeout ⇒ Object
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/ffmpeg/transcoder.rb', line 10 def timeout @timeout end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/ffmpeg/transcoder.rb', line 5 def command @command end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
5 6 7 |
# File 'lib/ffmpeg/transcoder.rb', line 5 def input @input end |
Instance Method Details
#encoded ⇒ Object
58 59 60 |
# File 'lib/ffmpeg/transcoder.rb', line 58 def encoded @encoded ||= Movie.new(@output_file) end |
#encoding_succeeded? ⇒ Boolean
52 53 54 55 56 |
# File 'lib/ffmpeg/transcoder.rb', line 52 def encoding_succeeded? @errors << "no output file created" and return false unless File.exist?(@output_file) @errors << "encoded file is invalid" and return false unless encoded.valid? true end |
#run(&block) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/ffmpeg/transcoder.rb', line 42 def run(&block) transcode_movie(&block) if [:validate] validate_output_file(&block) return encoded else return nil end end |
#timeout ⇒ Object
62 63 64 |
# File 'lib/ffmpeg/transcoder.rb', line 62 def timeout self.class.timeout end |