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

Lars Blumberg Lars.Blumberg
Fri Feb 17 12:55:40 CET 2006


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");
        exit(1);
    }

    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");
        exit(1);
    }

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

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

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

Thanks in advance for any help

Lars


"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 







More information about the ffmpeg-devel mailing list