gpt4 book ai didi

objective-c - 在 Mac 上更改使用 AVFoundation 制作的录音的比特率

转载 作者:太空狗 更新时间:2023-10-30 03:51:19 26 4
gpt4 key购买 nike

我正在使用 AVFoundation 在 OSX 10.8 上进行一些屏幕录制。我正在使用 sessionPreset“AVCaptureSessionPresetPhoto”来记录整个屏幕。我想改变的一件事是创建的电影文件的质量。

AVCaptureSessionPresetPhoto 似乎需要实际捕获全屏而不剪切。

根据此处的文档:http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html

"You use this property to customize the quality level or bitrate of the output. For possible values of sessionPreset, see “Video Input Presets.” The default value is AVCaptureSessionPresetHigh."

但是,对于视频输入预设,唯一的选项是这些常量: http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html#//apple_ref/occ/cl/AVCaptureSession

NSString *const AVCaptureSessionPresetPhoto;

NSString *const AVCaptureSessionPresetHigh;

NSString *const AVCaptureSessionPresetMedium;

NSString *const AVCaptureSessionPresetLow;

NSString *const AVCaptureSessionPreset320x240;

NSString *const AVCaptureSessionPreset352x288;

NSString *const AVCaptureSessionPreset640x480;

NSString *const AVCaptureSessionPreset960x540;

NSString *const AVCaptureSessionPreset1280x720;

AVCaptureSessionPresetPhoto 可以在不裁剪的情况下捕获全屏,但最终质量有些平庸。由于默认使用较低的比特率,因此存在可见的伪像。

我怎样才能提高最终录音的比特率?

下面是我当前代码的示例。

    mSession = [[AVCaptureSession alloc] init];

mSession.sessionPreset = AVCaptureSessionPresetPhoto;

CGDirectDisplayID displayId = kCGDirectMainDisplay;

AVCaptureScreenInput *input = [[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
if (!input) {
mSession = nil;
return;
}

if ([mSession canAddInput:input]){
[mSession addInput:input];
}

mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([mSession canAddOutput:mMovieFileOutput])
[mSession addOutput:mMovieFileOutput];

[mSession startRunning];

if ([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]])
{
NSError *err;
if (![[NSFileManager defaultManager] removeItemAtPath:[destPath path] error:&err])
{
NSLog(@"Error deleting existing movie %@",[err localizedDescription]);
}
}

[mMovieFileOutput startRecordingToOutputFileURL:destPath recordingDelegate:self];

mTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(finishRecord:) userInfo:nil repeats:NO];

最佳答案

如果您需要精细控制 MP4/MOV H.264 比特流的比特率,那么您将需要使用 AVFoundation 的 AVAssetWriter。对于视频输入,您可以像这样设置属性 post .查看 AVVideoAverageBitRateKey。另请注意 AVVideoMaxKeyFrameIntervalKey 键。如果您计划对视频进行后期制作,那么我建议使用 1 作为关键帧间隔。有关使用 AVAssetWriter 的示例,请查看 Apple 的 RosyWriter 或 AVCamDemo 示例应用程序。让我知道您是否需要更多解释。

关于objective-c - 在 Mac 上更改使用 AVFoundation 制作的录音的比特率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12083529/

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