小编luk*_*ura的帖子

AVSampleBufferDisplayLayer 未在设备上呈现

我正在为 iOS 上的 AVSampleBufferDisplayLayer 苦苦挣扎。我想使用这一层显示一个 CVPixelBuffer,但我无法让它在实际的 iOS 设备上工作。在我的示例应用程序中,我尝试使用以下代码来显示一个颜色像素缓冲区:

@implementation ViewController {
    AVSampleBufferDisplayLayer *videoLayer;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    videoLayer = [[AVSampleBufferDisplayLayer alloc] init];
    videoLayer.frame = CGRectMake(50, 50, 300, 300);
    videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;

    [self.view.layer addSublayer:videoLayer];
}

@implementation ViewController {
    AVSampleBufferDisplayLayer *videoLayer;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    videoLayer = [[AVSampleBufferDisplayLayer alloc] init];
    videoLayer.frame = CGRectMake(50, 50, 300, 300);
    videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;

    [self.view.layer addSublayer:videoLayer];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self startVideo];
}

- (void)startVideo {
    [self drawPixelBuffer];
    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self …
Run Code Online (Sandbox Code Playgroud)

video objective-c avfoundation calayer ios

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

标签 统计

avfoundation ×1

calayer ×1

ios ×1

objective-c ×1

video ×1