2013-07-21 2 views
1

Novocaine의 샘플 프로젝트에서 m4a 파일을 출력합니다. 하지만 iTunes에서 파일을 열 수 없습니다. 파일이 손상되었을 수 있습니다.Novocaine : 저장된 오디오 파일이 작동하지 않습니다.

NSArray *pathComponents = [NSArray arrayWithObjects: 
           [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject], 
           @"My Recording.m4a", 
           nil]; 
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents]; 
NSLog(@"URL: %@", outputFileURL); 

self.fileWriter = [[AudioFileWriter alloc] 
        initWithAudioFileURL:outputFileURL 
        samplingRate:self.audioManager.samplingRate 
        numChannels:self.audioManager.numInputChannels]; 


__block int counter = 0; 
self.audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) { 
    [wself.fileWriter writeNewAudio:data numFrames:numFrames numChannels:numChannels]; 
    counter += 1; 
    if (counter > 800) { // roughly 5 seconds of audio 
     wself.audioManager.inputBlock = nil; 
    } 
}; 

코드를 변경하지 않고 주석 만 제거했습니다.

가능한 해결책이나 제안 사항을 알고 있다면 나와 공유 할 수 있는지 궁금합니다.

탔을 https://github.com/alexbw/novocaine

답변

4

이 문제는 여기에 설명되어 https://github.com/alexbw/novocaine/issues/59

원래의 코드는 (a 처리기 블록 내부)이 선으로 기록을 종료 :

wself.audioManager.inputBlock = nil; 

난 의해 작동있어 다음 행 바로 뒤에 추가하십시오 :

[wself.fileWriter stop]; 

AudioFileWriter의 stop 메서드는 private이므로 공용 인터페이스에도 추가해야합니다.

+0

굉장한! 감사) –

관련 문제