Crop video in iOS see weird green line around video

后端 未结 2 489
[愿得一人]
[愿得一人] 2020-12-30 12:37

Hey everyone I am cropping a video taken from the camera on iPhone and then cropping it an playing it back like this. When i do it however I get a weird green line around th

2条回答
  •  感情败类
    2020-12-30 13:19

    The answer by @Rhythmic saved my day.

    In my app, I need square video as per screen width size. So for iPhone 5 this comes 320 pixels and for iPhone 6 this becomes 375 pixels.

    So I came across same green line issue for iPhone 6 size resolution. Because its screen size width is 375 pixels. And not divisible by 2 or 4.

    To come out of this we made these changes

     AVMutableVideoComposition *MainCompositionInst = [AVMutableVideoComposition videoComposition];
        MainCompositionInst.instructions = [NSArray arrayWithObject:MainInstruction];
        MainInstruction.timeRange = range;
    
        MainCompositionInst.frameDuration = VideoFrameDuration; //Constants
        MainCompositionInst.renderScale = VideoRenderScale; //Constants
    
        if ((int)SCREEN_WIDTH % 2 == 0)
            MainCompositionInst.renderSize = CGSizeMake(SCREEN_WIDTH, SCREEN_WIDTH);
        else // This does the trick
            MainCompositionInst.renderSize = CGSizeMake(SCREEN_WIDTH+1, SCREEN_WIDTH+1); 
    

    Hope This helps. Just add one more pixel to it so it becomes divisible by 2 or 4.

    Thanks

提交回复
热议问题