yangKJ / Kakapos

🌀 High-performance and flexible video edit and export framework.
MIT License
24 stars 4 forks source link

C7Rotate filter is not working when exporting #3

Open smrkdrhashone opened 1 month ago

smrkdrhashone commented 1 month ago

C7Rotate filter is not working when exporting, it even messes up another filters as well, I noticed in C7Collector file while applying the filters we fix the orientation using this.

if self.autoCorrectDirection {
    image = image.c7.fixOrientation()
}

but when exporting we just pass the block in the FilterInstruction.

I also tried manually rotating the video but it is much more memory occupying task as I want to save the video in its original quality.

smrkdrhashone commented 1 month ago

Update

possible solution for this might be to rotate the video at the save time, I also changed dimensions for rotation of 90 degrees like below:

let exporter = VideoX(provider: provider)

let _ = exporter.export (
    options: [
        .ExportSessionPresetName: AVAssetExportPresetHighestQuality,
        .VideoCompositionRenderSize: rotation == 90 ? CGSize(width: size.height, height: size.width) : .zero
    ],
    instructions: [filtering]
) { [weak self] res in
    switch res {
    case .success(let url):
        DispatchQueue.main.async { [weak self] in
            guard let self else { return }
            video.play()
            ProgressHUD.dismiss()
            saveVideoWithOrientation (
                url: url,
                transform: .init(
                    rotationAngle: CGFloat(Degree(value: rotation).radians)
                )
            )
        }
    case .failure(let error):
        print(error.localizedDescription)
    }
} progress: { pro in
    print(pro)
}