iPhone AVCaptureDeviceInput如何设置音频捕获的质量? [英] iPhone AVCaptureDeviceInput How to Set Quality of Audio Capture?

查看:120
本文介绍了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];

推荐答案

这应该可以解决问题.

This should do the trick.

更多内容

http://developer.apple .com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html

 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆