lib/ffmpeg/transcoder.rb in streamio-ffmpeg-0.6.0 vs lib/ffmpeg/transcoder.rb in streamio-ffmpeg-0.6.2
- old
+ new
@@ -63,11 +63,11 @@
@errors << "encoded file is invalid"
return false
end
precision = 1.1
- unless !(encoded.duration >= (@movie.duration * precision) or encoded.duration <= (@movie.duration / precision))
+ unless @movie.uncertain_duration? || !(encoded.duration >= (@movie.duration * precision) or encoded.duration <= (@movie.duration / precision))
@errors << "encoded file duration differed from original (original: #{@movie.duration}sec, encoded: #{encoded.duration}sec)"
return false
end
true
@@ -77,15 +77,18 @@
@encoded ||= Movie.new(@output_file)
end
private
def apply_transcoder_options
+ return if @movie.calculated_aspect_ratio.nil?
case @transcoder_options[:preserve_aspect_ratio].to_s
when "width"
- new_height = (@raw_options.width / @movie.calculated_aspect_ratio).to_i
+ new_height = @raw_options.width / @movie.calculated_aspect_ratio
+ new_height = new_height.ceil.even? ? new_height.ceil : new_height.floor
@raw_options[:resolution] = "#{@raw_options.width}x#{new_height}"
when "height"
- new_width = (@raw_options.height * @movie.calculated_aspect_ratio).to_i
+ new_width = @raw_options.height * @movie.calculated_aspect_ratio
+ new_width = new_width.ceil.even? ? new_width.ceil : new_width.floor
@raw_options[:resolution] = "#{new_width}x#{@raw_options.height}"
end
end
end
end