2012-05-17 5 views

답변

2

나는 이것을했다. 연결을 수행하려면 먼저 오디오 파일을 AVAssets에로드해야합니다. 특히 AVURLAssets이라는 AVAsset의 하위 클래스를 사용하여 URL을로드 할 수 있습니다 (Loading AVAsset). 그런 다음 각각의 AVAssetAVMutableComposition에 추가 할 수 있으며, 복수 AVAssets을 포함하도록 설계되었습니다. AVMutableComposition에로드 된 후 AVAssetExportSession을 사용하여 파일에 컴포지션을 쓸 수 있습니다.

AVAssetExportSession은 파일 출력을 제어하지 못합니다 (오디오를 m4a 파일로 내 보냅니다). 출력 형식을 더 많이 제어해야하는 경우 AVAssetExportSession 대신 내보내기를 수행하려면 AVAssetReaderAVAssetWriter 클래스를 사용해야합니다. 이 클래스는 AVAssetExportSession보다 훨씬 복잡하며 곧은 C를 이해하기 위해 여기에서 지불합니다.

또한 Apple에서 MP3 파일을 쓸 수있는 옵션이 없음을 지적합니다. 읽을 수는 있지만 쓸 수는 없습니다. 일반적으로 m4a/aac 형식을 고수하는 것이 가장 좋습니다.

0

ExtAudioFile을 사용하면 상당히 간단합니다. 의사 코드에서 당신이 원하는 것은 :

1. Open the file you'll be using for output (ExtAudioFileOpen) 
2. Set the client data format you'll use for ExtAudioFileWrite 
3. For each input file you want to process: 
    a. Open the file using ExtAudioFile 
    b. Set the client data format used for reading to the same client format used in the output file for writing 
    c. Loop through the input file using ExtAudioFileRead and save the data to the output file using ExtAudioFileWrite 
    d. Close the input file 
4. Close the output file 
관련 문제