lib/bulldog/processor/ffmpeg.rb in bulldog-0.0.8 vs lib/bulldog/processor/ffmpeg.rb in bulldog-0.0.9
- old
+ new
@@ -5,25 +5,25 @@
attr_accessor :ffmpeg_path
end
def initialize(*args)
super
- @arguments = style_list_map
- @still_frame_callbacks = style_list_map
end
- def process
- return if styles.empty?
- super
- run_still_frame_callbacks
+ def process(styles, options={})
+ super or
+ return
end
def process_style(*args)
@operation = nil
+ @arguments = []
+ @still_frame_callbacks = []
super
set_default_operation
run_ffmpeg
+ run_still_frame_callbacks
end
def use_threads(num_threads)
operate '-threads', num_threads
end
@@ -63,21 +63,21 @@
operate '-vcodec', params[:codec] || default_frame_codec(params)
if (attribute = params[:assign_to])
basename = "recorded_frame.#{params[:format]}"
output_path = record.send(attribute).interpolate_path(:original, :basename => basename)
- @still_frame_callbacks[style] << lambda do
+ @still_frame_callbacks << lambda do
file = SavedFile.new(output_path, :file_name => basename)
record.update_attribute(attribute, file)
end
else
output_path = output_file(style.name)
end
operate '-y', output_path
if block
- @still_frame_callbacks[style] << lambda{instance_exec(output_path, &block)}
+ @still_frame_callbacks << lambda{instance_exec(output_path, &block)}
end
end
private # -----------------------------------------------------
@@ -86,11 +86,11 @@
styles.each{|s| hash[s] = []}
hash
end
def operate(*args)
- @arguments[style].concat args.map(&:to_s)
+ @arguments.concat args.map(&:to_s)
end
def set_default_operation
encode if @operation.nil?
end
@@ -152,18 +152,16 @@
end
def run_ffmpeg
command = [self.class.ffmpeg_path]
command << '-i' << input_file
- command.concat(@arguments[style])
+ command.concat(@arguments)
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}
- end
+ @still_frame_callbacks.each(&:call)
end
end
end
end