I was wondering is there any way to force replaykit to record only a part of the screen in square mode? The current API seems to record the whole screen!
Asked
Active
Viewed 1,330 times
1
-
The guy at wwdc said something about specifying another UIWindow for a similar purpose. Not sure if that UIWindow can be square or if it has to be full screen but I guess the purpose is to only record certain parts. – Jonny Apr 07 '16 at 03:47
2 Answers
3
ReplayKit records everything on the screen exempt system prompts and dialogs.
You can however overlay another UIWindow on top of your main one and apply a mask to an empty UIView to hide parts of the screen and force a square recording.
The frame ratio of the final recording will still be equal to the screen though.
_overlayWindow = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; //Full sized window
_overlayWindow.backgroundColor = [UIColor clearColor];
_overlayWindow.userInteractionEnabled = false;
_overlayWindow.hidden = NO;
UIView *maskedView = [[UIView alloc] initWithFrame:_overlayWindow.bounds];
// Create a mask layer
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGRect maskRect = CGRectMake(0, 0, 200, 200);
// Create a path with the rectangle in it.
CGPathRef path = CGPathCreateWithRect(maskRect, NULL);
maskLayer.path = path;
// Set the mask of the view.
maskedView.layer.mask = maskLayer;
[_overlayWindow addSubview:maskedView];

ahbou
- 4,710
- 23
- 36
-
-
-
I have tried above ur code. But, recordings done with full screen. I can't record a particular CGRect – McDonal_11 Mar 11 '19 at 17:50
-
-
@McDonal_11 ReplayKit doesn't support recording a particular frame. But you can overlay you mainWindow with a mask like the code above – ahbou Mar 11 '19 at 22:29
-
I need to crop particular frame in video file like image crop . Is it possible ? – McDonal_11 Mar 12 '19 at 05:09
-
Suppose, If am having 5 mins video and I am trying to play in AVPlayer, with frame 375 * 400, then now I need to crop particular frame, 200 * 200 either in top, left or center, Is it possible? I don't want compress video size to be 200*200 – McDonal_11 Mar 12 '19 at 05:16
-
-
ReplayKit doesn't support that unfortunately. You'll have to crop after the recording is done. – ahbou Mar 12 '19 at 09:23
0
At the moment ReplayKit framework does not provide customisation of Screen Recording in terms of Screen size. So you have to record whole screen of GamePlay.

technerd
- 14,144
- 10
- 61
- 92