小编Gre*_*ode的帖子

更改AVCaptureDeviceInput会导致AVAssetWriterStatusFailed

我正在尝试更改摄像机视图Front和.Back它运行良好Pause/Record.如果Flip Camera View录制的视频没有翻转选项它工作正常.但如果我们曾经,那么进一步录制视频不保存导致AVAssetWriterStatusFailed- The operation could not be completed.任何人都可以帮我找到我出错的地方吗?以下是我的代码.

Camera.m

- (void)flipCamera{
NSArray * inputs = _session.inputs;
for ( AVCaptureDeviceInput * INPUT in inputs ) {
    AVCaptureDevice * Device = INPUT.device ;
    if ( [ Device hasMediaType : AVMediaTypeVideo ] ) {
        AVCaptureDevicePosition position = Device . position ; AVCaptureDevice * newCamera = nil ; AVCaptureDeviceInput * newInput = nil ;
        if ( position == AVCaptureDevicePositionFront )
            newCamera = …
Run Code Online (Sandbox Code Playgroud)

objective-c avfoundation ios avcapturesession avassetwriter

7
推荐指数
1
解决办法
952
查看次数

在Twitter App中检测哈希标记#,提及标签@,在iOS App中

我需要检测描述中给出的#TagsUILabel并更改文本颜色,[UIColor BlueColor];因为我无法将特定文本颜色更改UILabel为蓝色.现在我UILabel在自定义中使用它UITableViewCell.有没有办法解决这个问题,以区分#Tags和普通文本的文字颜色?任何人都可以帮我解决这个问题吗?

objective-c uitableview uilabel ios hashtag

4
推荐指数
1
解决办法
9952
查看次数

在UITextView中检测Tapped字符串

我试图找到Tapped String in UITextView.我试过了.UIDataDetectorTypeLink但它没有用.我也不确定是否有可能检测到String.我正在使用UITextView自定义UITableViewCell.从那我我试图检测轻拍的字符串.以下是我试过的示例代码.任何人都可以帮我找到我做错了什么,我怎么能解决这个问题?即使不可能,我该如何解决这个问题呢?

NSMutableArray *sampleArray = [[NSMutableArray alloc]init];
NSMutableString *mutableString = [[NSMutableString alloc]init];
NSMutableAttributedString * string;
sampleArray = [[postArray valueForKey:@"hash_tags"] objectAtIndex:indexPath.row];
for(NSString *sampleString in sampleArray){
    if (mutableString.length == 0) {
        [mutableString appendString:sampleString];
    }else{
        [mutableString appendString:[NSString stringWithFormat:@", %@",sampleString]];
    }
    string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",mutableString]];
    //        [string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,[string length])];
}
NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor colorWithRed:5.0f/255.0f green:107.0f/255.0f blue:153.0f/255.0f alpha:1.0f], NSUnderlineColorAttributeName: [UIColor greenColor],NSUnderlineStyleAttributeName: @(NSUnderlinePatternSolid)};
[string addAttribute:NSLinkAttributeName
               value:string
               range:NSMakeRange(0, [string …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview nsstring uitextview ios

3
推荐指数
1
解决办法
2418
查看次数

裁剪录制的视频帧

我正在尝试裁剪视频帧。我已经使用AVFoundation框架录制了视频。我需要将捕捉的图像和录制的视频裁剪为正方形。我已经完成了UIImage工作,现在我正在尝试裁剪视频。

- (UIImage *)squareImageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
  // Cropping UIImage is working fine.
  CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(0,0, image.size.width, image.size.width));
  UIImage *result = [UIImage imageWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation];
  CGImageRelease(imageRef);
  return result;
}
Run Code Online (Sandbox Code Playgroud)

我尝试裁剪视频,但结果是整个视频帧都没有裁剪,而是看起来很拉伸。

_writer = [AVAssetWriter assetWriterWithURL:url fileType:AVFileTypeQuickTimeMovie error:nil];
NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
                          AVVideoCodecH264, AVVideoCodecKey,
                          [NSNumber numberWithInt: 320], AVVideoWidthKey,
                          [NSNumber numberWithInt: 320], AVVideoHeightKey,
                          nil];
_videoInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:settings];
[_writer addInput:_videoInput];
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我解决视频播种问题吗?提前致谢。

objective-c avfoundation ios avassetwriter avvideocomposition

3
推荐指数
1
解决办法
1149
查看次数