Skip to content
Extraits de code Groupes Projets
Valider 85fce04d rédigé par Eugen Rochko's avatar Eugen Rochko
Parcourir les fichiers

Detect videos with no sound, handle them like gifv

parent 4fb95c91
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -80,7 +80,7 @@ class MediaAttachment < ApplicationRecord ...@@ -80,7 +80,7 @@ class MediaAttachment < ApplicationRecord
if f.file_content_type == 'image/gif' if f.file_content_type == 'image/gif'
[:gif_transcoder] [:gif_transcoder]
elsif VIDEO_MIME_TYPES.include? f.file_content_type elsif VIDEO_MIME_TYPES.include? f.file_content_type
[:transcoder] [:video_transcoder]
else else
[:thumbnail] [:thumbnail]
end end
......
...@@ -8,6 +8,7 @@ Bundler.require(*Rails.groups) ...@@ -8,6 +8,7 @@ Bundler.require(*Rails.groups)
require_relative '../app/lib/exceptions' require_relative '../app/lib/exceptions'
require_relative '../lib/paperclip/gif_transcoder' require_relative '../lib/paperclip/gif_transcoder'
require_relative '../lib/paperclip/video_transcoder'
Dotenv::Railtie.load Dotenv::Railtie.load
......
# 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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter