gpt4 book ai didi

ios - 使用 VideoCore 库用实时流视频填充 ui View

转载 作者:行者123 更新时间:2023-11-29 12:01:22 24 4
gpt4 key购买 nike

我正在使用 VideoCore 库来捕获视频并将其直播到服务器。我正在使用方形 uiview 来监视我的应用程序上的实时流。但我无法用我的直播视频输出完全填满 View 。很感谢任何形式的帮助。谢谢。我是 iOS 开发新手。

这是我的代码:

ViewController.h

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <AVFoundation/AVFoundation.h>
#import "VCSimpleSession.h"
#import <CoreMedia/CoreMedia.h>

@interface ViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UIView *previewview;

ViewController.m:

#import "ViewController.h"
#import "VCSimpleSession.h"
@interface ViewController ()<VCSessionDelegate>


@end

VCSimpleSession *mysession;

UIImagePickerController *picker;

int *flag;

@implementation ViewController

@synthesize mybutton;

- (void)viewDidLoad
{
[super viewDidLoad];
flag = 0;
self.textfield.autocorrectionType = UITextAutocorrectionTypeNo;

mysession.delegate = self;

self.previewview.hidden = NO;
self.mybutton.hidden = NO;
self.textfield.hidden = NO;

[self.mybutton setBackgroundColor:[UIColor greenColor]];
[self.mybutton setTitle:@"Start streaming" forState:UIControlStateNormal];
mysession = [[VCSimpleSession alloc]initWithVideoSize:CGSizeMake(1280, 720) frameRate:30 bitrate:100000 useInterfaceOrientation:YES];

mysession.previewView.frame = self.previewview.bounds;

[self.previewview addSubview:mysession.previewView];
}

最佳答案

我的问题已经解决了。

在这一行而不是 1280,720

mysession = [[VCSimpleSession alloc]initWithVideoSize:CGSizeMake(1280,720) frameRate:30 bitrate:100000 useInterfaceOrientation: YES];

我输入了480,850

mysession = [[VCSimpleSession alloc]initWithVideoSize:CGSizeMake(480,850) frameRate:30 bitrate:100000 useInterfaceOrientation: YES];

这解决了我的问题。现在我的 UI View 充满了实时摄像头画面。

关于ios - 使用 VideoCore 库用实时流视频填充 ui View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36860305/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com