gpt4 book ai didi

ios - 从服务器流式传输 .caf 音频文件

转载 作者:行者123 更新时间:2023-11-28 22:29:45 25 4
gpt4 key购买 nike

我正在做一个项目,我正在录制语音并将其上传到服务器。上传的文件格式为.caf(核心音频格式)

现在,当我尝试使用AVPLayer服务器 播放此文件时,它会在下面给出错误消息。

Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action"UserInfo=0x2f31e0 {NSLocalizedRecoverySuggestion=稍后再试。, NSLocalizedDescription=无法完成操作}

我已经检查过服务器上的文件,它没有损坏。

我的问题是:.caf 文件可以支持流媒体吗?如果不是,那么我需要将支持流式传输的录制文件转换为哪种格式?

最佳答案

AVAudioSession 中使用此设置

使用 .mp4 播放双方的音频:

     AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];
[audioSession setActive:YES error: &error];

NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

NSURL *recordedTmpFile = [NSURL fileURLWithPath:yourdirectorypath];
//file=[NSString stringWithFormat:@"%@",recordedTmpFile];
NSLog(@" filr url%@",recordedTmpFile);
// NSLog(@" filr url%@",file);
recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];

关于ios - 从服务器流式传输 .caf 音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17785925/

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