[Ffmpeg-devel] The question is: how to open the AMR_NB-Codec?

Sumit Roy sroy
Fri Feb 17 18:20:10 CET 2006

Try using legal values for the sample parameters for AMR eg.

c->bit_rate = 12200;
c->sample_rate = 8000;
c->channels = 1;



-----Original Message-----
From: ffmpeg-devel-bounces at mplayerhq.hu
[mailto:ffmpeg-devel-bounces at mplayerhq.hu] On Behalf Of Lars Blumberg
Sent: Friday, February 17, 2006 3:56 AM
To: ffmpeg-devel at mplayerhq.hu
Subject: [Ffmpeg-devel] The question is: how to open the AMR_NB-Codec?

How do I have to initialize the codec with codec id CODEC_ID_AMR_NB ?

I use the output_example.c :

 * add an audio output stream
AVStream *add_audio_stream(AVFormatContext *oc, int codec_id) {
    AVCodecContext *c;
    AVStream *st;

    st = av_new_stream(oc, 1);
    if (!st) {
        fprintf(stderr, "Could not alloc stream\n");

    c = st->codec;
    c->codec_id = codec_id;
    c->codec_type = CODEC_TYPE_AUDIO;

    /* put sample parameters */
    c->bit_rate = 64000;
    c->sample_rate = 44100;
    c->channels = 2;
    return st;

To open the audio stream the following instructions are used:

void open_audio(AVFormatContext *oc, AVStream *st) {
    AVCodecContext *c;
    AVCodec *codec;

    c = st->codec;

    /* find the audio encoder */
    codec = avcodec_find_encoder(c->codec_id);
    if (!codec) {
        fprintf(stderr, "codec not found\n");

   >>>>> NOW the codec cannot be opened >>>>>>

    /* open it */
    if (avcodec_open(c, codec) < 0) {
        fprintf(stderr, "could not open codec\n");

Is there any initialization missing for the AMR_NB codec to open it?

Thanks in advance for any help


"Lars Blumberg" <Lars.Blumberg at aquasoft.de> schrieb im Newsbeitrag
news:dt2pu0$2n7$1 at sea.gmane.org...
> Hello!
> Has anyone tried the output_example.exe with a 3gp-filename?
> I therefore included the AMR NB audio codec, described at
> http://www.allaboutsymbian.com/archive/t-22589
> I am able to convert video files to 3gp file with ffmpeg.exe (with 
> sound), but I can not generate a 3gp output example with 
> "output_example.exe test.3gp". The message is, that the audio codec
cannot be opened.
> I also tried different bit rates and sample rates in output_example.c 
> but the error message is still the same.
> Thanks for any help in advance!
> Lars

ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu

More information about the ffmpeg-devel mailing list