lib/bulldog/processor/ffmpeg.rb in bulldog-0.0.7 vs lib/bulldog/processor/ffmpeg.rb in bulldog-0.0.8

- old
+ new

@@ -5,25 +5,25 @@ attr_accessor :ffmpeg_path end def initialize(*args) super - @operation = nil @arguments = style_list_map @still_frame_callbacks = style_list_map end def process return if styles.empty? super - run_ffmpeg run_still_frame_callbacks end def process_style(*args) + @operation = nil super - run_default_operation + set_default_operation + run_ffmpeg end def use_threads(num_threads) operate '-threads', num_threads end @@ -35,10 +35,11 @@ parse_audio_option(params) style_option '-vcodec', params[:video_codec] style_option '-acodec', params[:audio_codec] preset_option '-vpre', params[:video_preset] preset_option '-apre', params[:audio_preset] + preset_option '-spre', params[:subtitle_preset] operate '-s', attachment.dimensions(style.name).join('x') if params[:size] style_option '-r', params[:frame_rate] style_option '-b', params[:video_bit_rate] style_option '-ar', params[:sampling_rate] style_option '-ab', params[:audio_bit_rate] @@ -48,11 +49,10 @@ style_option '-b_strategy', params[:b_strategy] style_option '-bufsize', params[:buffer_size] style_option '-coder', params[:coder] style_option '-v', params[:verbosity] style_option '-flags', params[:flags] - preset_option '-spre', params[:subtitle_preset] style_option '-y', output_file(style.name) end def record_frame(params={}, &block) @operation = :record_frame @@ -89,11 +89,11 @@ def operate(*args) @arguments[style].concat args.map(&:to_s) end - def run_default_operation + def set_default_operation encode if @operation.nil? end def parse_video_option(params) value = params.delete(:video) or @@ -150,16 +150,14 @@ raise ProcessingError, "no default codec for '#{format}' - please use :codec to specify" end end def run_ffmpeg - @arguments.each do |style, arguments| - command = [self.class.ffmpeg_path] - command << '-i' << input_file - command.concat(arguments) - Bulldog.run(*command) or - record.errors.add name, "convert failed (status #$?)" - end + command = [self.class.ffmpeg_path] + command << '-i' << input_file + command.concat(@arguments[style]) + Bulldog.run(*command) or + record.errors.add name, "convert failed (status #$?)" end def run_still_frame_callbacks @still_frame_callbacks.each do |style, callbacks| callbacks.each{|c| c.call}