1

I built a class with the use of the FFmpeg API to decode several audio files (mp3, ogg, G.729, etc) and load them into a data structure as raw audio data. Now for example when I run the following code:

codec = avcodec_find_decoder(AV_CODEC_ID_G729);
if (codec == NULL){
    printf("Codec not found");
    exit(1);
}

The program will indeed output the error message, but if I load mp3 or ogg codecs there's no issue.

So to double check I executed in the terminal ffmpeg -decoders to see if the decoder is supported (which I also checked online) and outputs:

A....D g729 G.729

I need the decoder for G.729. Is there anything I'm missing or doing something wrong? Is there a different way to load this decoder? Any suggestions would be greatly appreciated.

The FFmpeg version installed is 2.7.1 on a Debian system

API use example: https://www.ffmpeg.org/doxygen/2.7/decoding_encoding_8c-example.html

Community
  • 1
  • 1
gapc
  • 13
  • 6
  • Could it be that your ffmpeg binary and your own application use different versions of ffmpeg? – Ronald S. Bultje Jul 17 '15 at 20:27
  • How can that be if I compiled & installed it from source code? – gapc Jul 17 '15 at 20:42
  • Check it anyway. When you run ffmpeg, you should see a line like "ffmpeg version N-73539-gfc1800a". You can get the same information from the API function av_version_info (http://ffmpeg.org/doxygen/trunk/group__lavu__ver.html#gabaea9f86706819534baceeac7ea5818a). Make sure these two values match. – Ronald S. Bultje Jul 17 '15 at 23:39
  • Followed your suggestion and checked the FFmpeg versions vs the API -- they match – gapc Jul 20 '15 at 12:15
  • Wow, ok, that's indeed incredibly confusing then. I'll try to think of other things that may cause this. – Ronald S. Bultje Jul 20 '15 at 12:35

1 Answers1

1

OK, so given the original comment sequence, I tried the most simple example I could come up with:

#include "libavcodec/avcodec.h"

int main() {
    avcodec_register_all();
    AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_G729);
    if (!codec) {
        fprintf(stderr, "Codec not found\n");
        exit(1);
    }
    fprintf(stderr, "Codec found\n");
    return 0;
}

and compiled this against my local ffmpeg tree, and that works fine:

$ /tmp/x
Codec found

So, something strange must be going on in your specific case. Can you give more information on for example how you compiled your self-compiled ffmpeg tree (in particular, your configure parameters, and also do "grep 729 config.h", your complete example code of how you're trying to run your piece of code (which wouldn't run by itself since it's missing avcodec_register_all(), but since you referred to api_example I'm assuming that your complete code does not have this problem, otherwise mp3/ogg wouldn't work), and compiler line used to compile/link it against your ffmpeg version.

Ronald S. Bultje
  • 9,576
  • 22
  • 43
  • I grabbed the Debian package FFmpeg from their repo, installed it, and was able to load the codec from my code. Thanks for your help. – gapc Jul 22 '15 at 17:02