about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/models/media_attachment.rb5
-rw-r--r--lib/paperclip/video_transcoder.rb14
2 files changed, 11 insertions, 8 deletions
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index 9ca0a6cda..31aa918b7 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -78,8 +78,9 @@ class MediaAttachment < ApplicationRecord
   }.freeze
 
   VIDEO_PASSTHROUGH_OPTIONS = {
-    video_codec_whitelist: ['h264'],
-    audio_codec_whitelist: ['aac', nil],
+    video_codecs: ['h264'],
+    audio_codecs: ['aac', nil],
+    colorspaces: ['yuv420p'],
     options: {
       format: 'mp4',
       convert_options: {
diff --git a/lib/paperclip/video_transcoder.rb b/lib/paperclip/video_transcoder.rb
index 0de548964..4d9544231 100644
--- a/lib/paperclip/video_transcoder.rb
+++ b/lib/paperclip/video_transcoder.rb
@@ -6,19 +6,21 @@ module Paperclip
   class VideoTranscoder < Paperclip::Processor
     def make
       movie = FFMPEG::Movie.new(@file.path)
-      actual_options = options
-      passthrough_options = actual_options[:passthrough_options]
-      actual_options = passthrough_options[:options] if passthrough?(movie, passthrough_options)
 
       attachment.instance.type = MediaAttachment.types[:gifv] unless movie.audio_codec
 
-      Paperclip::Transcoder.make(file, actual_options, attachment)
+      Paperclip::Transcoder.make(file, actual_options(movie), attachment)
     end
 
     private
 
-    def passthrough?(movie, options)
-      options && options[:video_codec_whitelist].include?(movie.video_codec) && options[:audio_codec_whitelist].include?(movie.audio_codec)
+    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
     end
   end
 end