如何将音频片段实时上传到服务器而录制?基本上我的要求是上传一个音频剪辑作为卡盘/数据包,而其录音。 我已经使用IQAudioRecorderController https://github.com/hackiftekhar/IQAudioRecorderController做了录音部分。它会记录音频并保存到TemporaryDirectory。在录音时实时上传音频剪辑?
我想知道如何在不保存音频剪辑的情况下实时上传。
这是记录部分
//Unique recording URL
NSString *fileName = [[NSProcessInfo processInfo] globallyUniqueString];
_recordingFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.m4a",fileName]];
// Initiate and prepare the recorder
_audioRecorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:_recordingFilePath] settings:recordSetting error:nil];
_audioRecorder.delegate = self;
_audioRecorder.meteringEnabled = YES;
// Recording start
- (void)recordingButtonAction:(UIBarButtonItem *)item
{
if (_isRecording == NO)
{
_isRecording = YES;
//UI Update
{
[self showNavigationButton:NO];
_recordButton.tintColor = _recordingTintColor;
_playButton.enabled = NO;
_trashButton.enabled = NO;
}
/*
Create the recorder
*/
if ([[NSFileManager defaultManager] fileExistsAtPath:_recordingFilePath])
{
[[NSFileManager defaultManager] removeItemAtPath:_recordingFilePath error:nil];
}
_oldSessionCategory = [[AVAudioSession sharedInstance] category];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:nil];
[_audioRecorder prepareToRecord];
[_audioRecorder record];
}
else
{
_isRecording = NO;
//UI Update
{
[self showNavigationButton:YES];
_recordButton.tintColor = _normalTintColor;
_playButton.enabled = YES;
_trashButton.enabled = YES;
}
[_audioRecorder stop];
[[AVAudioSession sharedInstance] setCategory:_oldSessionCategory error:nil];
}
}
// Recording done
-(void)doneAction:(UIBarButtonItem*)item
{
if ([self.delegate respondsToSelector:@selector(audioRecorderController:didFinishWithAudioAtPath:)])
{
IQAudioRecorderController *controller = (IQAudioRecorderController*)[self navigationController];
[self.delegate audioRecorderController:controller didFinishWithAudioAtPath:_recordingFilePath];
}
[self dismissViewControllerAnimated:YES completion:nil];
}
您不需要'ffmpeg'来上传音频,而且您可能会将App中内置的应用程序放在App Store上发生许可问题。 – damian
ffmpeg可能还有其他选项,但是如果您关心授权,那么将应用程序提交给App Store是没有问题的,因为我成功地向App Store提交了一个包含ffmpeg实现的应用程序,但是您必须提及您正在使用它您的应用程序的信用目的。 – Yuvrajsinh
ffmpeg获得LGPL许可。 LGPL的条款与App Store不兼容。基本上,你违反了ffmpeg许可条款。 https://trac.ffmpeg.org/ticket/1229 – damian