This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-03-05 13:55:24 -08: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
|
2020-03-09 15:15:59 -07:00
|
|
|
movie = FFMPEG::Movie.new(@file.path)
|
2019-10-02 16:09:12 -07:00
|
|
|
|
2020-03-09 15:15:59 -07:00
|
|
|
attachment.instance.type = MediaAttachment.types[:gifv] unless movie.audio_codec
|
2017-03-05 13:55:24 -08:00
|
|
|
|
2020-03-10 03:58:40 -07:00
|
|
|
Paperclip::Transcoder.make(file, actual_options(movie), attachment)
|
2020-03-09 15:15:59 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-03-10 03:58:40 -07:00
|
|
|
def actual_options(movie)
|
|
|
|
opts = options[:passthrough_options]
|
|
|
|
if opts && opts[:video_codecs].include?(movie.video_codec) && opts[:audio_codecs].include?(movie.audio_codec) && opts[:colorspaces].include?(movie.colorspace)
|
|
|
|
opts[:options]
|
|
|
|
else
|
|
|
|
options
|
|
|
|
end
|
2017-03-05 13:55:24 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|