From 85fce04d1b4353c3645c15967d222cdcdb488dfd Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 5 Mar 2017 22:55:24 +0100 Subject: Detect videos with no sound, handle them like gifv --- lib/paperclip/video_transcoder.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/paperclip/video_transcoder.rb (limited to 'lib') diff --git a/lib/paperclip/video_transcoder.rb b/lib/paperclip/video_transcoder.rb new file mode 100644 index 000000000..c3504c17c --- /dev/null +++ b/lib/paperclip/video_transcoder.rb @@ -0,0 +1,14 @@ +# 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) + attachment.instance.type = MediaAttachment.types[:gifv] unless meta[:audio_encode] + + Paperclip::Transcoder.make(file, options, attachment) + end + end +end -- cgit