Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate video on export block app #38

Open
BRIKSING opened this issue Jun 21, 2024 · 3 comments
Open

Rotate video on export block app #38

BRIKSING opened this issue Jun 21, 2024 · 3 comments

Comments

@BRIKSING
Copy link

BRIKSING commented Jun 21, 2024

Hello! When I try to use this code (rotate video right) when fiter exporting video by Kakapos my app blocked export session

let filtering = FilterInstruction { buffer, time, callback in
      let uiimage = UIImage(cgImage: buffer.c7.toCGImage()!, scale: 1, orientation: orientation!)
      let dest = HarbethIO(element: uiimage, filters: self.filters)

      return dest.transmitOutput { image in
            callback(image.c7.toPixelBuffer() ?? buffer)
      }
}

But on simulator (iPhone 15 pro) it's works great

@BRIKSING
Copy link
Author

BRIKSING commented Jun 22, 2024

also have some logs for that export. On iPhones filtering function runs 2 times

Start export video...
UIImage generated:  <UIImage:0x283500fc0 anonymous {1080, 1920} renderingMode=automatic>
Destanation recievied:  HarbethIO<UIImage>(element: <UIImage:0x283500fc0 anonymous {1080, 1920} renderingMode=automatic>, filters: [Harbeth.C7LookupTable(_intensity: Harbeth.ZeroOneRange(wrappedValue: 1.0), lookupImage: Optional(<UIImage:0x283505d40 named(main: Home) {512, 512} renderingMode=alwaysOriginal>), lookupTexture: Optional(<CaptureMTLTexture: 0x281268e40> -> <AGXA9FamilyTexture: 0x1059a7bc0>
    label = <none> 
    textureType = MTLTextureType2D 
    pixelFormat = MTLPixelFormatRGBA8Unorm 
    width = 512 
    height = 512 
    depth = 1 
    arrayLength = 1 
    mipmapLevelCount = 10 
    sampleCount = 1 
    cpuCacheMode = MTLCPUCacheModeDefaultCache 
    storageMode = MTLStorageModeShared 
    hazardTrackingMode = MTLHazardTrackingModeTracked 
    resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked  
    usage = MTLTextureUsageShaderRead MTLTextureUsageShaderWrite 
    shareable = 0 
    framebufferOnly = 0 
    purgeableState = MTLPurgeableStateNonVolatile 
    swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] 
    isCompressed = 0 
    parentTexture = <null> 
    parentRelativeLevel = 0 
    parentRelativeSlice = 0 
    buffer = <null> 
    bufferOffset = 0 
    bufferBytesPerRow = 0 
    iosurface = 0x0 
    iosurfacePlane = 0 
    allowGPUOptimizedContents = YES
    label = <none>)), Harbeth.C7Brightness(_brightness: Harbeth.Clamping<Swift.Float>(value: 0.0, range: ClosedRange(-1.0...1.0))), Harbeth.C7Contrast(contrast: 1.0), Harbeth.C7Exposure(exposure: 0.0), Harbeth.C7Vibrance(vibrance: 0.0), Harbeth.C7Saturation(saturation: 1.0), Harbeth.C7HighlightShadow(_shadows: Harbeth.ZeroOneRange(wrappedValue: 0.0), _highlights: Harbeth.ZeroOneRange(wrappedValue: 1.0)), Harbeth.C7WhiteBalance(_tint: Harbeth.Clamping<Swift.Float>(value: 0.0, range: ClosedRange(-200.0...200.0)), _temperature: Harbeth.Clamping<Swift.Float>(value: 5000.0, range: ClosedRange(4000.0...7000.0))), Harbeth.C7ZoomBlur(radius: 0.0, blurCenter: Harbeth.C7Point2D(_x: Harbeth.ZeroOneRange(wrappedValue: 0.5), _y: Harbeth.ZeroOneRange(wrappedValue: 0.5))), Harbeth.C7GaussianBlur(radius: 0.0), Harbeth.C7GaussianBlur(radius: 0.0), Harbeth.C7GaussianBlur(radius: 0.0)], bufferPixelFormat: __C.MTLPixelFormat, mirrored: false, createDestTexture: true, transmitOutputRealTimeCommit: false, hasCoreImage: false)
UIImage generated:  <UIImage:0x283500240 anonymous {1080, 1920} renderingMode=automatic>
Destanation recievied:  HarbethIO<UIImage>(element: <UIImage:0x283500240 anonymous {1080, 1920} renderingMode=automatic>, filters: [Harbeth.C7LookupTable(_intensity: Harbeth.ZeroOneRange(wrappedValue: 1.0), lookupImage: Optional(<UIImage:0x283505d40 named(main: Home) {512, 512} renderingMode=alwaysOriginal>), lookupTexture: Optional(<CaptureMTLTexture: 0x281268e40> -> <AGXA9FamilyTexture: 0x1059a7bc0>
    label = <none> 
    textureType = MTLTextureType2D 
    pixelFormat = MTLPixelFormatRGBA8Unorm 
    width = 512 
    height = 512 
    depth = 1 
    arrayLength = 1 
    mipmapLevelCount = 10 
    sampleCount = 1 
    cpuCacheMode = MTLCPUCacheModeDefaultCache 
    storageMode = MTLStorageModeShared 
    hazardTrackingMode = MTLHazardTrackingModeTracked 
    resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeShared MTLResourceHazardTrackingModeTracked  
    usage = MTLTextureUsageShaderRead MTLTextureUsageShaderWrite 
    shareable = 0 
    framebufferOnly = 0 
    purgeableState = MTLPurgeableStateNonVolatile 
    swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] 
    isCompressed = 0 
    parentTexture = <null> 
    parentRelativeLevel = 0 
    parentRelativeSlice = 0 
    buffer = <null> 
    bufferOffset = 0 
    bufferBytesPerRow = 0 
    iosurface = 0x0 
    iosurfacePlane = 0 
    allowGPUOptimizedContents = YES
    label = <none>)), Harbeth.C7Brightness(_brightness: Harbeth.Clamping<Swift.Float>(value: 0.0, range: ClosedRange(-1.0...1.0))), Harbeth.C7Contrast(contrast: 1.0), Harbeth.C7Exposure(exposure: 0.0), Harbeth.C7Vibrance(vibrance: 0.0), Harbeth.C7Saturation(saturation: 1.0), Harbeth.C7HighlightShadow(_shadows: Harbeth.ZeroOneRange(wrappedValue: 0.0), _highlights: Harbeth.ZeroOneRange(wrappedValue: 1.0)), Harbeth.C7WhiteBalance(_tint: Harbeth.Clamping<Swift.Float>(value: 0.0, range: ClosedRange(-200.0...200.0)), _temperature: Harbeth.Clamping<Swift.Float>(value: 5000.0, range: ClosedRange(4000.0...7000.0))), Harbeth.C7ZoomBlur(radius: 0.0, blurCenter: Harbeth.C7Point2D(_x: Harbeth.ZeroOneRange(wrappedValue: 0.5), _y: Harbeth.ZeroOneRange(wrappedValue: 0.5))), Harbeth.C7GaussianBlur(radius: 0.0), Harbeth.C7GaussianBlur(radius: 0.0), Harbeth.C7GaussianBlur(radius: 0.0)], bufferPixelFormat: __C.MTLPixelFormat, mirrored: false, createDestTexture: true, transmitOutputRealTimeCommit: false, hasCoreImage: false)
Image tranmited:  <UIImage:0x283501710 anonymous {1080, 1920} renderingMode=automatic>
Converted to PixelBuffer:  <CVPixelBuffer 0x2836046e0 width=1080 height=1920 bytesPerRow=4352 pixelFormat=32 iosurface=0x0 attributes={
    CGBitmapContextCompatibility = 1;
    CGImageCompatibility = 1;
    PixelFormatDescription =     {
        BitsPerBlock = 32;
        BitsPerComponent = 8;
        BlackBlock = {length = 4, bytes = 0xff000000};
        CGBitmapContextCompatibility = 1;
        CGBitmapInfo = 16388;
        CGImageCompatibility = 1;
        ContainsAlpha = 1;
        ContainsGrayscale = 0;
        ContainsRGB = 1;
        ContainsYCbCr = 0;
        FillExtendedPixelsCallback = {length = 24, bytes = 0x0000000000000000a8d1f48a010000000000000000000000};
        PixelFormat = 32;
        QDCompatibility = 1;
    };
} propagatedAttachments={
} nonPropagatedAttachments={
}>
Image tranmited:  <UIImage:0x283501290 anonymous {1080, 1920} renderingMode=automatic>
Converted to PixelBuffer:  <CVPixelBuffer 0x2836043c0 width=1080 height=1920 bytesPerRow=4352 pixelFormat=32 iosurface=0x0 attributes={
    CGBitmapContextCompatibility = 1;
    CGImageCompatibility = 1;
    PixelFormatDescription =     {
        BitsPerBlock = 32;
        BitsPerComponent = 8;
        BlackBlock = {length = 4, bytes = 0xff000000};
        CGBitmapContextCompatibility = 1;
        CGBitmapInfo = 16388;
        CGImageCompatibility = 1;
        ContainsAlpha = 1;
        ContainsGrayscale = 0;
        ContainsRGB = 1;
        ContainsYCbCr = 0;
        FillExtendedPixelsCallback = {length = 24, bytes = 0x0000000000000000a8d1f48a010000000000000000000000};
        PixelFormat = 32;
        QDCompatibility = 1;
    };
} propagatedAttachments={
} nonPropagatedAttachments={
}>

@BRIKSING
Copy link
Author

Also find that this code works great on simulator and iPhone

let dest = HarbethIO(element: buffer, filters: self.filters)
        return dest.transmitOutput(success: callback)

But this code can't rotate exporting video (need rotate it to right because of bug with getting AvAsset)
Tried C7Rotate, it's works with photo, video rendering but not working with exporting video

@crazypoo
Copy link

#32 我之前讲的问题就是这个🥹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants