美文网首页
GPUImage之视频录制+自定义水印

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

作者: ___吉 | 来源:发表于2017-07-03 20:01 被阅读0次

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

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,比较模糊,达不到要求
希望看到的大神给条明路,感激不尽

相关文章

  • iOS音视频学习

    GPUImage 可以实现的功能(基于GPU) 视频合成 视频加水印 修改图片 使用GPUImage拍照 录制视频...

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

    公司的项目有视频录制的功能,要求能将自定义视图嵌入到视频中去,下面是效果: 左边进度环是自己定义的内容代码如下: ...

  • 短视频从无到有 (五)录制视频实时添加水印

    上篇文章已经讲到给录制好的视频添加水印,这篇文章主要阐述下如何使用GPUImage给实时录制视频添加水印的思路。原...

  • GPUImage填坑心得

    项目用到GPUImage录制视频,同时还要加水印录制,录制的教程大把,但是这个库15年就不维护了,导致很多坑没有补...

  • GPUImage详细解析(八)视频合并混音

    回顾 GPUImage源码解析、图片模糊、视频滤镜、视频水印、文字水印和动态图片水印GPUImage的大多数功能已...

  • GPUImage 录制视频

    核心代码如下 在这里我强调一下,我在开发的时候,被一个错误困扰了好几天是 解释一下,这个问题出现的原因是文件路径出...

  • GPUImage详细解析(七)文字水印和动态图像水印

    回顾 GPUImage源码解析、图片模糊、视频滤镜、视频水印都已经介绍过,这次带来的是给视频添加文字水印、动态图像...

  • iOS-GPUImage自定义录制+水印封装

    简介 本文章不讲解美颜功能和更多滤镜功能,只讲解我真实项目需求需要的功能封装。功能用OC写的,主要是公司太多项目了...

  • GPUImage presentBufferForDispla

    项目中使用GPUImage自定义相机录制短视频,测试发现锁屏后再进入App会Crash,每次都崩溃在以下代码: 在...

  • GPUImage 录制视频bug

    GPUImage第一次录制视频会闪一下解决办法 [_videoCamera addAudioInputsAndOu...

网友评论

      本文标题:GPUImage之视频录制+自定义水印

      本文链接:https://www.haomeiwen.com/subject/cbyzcxtx.html