forked from e621ng/e621ng
parent
b7fee5fe2f
commit
92e1fadd20
@ -21,7 +21,7 @@
|
||||
type="file"
|
||||
ref="post_file"
|
||||
id="file-input"
|
||||
accept="image/png,image/apng,image/jpeg,image/gif,video/webm,.png,.apng,.jpg,.jpeg,.gif,.webm"
|
||||
accept="image/png,image/apng,image/jpeg,image/gif,video/webm,video/mp4,.png,.apng,.jpg,.jpeg,.gif,.webm,.mp4"
|
||||
@change="updatePreviewFile"
|
||||
:disabled="disableFileUpload"
|
||||
/>
|
||||
@ -200,7 +200,7 @@ export default {
|
||||
}
|
||||
this.whitelist.oldDomain = domain;
|
||||
if(/^(https?\:\/\/|www).*?$/.test(this.uploadURL)) {
|
||||
const isVideo = /^(https?\:\/\/|www).*?\.(webm)$/.test(this.uploadURL);
|
||||
const isVideo = /^(https?\:\/\/|www).*?\.(webm|mp4)$/.test(this.uploadURL);
|
||||
this.previewChanged(this.uploadURL, isVideo);
|
||||
} else {
|
||||
this.setEmptyThumb();
|
||||
@ -222,7 +222,7 @@ export default {
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
this.disableURLUpload = true;
|
||||
this.uploadValueChanged(file);
|
||||
this.previewChanged(objectUrl, file.type === "video/webm");
|
||||
this.previewChanged(objectUrl, (file.type === "video/webm") || (file.type === "video/mp4"));
|
||||
},
|
||||
uploadValueChanged(value) {
|
||||
this.$emit("uploadValueChanged", value);
|
||||
|
@ -59,6 +59,10 @@ article.post-preview {
|
||||
&[data-file-ext=webm] > a:before {
|
||||
@include preview-type-badge('WEBM');
|
||||
}
|
||||
|
||||
&[data-file-ext=mp4] > a:before {
|
||||
@include preview-type-badge('MP4');
|
||||
}
|
||||
}
|
||||
|
||||
#edit-dialog textarea {
|
||||
|
@ -37,7 +37,7 @@ class PostVideoConversionJob < ApplicationJob
|
||||
sm.store(named_samples[1], mp4_path)
|
||||
named_samples[1].close!
|
||||
end
|
||||
sm.store(samples[:original][1], sm.file_path(md5, "mp4", :original, post.is_deleted?))
|
||||
sm.store(samples[:original][1], sm.file_path(md5, post.is_webm? ? "mp4" : "webm", :original, post.is_deleted?))
|
||||
samples[:original].each(&:close!)
|
||||
end
|
||||
|
||||
@ -48,7 +48,7 @@ class PostVideoConversionJob < ApplicationJob
|
||||
scaled_dims = post.scaled_sample_dimensions(dims)
|
||||
outputs[size] = generate_scaled_video(post.file_path, scaled_dims)
|
||||
end
|
||||
outputs[:original] = generate_scaled_video(post.file_path, post.scaled_sample_dimensions([post.image_width, post.image_height]), format: :mp4)
|
||||
outputs[:original] = generate_scaled_video(post.file_path, post.scaled_sample_dimensions([post.image_width, post.image_height]), format: post.is_webm? ? :mp4 : :webm)
|
||||
outputs
|
||||
end
|
||||
|
||||
|
@ -83,6 +83,8 @@ module FileMethods
|
||||
"png"
|
||||
when "video/webm"
|
||||
"webm"
|
||||
when "video/mp4"
|
||||
"mp4"
|
||||
else
|
||||
mime_type
|
||||
end
|
||||
|
@ -71,10 +71,18 @@ class FileValidator
|
||||
record.errors.add(:base, "video isn't valid")
|
||||
return
|
||||
end
|
||||
valid_video_codec = %w[vp8 vp9 av1].include?(video.video_codec)
|
||||
valid_container = video.container == "matroska,webm"
|
||||
if record.is_webm?
|
||||
valid_video_codec = %w[vp8 vp9 av1].include?(video.video_codec)
|
||||
valid_container = video.container == "matroska,webm"
|
||||
elsif record.is_mp4?
|
||||
valid_video_codec = %w[h264 hevc].include?(video.video_codec)
|
||||
valid_container = video.container == "mov,mp4,m4a,3gp,3g2,mj2"
|
||||
else
|
||||
valid_video_codec = false
|
||||
valid_container = false
|
||||
end
|
||||
unless valid_video_codec && valid_container
|
||||
record.errors.add(:base, "video container/codec isn't valid for webm")
|
||||
record.errors.add(:base, "video container/codec isn't valid for webm/mp4")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -366,7 +366,8 @@ module Danbooru
|
||||
'jpg' => 100.megabytes,
|
||||
'png' => 100.megabytes,
|
||||
'gif' => 20.megabytes,
|
||||
'webm' => 100.megabytes
|
||||
'webm' => 100.megabytes,
|
||||
'mp4' => 100.megabytes
|
||||
}
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user