如何將音頻片段實時上傳到服務器而錄製?基本上我的要求是上傳一個音頻剪輯作爲卡盤/數據包,而其錄音。 我已經使用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