Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ In your model:
This will produce:

1. A transcoded `:medium` FLV file with the requested dimensions if they will match the aspect ratio of the original file, otherwise, width will be maintained and height will be recalculated to keep the original aspect ration.
2. A screenshot `:thumb` with the requested dimensions regardless of the aspect ratio.
2. A screenshot `:thumb` with the requested dimensions regardless of the aspect ratio and with `:time => 10`, it captures a frame from the 10th second of the video.

### Meta Data

Expand Down
7 changes: 6 additions & 1 deletion lib/paperclip/paperclip_processors/transcoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize file, options = {}, attachment = nil
@shrink_only = @keep_aspect && modifier == '>'
end

@time = options[:time].nil? ? 3 : options[:time]
@time = options[:time].nil? ? default_time : options[:time]
@auto_rotate = options[:auto_rotate].nil? ? false : options[:auto_rotate]
@pad_color = options[:pad_color].nil? ? "black" : options[:pad_color]

Expand Down Expand Up @@ -105,6 +105,11 @@ def format_geometry geometry
def output_is_image?
[email protected]_s.match(/jpe?g|png|gif$/)
end

def default_time
duration = @meta[:duration].to_f rescue 0
duration < 3 ? 0 : 3
end
end

class Attachment
Expand Down