rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

Watermark overlay before export #315

Open AnthoPakPak opened 8 years ago

AnthoPakPak commented 8 years ago

Very nice job on this lib !

Is there a way to add the SCWatermarkOverlayView on the preview, before exporting ? I would like the user be able to see it's composition before export. One way would be to add the UIView above the current preview view, but is it a good way, will the result always be the same as in export ?

Thanks in advance.

AnthoPakPak commented 8 years ago

I've tried to insert SCWatermarkOverlayView as a subview on SCVideoPlayerViewController. As I expected, the result was NOT the same as in the export. Indeed, the frame are not the same. For example, an overlay text with font size of 40 will appear huge on preview, and normal in export.

I've made a quick workaround with scale factor for that but there's must be a better way.

Example : If you save your videos in high quality their height will be of 1280. iPhone 5's height is 568. Scale --> 1280/568 = 2.253. So you'll have to reduce every element on the overlay view by 2.253 if you want them to appear the same on preview and export.

Add this (for example) to SCWatermarkOverlayView and call it in SCVideoPlayerViewController :

-(void) scaleElementsWithDivideValue:(CGFloat)divideValue { _watermarkLabel.font = [UIFont boldSystemFontOfSize:40/divideValue]; marginOffset = marginOffset/divideValue; [self layoutSubviews]; }

Call it this way on SCVideoPlayerViewController in viewDidLoad :

SCWatermarkOverlayView *overlay = [[SCWatermarkOverlayView alloc]initWithFrame:self.view.frame]; overlay.userInteractionEnabled = NO; [overlay scaleElementsWithDivideValue:1280/self.view.frame.size.height]; [self.view insertSubview:overlay aboveSubview:self.filterSwitcherView];

If there's a better solution I'll be glad to hear about it ! :)