Determine video codecs

This commit is contained in:
Christoph Hagen
2025-08-31 18:04:00 +02:00
parent 96bd07bdb7
commit 9848de02cb
9 changed files with 93 additions and 17 deletions

View File

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

View File

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

View File

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

View File

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