new MediaAttachment video style :playable for mp4 to make videojs work with multiple files, hiding albums, hiding bookmark collections. may need tweaks on mediaattachment for mov and other formats : todo :
This commit is contained in:
mgabdev
2020-12-22 12:11:22 -05:00
parent 6fbea0a59e
commit 34f6a1ab5b
28 changed files with 259 additions and 138 deletions

View File

@@ -28,11 +28,11 @@ class MediaAttachment < ApplicationRecord
enum type: [:image, :gifv, :video, :unknown]
IMAGE_FILE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp'].freeze
VIDEO_FILE_EXTENSIONS = ['.webm', '.mp4', '.m4v'].freeze
VIDEO_FILE_EXTENSIONS = ['.webm', '.mp4', '.m4v', '.mov'].freeze
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
VIDEO_MIME_TYPES = ['video/webm', 'video/mp4'].freeze
VIDEO_CONVERTIBLE_MIME_TYPES = ['video/webm'].freeze
VIDEO_MIME_TYPES = ['video/webm', 'video/mp4', 'video/quicktime'].freeze
VIDEO_CONVERTIBLE_MIME_TYPES = ['video/webm', 'video/quicktime'].freeze
BLURHASH_OPTIONS = {
x_comp: 4,
@@ -64,6 +64,23 @@ class MediaAttachment < ApplicationRecord
file_geometry_parser: FastGeometryParser,
blurhash: BLURHASH_OPTIONS,
},
playable: {
convert_options: {
output: {
'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',
},
}.freeze
VIDEO_FORMAT = {
@@ -170,9 +187,9 @@ class MediaAttachment < ApplicationRecord
elsif IMAGE_MIME_TYPES.include? f.instance.file_content_type
IMAGE_STYLES
elsif VIDEO_CONVERTIBLE_MIME_TYPES.include?(f.instance.file_content_type)
puts "tilly convert"
{
small: VIDEO_STYLES[:small],
playable: VIDEO_STYLES[:playable],
original: VIDEO_FORMAT,
}
else