lib/bulldog/processor/ffmpeg.rb in bulldog-0.0.9 vs lib/bulldog/processor/ffmpeg.rb in bulldog-0.0.10
- old
+ new
@@ -64,12 +64,16 @@
if (attribute = params[:assign_to])
basename = "recorded_frame.#{params[:format]}"
output_path = record.send(attribute).interpolate_path(:original, :basename => basename)
@still_frame_callbacks << lambda do
- file = SavedFile.new(output_path, :file_name => basename)
- record.update_attribute(attribute, file)
+ if existing_frame_path(attribute) == output_path
+ attachment.reload
+ else
+ file = SavedFile.new(output_path, :file_name => basename)
+ record.update_attribute(attribute, file)
+ end
end
else
output_path = output_file(style.name)
end
@@ -155,9 +159,14 @@
command = [self.class.ffmpeg_path]
command << '-i' << input_file
command.concat(@arguments)
Bulldog.run(*command) or
record.errors.add name, "convert failed (status #$?)"
+ end
+
+ def existing_frame_path(attribute)
+ stream = record.send(attribute).stream
+ stream && stream.path
end
def run_still_frame_callbacks
@still_frame_callbacks.each(&:call)
end