[media_attachments] support NVENC_ENABLED

This commit is contained in:
Fosco Marotto 2021-01-07 16:10:42 -05:00
parent d9f6a142a0
commit bc35480662
1 changed files with 20 additions and 25 deletions

View File

@ -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