GPUImage之视频录制+自定义水印

公司的项目有视频录制的功能,要求能将自定义视图嵌入到视频中去,下面是效果:

IMG_1602.gif

左边进度环是自己定义的内容
代码如下:

///创建摄像头
    _videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1280x720 cameraPosition:AVCaptureDevicePositionBack];
    _videoCamera.outputImageOrientation = [UIApplication sharedApplication].statusBarOrientation;

//添加时间戳水印和图片水印
    UIView *contentView = [[UIView alloc] initWithFrame:self.view.frame];
    contentView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy年MM月dd日hh:mm:ss"];
    NSDate *currentDate = [NSDate date];
    NSString *timeString = [formatter stringFromDate:currentDate];
    UILabel *timestampLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, 300, 30)];
    timestampLabel.text = timeString;
    timestampLabel.textColor = [UIColor redColor];
    timestampLabel.font = [UIFont systemFontOfSize:20];
    [contentView addSubview:timestampLabel];
    
    _progressView = [[JCAnalysisCircleProgress alloc] initWithFrame:CGRectMake(10, 120, 100, 100)];
    _progressView.progressWidth = 15;
    _progressView.progressColor = [UIColor orangeColor];
    _progressView.trackColor = [UIColor whiteColor];
    [_progressView setProgress:.5 animated:YES];
    
    [contentView addSubview:_progressView];

///创建水印图形
    GPUImageUIElement *uiElement = [[GPUImageUIElement alloc] initWithView:contentView];

 ///创建滤镜
    _filter = [[GPUImageAlphaBlendFilter alloc] init];
    ((GPUImageAlphaBlendFilter*)_filter).mix = 1;
    _filterView = [[GPUImageView alloc] initWithFrame:self.view.frame];
    [self.view addSubview: _filterView];
    
    GPUImageFilter *videoFilter = [[GPUImageFilter alloc] init];
    [_videoCamera addTarget:videoFilter];
    [videoFilter addTarget:_filter];
    [uiElement addTarget:_filter];
    
    [_filter addTarget:_filterView];
    [_videoCamera startCameraCapture];
    
    ///刷新
    [videoFilter setFrameProcessingCompletionBlock:^(GPUImageOutput *output, CMTime time) {
        
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyy年MM月dd日hh:mm:ss"];
        NSDate *currentDate = [NSDate date];
        NSString *timeString = [formatter stringFromDate:currentDate];
        timestampLabel.text = timeString;
        [uiElement update];
    }];

效果不是很好,自定义控件效果不行:
1,进度条的动画没了
2,比较模糊,达不到要求
希望看到的大神给条明路,感激不尽

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,094评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,624评论 4 61
  • 没有一个女性会不爱美吧?我这里指的是外在美,不管先天条件和后天条件如何?不管对美的认知有何不同,不管期间经历的过程...
    萍儿_9fea阅读 1,616评论 0 1
  • 铲屎官带狗狗出门最怕的是什么呢?可能只是一个标牌:宠物禁止入内!把狗狗拴在门外,看着狗狗委屈的眼神,只能说“好吧,...
    狗狗铲屎官阅读 2,656评论 0 0
  • 我的思念就像秋天的落叶,在心底堆成了灰色的塔! 你决定离开就别在给我期待,要离开就请绝情! 我是你想不到的无关痛痒...
    流年浅梦阅读 3,349评论 0 1

友情链接更多精彩内容