What is AudioStreamBasicDescription for the m4a file format

I tried with lots of AudioStreamBasicDescription for the m4a file format. However, I get some problems with this.

Please tell me the exact AudioStreamBasicDescription format for the m4a file format.

+4
source share
2 answers

you can use ExtAudioFileGetProperty to get ASBD from an existing m4a audio file.

Details Click here .

+6
source

You can get an ASBD file with 2 (at least) different methods. You can use "ExtAudioFileGetProperty" or "AudioFileGetProperty".

AudioFileGetProperty:

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4a"]; CFURLRef soundFileURL = (__bridge CFURLRef)[NSURL fileURLWithPath:soundFilePath]; if (soundFileURL != nil) { AudioFileID audioFile; OSStatus theError = noErr; theError = AudioFileOpenURL(soundFileURL, kAudioFileReadPermission, 0, &audioFile); if(theError != noErr) { printf("AudioFileOpenURL failed!"); return; } AudioStreamBasicDescription asbd; UInt32 size = sizeof(asbd); theError = AudioFileGetProperty(audioFile, kAudioFilePropertyDataFormat, &size, &asbd); if(theError != noErr) { printf("kAudioFilePropertyDataFormat failed!"); return; } else { printf("Sample Rate : %f\n", asbd.mSampleRate); /* Float64 mSampleRate; AudioFormatID mFormatID; AudioFormatFlags mFormatFlags; UInt32 mBytesPerPacket; UInt32 mFramesPerPacket; UInt32 mBytesPerFrame; UInt32 mChannelsPerFrame; UInt32 mBitsPerChannel; UInt32 mReserved; */ } } 

ExtAudioFileGetProperty:

 NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4a"]; CFURLRef soundFileURL = (__bridge CFURLRef)[NSURL fileURLWithPath:soundFilePath]; if (soundFileURL != nil) { OSStatus theError = noErr; ExtAudioFileRef fileRef; theError = ExtAudioFileOpenURL(soundFileURL, &fileRef); if(theError != noErr) { printf("ExtAudioFileOpenURL failed!"); return; } AudioStreamBasicDescription asbd; UInt32 size = sizeof(asbd); theError = ExtAudioFileGetProperty(fileRef, kExtAudioFileProperty_FileDataFormat, &size, &asbd ); } 
0
source

Source: https://habr.com/ru/post/1335040/


All Articles