Search code examples
objective-cffmpegcore-audiolibav

Decoding WMA with FFMPeg on iPhone


I'm using this function to decode audio, but there is no sound:

int decodedBytes;
decodedBytes = avcodec_decode_audio4(myData->pCodecCtx, myData->myFrame, &data_size, &myData->pkt);

The data is successfully downloaded, but I don't know where to go from here, since there is no sound at all.


Solution

  • If you use avcodec_decode_audio3 instead it seams to work:

    decodedBytes = avcodec_decode_audio3(myData->pCodecCtx, samples, &data_size, &myData->pkt);
    

    But you should probably use avcodec_decode_audio4 as avcodec_decode_audio3 seams to be deprecated. I don't know much about ffmpeg/libav but I would guess that the audio4 uses the buffer system in libav instead of you passing in a buffer.

    Maybe this diff will give a hint how to use audio4:

    http://git.libav.org/?p=libav.git;a=commitdiff;h=f199f38573c4c02753f03ba8db04481038fa6f2e