Determine video codecs
This commit is contained in:
@@ -188,6 +188,14 @@ extension VideoBlock {
|
||||
case .webm: "video/webm"
|
||||
}
|
||||
}
|
||||
|
||||
static func h265(codec: String) -> SourceType? {
|
||||
switch codec {
|
||||
case "hvc1": return .h265
|
||||
case "avc1": return .h264
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Source {
|
||||
|
||||
@@ -30,8 +30,8 @@ struct VideoCommand: CommandProcessor {
|
||||
}
|
||||
results.require(file: file)
|
||||
|
||||
guard let videoType = file.type.htmlType else {
|
||||
invalid(markdown)
|
||||
guard let videoType = file.videoType() else {
|
||||
invalid("File \(file.identifier) has an unknown video type")
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,7 @@ final class ImageGenerator {
|
||||
let generatedImagePath = storage.outputPath(to: version.outputPath)!.path()
|
||||
let quality = Int(version.quality * 100)
|
||||
|
||||
// TODO: Run in security scope
|
||||
let process = Process()
|
||||
#warning("TODO: Move avifenc path to settings")
|
||||
process.launchPath = "/opt/homebrew/bin/avifenc" // Adjust based on installation
|
||||
|
||||
@@ -82,7 +82,18 @@ final class PostListPageGenerator {
|
||||
images.forEach(source.results.require)
|
||||
media = .images(images)
|
||||
} else if localized.hasVideos {
|
||||
media = .video(localized.images)
|
||||
let videos: [PostVideo.Video] = localized.images.compactMap { file -> PostVideo.Video? in
|
||||
guard file.type.isVideo else {
|
||||
self.source.results.warning("File \(file.identifier) ignored due to videos present in the post")
|
||||
return nil
|
||||
}
|
||||
guard let type = file.videoType() else {
|
||||
self.source.results.warning("Video \(file.identifier) ignored due to unknown video type")
|
||||
return nil
|
||||
}
|
||||
return .init(path: file.absoluteUrl, type: type)
|
||||
}
|
||||
media = .video(videos)
|
||||
localized.images.forEach(source.results.require)
|
||||
} else {
|
||||
media = nil
|
||||
|
||||
Reference in New Issue
Block a user