mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Add passthrough options for audio attachments
This commit is contained in:
parent
40ba6e119b
commit
0bc7bd75cb
@ -146,6 +146,20 @@ class MediaAttachment < ApplicationRecord
|
||||
original: VIDEO_FORMAT.merge(passthrough_options: VIDEO_PASSTHROUGH_OPTIONS).freeze,
|
||||
}.freeze
|
||||
|
||||
AUDIO_PASSTHROUGH_OPTIONS = {
|
||||
audio_codecs: ['acc'].freeze,
|
||||
options: {
|
||||
format: 'mp3',
|
||||
convert_options: {
|
||||
output: {
|
||||
'loglevel' => 'fatal',
|
||||
'map_metadata' => '-1',
|
||||
'c:a' => 'copy',
|
||||
}.freeze,
|
||||
}.freeze,
|
||||
}.freeze,
|
||||
}.freeze
|
||||
|
||||
AUDIO_STYLES = {
|
||||
original: {
|
||||
format: 'mp3',
|
||||
@ -156,6 +170,8 @@ class MediaAttachment < ApplicationRecord
|
||||
'q:a' => 2,
|
||||
}.freeze,
|
||||
}.freeze,
|
||||
|
||||
passthrough_options: AUDIO_PASSTHROUGH_OPTIONS,
|
||||
}.freeze,
|
||||
}.freeze
|
||||
|
||||
|
@ -115,7 +115,11 @@ module Paperclip
|
||||
end
|
||||
|
||||
def eligible_to_passthrough?(metadata)
|
||||
@passthrough_options && @passthrough_options[:video_codecs].include?(metadata.video_codec) && @passthrough_options[:audio_codecs].include?(metadata.audio_codec) && @passthrough_options[:colorspaces].include?(metadata.colorspace)
|
||||
return false if @passthrough_options.blank?
|
||||
|
||||
%i(video_codec audio_codec colorspace).all? do |attribute|
|
||||
@passthrough_options["#{attribute}s".to_sym].nil? || @passthrough_options["#{attribute}s".to_sym].include?(metadata.public_send(attribute))
|
||||
end
|
||||
end
|
||||
|
||||
def update_attachment_type(metadata)
|
||||
|
Loading…
Reference in New Issue
Block a user