video_transcoder.rb 554 B

12345678910111213141516
  1. # frozen_string_literal: true
  2. module Paperclip
  3. # This transcoder is only to be used for the MediaAttachment model
  4. # to check when uploaded videos are actually gifv's
  5. class VideoTranscoder < Paperclip::Processor
  6. def make
  7. meta = ::Av.cli.identify(@file.path)
  8. attachment.instance.type = MediaAttachment.types[:gifv] unless meta[:audio_encode]
  9. options[:format] = File.extname(attachment.instance.file_file_name)[1..-1] if options[:keep_same_format]
  10. Paperclip::Transcoder.make(file, options, attachment)
  11. end
  12. end
  13. end