Skip to content

Commit e09d44d

Browse files
committed
[feat]: video feats
1 parent cf39334 commit e09d44d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/ScriptToolkit/FileExtension.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,27 @@ public extension File {
213213
try silencedFile100.delete()
214214
}
215215

216+
////////////////////////////////////////////////////////////////////////////////
217+
// MARK: - Video Processing
218+
219+
@discardableResult public func reduceVideo(newName: String, overwrite: Bool = true) throws -> File {
220+
if !overwrite && FileManager.default.fileExists(atPath: newName) { return try File(path: newName) }
221+
222+
run(ScriptToolkit.ffmpegPath, "-i", path, "-vf", "scale=iw/2:ih/2", newName)
223+
return try File(path: newName)
224+
}
225+
216226
////////////////////////////////////////////////////////////////////////////////
217227
// MARK: - PDF
218228

219229
@discardableResult public func cropPDF(newName: String, insets: NSEdgeInsets, overwrite: Bool = true) throws -> File {
220230
if !overwrite && FileManager.default.fileExists(atPath: newName) { return try File(path: newName) }
221-
run(ScriptToolkit.pdfCropPath, "--margins", insets.left, insets.top, insets.right, insets.bottom, path, newName)
231+
let left = Int(insets.left)
232+
let top = Int(insets.top)
233+
let bottom = Int(insets.bottom)
234+
let right = Int(insets.right)
235+
236+
run(ScriptToolkit.pdfCropPath, "--margins", "\(left) \(top) \(right) \(bottom)", path, newName)
222237
return try File(path: newName)
223238
}
224239

0 commit comments

Comments
 (0)