English 中文(简体)
what is AudioStreamBasicDescription for m4a file format
原标题:
  • 时间:2011-01-11 07:41:33
  •  标签:
  • ios
  • audio
  • m4a

I have tried with more AudioStreamBasicDescription for m4a file format. Still I am getting some issues with that.

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

最佳回答

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

For more details Click here.

问题回答

You can get ASBD of a 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
", 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 );
}




相关问题
The codec could not be accessed. (-66672)

I am trying to convert caf file to m4a file using AudioUnit. I have implemented the code to convert. When I tried to run the application, I am getting following error message; couldn t set ...

what is AudioStreamBasicDescription for m4a file format

I have tried with more AudioStreamBasicDescription for m4a file format. Still I am getting some issues with that. Please anyone tell me the exact AudioStreamBasicDescription for m4a file format.

How to record voice in .m4a format

Already I have created an iPhone application to record. It will record in .caf file. But I want to record in .m4a format. Please help me to do this. Thanks.

flash audio player for m4a (AAC) audio file embedded in html

I m looking for a (free) flash player that I can embed in my site and use to play a .m4a (.mp4 with AAC audio) file that will be obtained using a URL (i.e. it s not local to the server hosting the web ...

WPF MediaElement: SpeedRatio not working for .m4a files?

I m working with a simple mediaplayer based on this msdn example where the user can control volume, playback speed (SpeedRatio) and seek (Position) using 3 sliders. Everything works correctly when I ...

How to read tags out of m4a files in .NET?

I ve got some heavily modified code that ultimately came from the Windows Media SDK that works great for reading tags out of MP3 and WMV files. Somewhere along the line, Windows Media Player added ...

热门标签