iPhone AVCaptureDeviceInput 如何设置音频捕获的质量? [英] iPhone AVCaptureDeviceInput How to Set Quality of Audio Capture?
本文介绍了iPhone AVCaptureDeviceInput 如何设置音频捕获的质量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码在 44100 深度 2 处工作正常(一些检查和代码已消除),这似乎是默认值.由于此界面可用,但没有很好的记录,有人知道如何更改默认质量吗?
The following code is working fine (some checking and code eliminated) at 44100 depth 2 which seems to be the default. Since this interface is usable, but not documented well, anyone know of how to change the default quality?
audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
captureSession = [[AVCaptureSession alloc] init];
audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error];
[captureSession addInput:audioInput];
audioOutput = [[AVCaptureAudioDataOutput alloc] init];
[audioOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
[captureSession addOutput:audioOutput];
推荐答案
这应该可以解决问题.
更多在这里
union
{
OSStatus propertyResult;
char a[4];
} u;
Float64 F64sampleRate = 8192.0;
Float64 F64realSampleRate = 0;
UInt32 F64datasize = 8;
u.propertyResult = AudioSessionSetProperty ( kAudioSessionProperty_PreferredHardwareSampleRate ,sizeof(F64sampleRate) , &F64sampleRate );
NSLog(@"Set Error Set Sample Rate %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);
u.propertyResult = AudioSessionGetProperty ( kAudioSessionProperty_CurrentHardwareSampleRate , &F64datasize, &F64realSampleRate );
NSLog(@"Get Error Current Sample Rate %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);
NSLog(@"Sample Rate is %f",F64realSampleRate);
这篇关于iPhone AVCaptureDeviceInput 如何设置音频捕获的质量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文