about summary refs log tree commit diff
path: root/lib/paperclip/video_transcoder.rb
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-03-15 22:55:22 +0100
committerGitHub <noreply@github.com>2017-03-15 22:55:22 +0100
commite245115f47082ffba27205f508301d14e792c369 (patch)
tree21a77b788dace45b734da6e64f1b0705016192f0 /lib/paperclip/video_transcoder.rb
parent620f70e42c16c324459ca2da52c68f1def8683de (diff)
parentc1124228e857b0e85f5bf927d2c41c7fadfdf955 (diff)
Merge branch 'master' into mastodon-site-api
Diffstat (limited to 'lib/paperclip/video_transcoder.rb')
-rw-r--r--lib/paperclip/video_transcoder.rb14
1 files changed, 14 insertions, 0 deletions
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