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