Permalink
Browse files

Added skip_encoding_validation transcoder option

  • Loading branch information...
1 parent 2eb6f8e commit 57a2fab7e4e11b87bee2533912134d9edb2fa606 @rangsikitpho committed Aug 1, 2011
Showing with 14 additions and 2 deletions.
  1. +3 −0 lib/ffmpeg/transcoder.rb
  2. +11 −2 spec/ffmpeg/transcoder_spec.rb
@@ -69,6 +69,7 @@ def encoding_succeeded?
end
unless encoded.valid?
+ return true if @skip_encoding_validation
@errors << "encoded file is invalid"
return false
end
@@ -104,6 +105,8 @@ def apply_transcoder_options
new_width += 1 if new_width.odd?
@raw_options[:resolution] = "#{new_width}x#{@raw_options.height}"
end
+
+ @skip_encoding_validation = !! @transcoder_options[:skip_encoding_validation]
end
def validate_duration?
@@ -116,7 +116,7 @@ module FFMPEG
transcoder = Transcoder.new(movie, "#{tmp_path}/fail.flv")
lambda { transcoder.run }.should raise_error(RuntimeError, /no output file created/)
end
-
+
it "should fail if duration differs from original" do
movie = Movie.new("#{fixture_path}/sounds/napoleon.mp3")
movie.stub!(:duration).and_return(200)
@@ -159,6 +159,15 @@ module FFMPEG
Transcoder.new(movie, "#{tmp_path}/durationalized.mp4", :duration => 10).run
}.to_not raise_error
end
+
+ it "should skip the encoding validation if skip_encoding_validation transcoder option is true" do
+ movie = Movie.new("#{fixture_path}/movies/awesome movie.mov")
+ transcoder_options = { :skip_encoding_validation => true }
+ transcoder = Transcoder.new(movie, "#{tmp_path}/skip encoding validation.flv", {}, transcoder_options)
+ output_movie = stub(Movie, :valid? => false)
+ transcoder.stub!(:encoded).and_return(output_movie)
+ lambda { transcoder.run }.should_not raise_error(RuntimeError)
+ end
end
end
-end
+end

0 comments on commit 57a2fab

Please sign in to comment.