You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
776 B

  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. movie = FFMPEG::Movie.new(@file.path)
  8. attachment.instance.type = MediaAttachment.types[:gifv] unless movie.audio_codec
  9. Paperclip::Transcoder.make(file, actual_options(movie), attachment)
  10. end
  11. private
  12. def actual_options(movie)
  13. opts = options[:passthrough_options]
  14. if opts && opts[:video_codecs].include?(movie.video_codec) && opts[:audio_codecs].include?(movie.audio_codec) && opts[:colorspaces].include?(movie.colorspace)
  15. opts[:options]
  16. else
  17. options
  18. end
  19. end
  20. end
  21. end