Class: FFMPEG::Transcoder
- Inherits:
-
Object
- Object
- FFMPEG::Transcoder
- Defined in:
- lib/ffmpeg/transcoder.rb
Constant Summary collapse
- @@timeout =
30
Class Method Summary collapse
Instance Method Summary collapse
- #encoded ⇒ Object
- #encoding_succeeded? ⇒ Boolean
-
#initialize(movie, output_file, options = EncodingOptions.new, transcoder_options = {}) ⇒ Transcoder
constructor
A new instance of Transcoder.
- #run(&block) ⇒ Object
Constructor Details
#initialize(movie, output_file, options = EncodingOptions.new, transcoder_options = {}) ⇒ Transcoder
Returns a new instance of Transcoder.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ffmpeg/transcoder.rb', line 16 def initialize(movie, output_file, = EncodingOptions.new, = {}) @movie = movie @output_file = output_file if .is_a?(String) || .is_a?(EncodingOptions) @raw_options = elsif .is_a?(Hash) @raw_options = EncodingOptions.new() else raise ArgumentError, "Unknown options format '#{.class}', should be either EncodingOptions, Hash or String." end @transcoder_options = @errors = [] end |
Class Method Details
.timeout ⇒ Object
12 13 14 |
# File 'lib/ffmpeg/transcoder.rb', line 12 def self.timeout @@timeout end |
.timeout=(time) ⇒ Object
8 9 10 |
# File 'lib/ffmpeg/transcoder.rb', line 8 def self.timeout=(time) @@timeout = time end |
Instance Method Details
#encoded ⇒ Object
50 51 52 |
# File 'lib/ffmpeg/transcoder.rb', line 50 def encoded @encoded ||= Movie.new(@output_file) end |
#encoding_succeeded? ⇒ Boolean
44 45 46 47 48 |
# File 'lib/ffmpeg/transcoder.rb', line 44 def encoding_succeeded? @errors << "no output file created" and return false unless File.exists?(@output_file) @errors << "encoded file is invalid" and return false unless encoded.valid? true end |
#run(&block) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/ffmpeg/transcoder.rb', line 34 def run(&block) transcode_movie(&block) if @transcoder_options[:validate] validate_output_file(&block) return encoded else return nil end end |