2017-03-06 06:55:24 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Paperclip
|
|
|
|
# This transcoder is only to be used for the MediaAttachment model
|
|
|
|
# to check when uploaded videos are actually gifv's
|
|
|
|
class VideoTranscoder < Paperclip::Processor
|
|
|
|
def make
|
|
|
|
meta = ::Av.cli.identify(@file.path)
|
2019-10-03 08:09:12 +09:00
|
|
|
|
2017-03-06 06:55:24 +09:00
|
|
|
attachment.instance.type = MediaAttachment.types[:gifv] unless meta[:audio_encode]
|
2019-10-03 08:09:12 +09:00
|
|
|
options[:format] = File.extname(attachment.instance.file_file_name)[1..-1] if options[:keep_same_format]
|
2017-03-06 06:55:24 +09:00
|
|
|
|
|
|
|
Paperclip::Transcoder.make(file, options, attachment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|