2017-03-05 23:55:24 +02: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 02:09:12 +03:00
|
|
|
|
2017-03-05 23:55:24 +02:00
|
|
|
attachment.instance.type = MediaAttachment.types[:gifv] unless meta[:audio_encode]
|
2019-10-03 02:09:12 +03:00
|
|
|
options[:format] = File.extname(attachment.instance.file_file_name)[1..-1] if options[:keep_same_format]
|
2017-03-05 23:55:24 +02:00
|
|
|
|
|
|
|
Paperclip::Transcoder.make(file, options, attachment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|