[media_attachments] support NVENC_ENABLED
This commit is contained in:
parent
d9f6a142a0
commit
bc35480662
|
@ -52,6 +52,23 @@ class MediaAttachment < ApplicationRecord
|
||||||
},
|
},
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
VIDEO_FORMAT_OUTPUT_OPTIONS = {
|
||||||
|
'loglevel' => 'fatal',
|
||||||
|
'movflags' => 'faststart',
|
||||||
|
'pix_fmt' => 'yuv420p',
|
||||||
|
'vf' => 'scale=\'trunc(iw/2)*2:trunc(ih/2)*2\'',
|
||||||
|
'vsync' => 'cfr',
|
||||||
|
'c:v' => if ENV['NVENC_ENABLED'] == 'Y'
|
||||||
|
'h264_nvenc'
|
||||||
|
else
|
||||||
|
'h264'
|
||||||
|
end,
|
||||||
|
'b:v' => '500K',
|
||||||
|
'maxrate' => '1300K',
|
||||||
|
'bufsize' => '1300K',
|
||||||
|
'crf' => 18,
|
||||||
|
}
|
||||||
|
|
||||||
VIDEO_STYLES = {
|
VIDEO_STYLES = {
|
||||||
small: {
|
small: {
|
||||||
convert_options: {
|
convert_options: {
|
||||||
|
@ -66,18 +83,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
},
|
},
|
||||||
playable: {
|
playable: {
|
||||||
convert_options: {
|
convert_options: {
|
||||||
output: {
|
output: VIDEO_FORMAT_OUTPUT_OPTIONS,
|
||||||
'loglevel' => 'fatal',
|
|
||||||
'movflags' => 'faststart',
|
|
||||||
'pix_fmt' => 'yuv420p',
|
|
||||||
'vf' => 'scale=\'trunc(iw/2)*2:trunc(ih/2)*2\'',
|
|
||||||
'vsync' => 'cfr',
|
|
||||||
'c:v' => 'h264',
|
|
||||||
'b:v' => '500K',
|
|
||||||
'maxrate' => '1300K',
|
|
||||||
'bufsize' => '1300K',
|
|
||||||
'crf' => 18,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
format: 'mp4',
|
format: 'mp4',
|
||||||
},
|
},
|
||||||
|
@ -86,18 +92,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
VIDEO_FORMAT = {
|
VIDEO_FORMAT = {
|
||||||
format: 'mp4',
|
format: 'mp4',
|
||||||
convert_options: {
|
convert_options: {
|
||||||
output: {
|
output: VIDEO_FORMAT_OUTPUT_OPTIONS,
|
||||||
'loglevel' => 'fatal',
|
|
||||||
'movflags' => 'faststart',
|
|
||||||
'pix_fmt' => 'yuv420p',
|
|
||||||
'vf' => 'scale=\'trunc(iw/2)*2:trunc(ih/2)*2\'',
|
|
||||||
'vsync' => 'cfr',
|
|
||||||
'c:v' => 'h264',
|
|
||||||
'b:v' => '500K',
|
|
||||||
'maxrate' => '1300K',
|
|
||||||
'bufsize' => '1300K',
|
|
||||||
'crf' => 18,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
@ -122,7 +117,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
|
|
||||||
validates :account, presence: true
|
validates :account, presence: true
|
||||||
validates :description, length: { maximum: 420 }, if: :local?
|
validates :description, length: { maximum: 420 }, if: :local?
|
||||||
|
|
||||||
scope :attached, -> { where.not(status_id: nil).or(where.not(scheduled_status_id: nil)) }
|
scope :attached, -> { where.not(status_id: nil).or(where.not(scheduled_status_id: nil)) }
|
||||||
scope :unattached, -> { where(status_id: nil, scheduled_status_id: nil) }
|
scope :unattached, -> { where(status_id: nil, scheduled_status_id: nil) }
|
||||||
scope :local, -> { where(remote_url: '') }
|
scope :local, -> { where(remote_url: '') }
|
||||||
|
|
Loading…
Reference in New Issue