关于GPUImage / 自定义分辨率设置相机 分辨率的问题求助

判断相册权限
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
DbpAlertView *alert = [[DbpAlertView alloc]initWithTitle:NSLocalizedString(@&HCC_set&, @&此功能需您到:设置-&隐私-&相机里面打开权限&) SubTitile:@&& Image:[UIImage imageNamed:@&Alert_DG_WAR&] CancelButton:@&& OkButton:NSLocalizedString(@&alert_OK&, @&确定&) andAlertTag:@&105&];
alert.delegate =
[alert show];
创建相机录视频采用&GPUImageVideoCamera 做输入源GPUImageVideoCamera摄像头用于实时拍摄视频GPUImageStillCamera摄像头用于实时拍摄照片GPUImagePicture用于处理已经拍摄好的图片GPUImageMovie用于处理已经拍摄好的视频//初始化videocamera 录视频输入源
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
//设置照片的方向为设备的定向
videoCamera.outputImageOrientation = UIInterfaceOrientationP
创建两层 &GPUImageView 显示两种滤镜,上层添加拖拽手势用于切换滤镜。底层正常显示,上层根据 手势偏移不断变化&
& &layer.mask
filteredVideoView = [[GPUImageView alloc] initWithFrame:self.view.bounds];
[filteredVideoView setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];
[self.view addSubview:filteredVideoView];
nextFilteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self applyMaskToNextVideoView:CGRectMake(0, 0, 0, self.view.bounds.size.height)];
[nextFilteredVideoView setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];
[self.view addSubview:nextFilteredVideoView];
//拖拽手势:用于切换滤镜
UIPanGestureRecognizer * panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[nextFilteredVideoView addGestureRecognizer:panGestureRecognizer];
给两层添加滤镜
[self changeFilter:[filters objectAtIndex:0] targetVideoView:filteredVideoView];
[self changeFilter:[self getFilterAtIndex:filterIndex + 1] targetVideoView:nextFilteredVideoView];
//开始捕获
[videoCamera startCameraCapture];
创建 &GPUImageMovieWriter 用于写入捕获的数据流
pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@&Documents/Movie.m4v&];
判断路径是否存在
unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:self.view.bounds.size];
[[filters objectAtIndex:0] addTarget:movieWriter];
//添加音频输入
videoCamera.audioEncodingTarget = movieW
movieWriter.shouldPassthroughAudio = YES;
拍照按钮自定义,点击拍照
-(void)tapPressBtnState:(UIGestureRecognizerState)state{
if (state == UIGestureRecognizerStateBegan) {
开始写入数据
[movieWriter startRecording];
}else if (state == UIGestureRecognizerStateEnded){
获取当前数据流的图像,
[filters[filterIndex] useNextFrameForImageCapture];
UIImage *img = [filters[filterIndex] imageFromCurrentFramebuffer];
[movieWriter finishRecordingWithCompletionHandler:^{
EditorViewController *testVC = [[EditorViewController alloc]init];
testVC.photoImage =
testVC.filterIndex = filterI
testVC.delegate =
[self presentViewController:testVC animated:YES completion:^{
videoCamera.audioEncodingTarget =
[videoCamera stopCameraCapture];
长按实现录像
-(void)longPressBtnState:(UIGestureRecognizerState)state
if (state == UIGestureRecognizerStateBegan) {
[movieWriter startRecording];
}else if (state == UIGestureRecognizerStateEnded){
[movieWriter finishRecordingWithCompletionHandler:^{
EditorViewController *testVC = [[EditorViewController alloc]init];
testVC.stickArr = [self getStikersArr];
testVC.delegate =
testVC.filterIndex = filterI
获取视频路径
testVC.videoPath = pathToM
[self presentViewController:testVC animated:YES completion:^{
videoCamera.audioEncodingTarget =
[videoCamera stopCameraCapture];
自定义录制button ,点击拍照,长按可录像
创建底层背景圆环
CAShapeLayer *circleLayer = [CAShapeLayer layer];
//创建一个园
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:
CGRectMake(0.0f, 0.0f, 116*_scrale_x, 116*_scrale_x)];
[circleLayer setPath:[path CGPath]];
// 边缘线的颜色
[circleLayer setStrokeColor:[[UIColor whiteColor] CGColor]];
// 线条宽度
[circleLayer setLineWidth:8.0f];
// 闭环填充的颜色
[circleLayer setFillColor:[[UIColor clearColor] CGColor]];
[[self layer] addSublayer:circleLayer];
创建进度的圆弧
progressLayer = [CAShapeLayer layer];
progressPath = [UIBezierPath bezierPath];
center:圆心的坐标
radius:半径
startAngle:起始的弧度
endAngle:圆弧结束的弧度
clockwise:YES为顺时针,No为逆时针
[progressPath addArcWithCenter:CGPointMake(58*_scrale_x,58*_scrale_x)
radius: 58*_scrale_x
startAngle: - M_PI_2
endAngle: -M_PI_2 + M_PI * 2 * 0.005
clockwise:YES];
[progressLayer setPath:[progressPath CGPath]];
[progressLayer setStrokeColor:[UIColorFromRGB(0x2CD1B1) CGColor]];
[progressLayer setLineWidth:8.0f];
progressLayer.lineCap = kCALineCapR
[progressLayer setFillColor:[[UIColor clearColor] CGColor]];
[[self layer] addSublayer:progressLayer];
给button 添加 手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self addGestureRecognizer:longPress];
UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapPress:)];
[self addGestureRecognizer:tapGes];
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
代理回调长按状态
if ([self.delegate respondsToSelector:@selector(longPressBtnState:)]) {
[self.delegate longPressBtnState:gesture.state];
if (gesture.state == UIGestureRecognizerStateBegan ) {
self.progressTimer.fireDate = [NSDate distantPast];
pop动画,长按时进度条放大
POPBasicAnimation * scaleUpAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
scaleUpAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.6, 1.6)];
scaleUpAnimation.duration = 1.5f;
[self.layer pop_addAnimation:scaleUpAnimation forKey:@&scaleUpAnimation&];
else if(gesture.state == UIGestureRecognizerStateChanged){
else if(gesture.state == UIGestureRecognizerStateEnded ) {
self.progressTimer.fireDate = [NSDate distantFuture];
self.progress = 0;
[self setProgressValue];
POPBasicAnimation * scaleDownAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
scaleDownAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)];
[self.layer pop_addAnimation:scaleDownAnimation forKey:@&scaleDownAnimation&];
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:668次
排名:千里之外
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'}

我要回帖

更多关于 会声会影自定义分辨率 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信