<div>Greetings all,</div>
<div> </div>
<div> </div>
<div>I successfully compiled **libavcodec** with **speex** enabled.<br>I modified example from FFMPEG docs to encode the sample audio into Speex.<br>But the result file cannot be played with VLC Player(which has Speex decoder).</div>

<p>Any tips?</p>
<p>    static void audio_encode_example(const char *filename)<br>    {<br>        AVCodec *codec;<br>        AVCodecContext *c= NULL;<br>        int frame_size, i, j, out_size, outbuf_size;<br>        FILE *f;<br>        short *samples;<br>
        float t, tincr;<br>        uint8_t *outbuf;<br>    <br>        printf("Audio encoding\n");<br>    <br>        /* find the MP2 encoder */<br>        codec = avcodec_find_encoder(CODEC_ID_SPEEX);<br>        if (!codec) {<br>
            fprintf(stderr, "codec not found\n");<br>            exit(1);<br>        }<br>    <br>       c= avcodec_alloc_context();<br>    <br>        /* put sample parameters */<br>        c->bit_rate = 64000;<br>
        c->sample_rate = 32000;<br>        c->channels = 2;<br>        c->sample_fmt=AV_SAMPLE_FMT_S16;<br>    <br>        /* open it */<br>        if (avcodec_open(c, codec) < 0) {<br>            fprintf(stderr, "could not open codec\n");<br>
            exit(1);<br>        }<br>    <br>        /* the codec gives us the frame size, in samples */<br>        frame_size = c->frame_size;<br>        printf("frame size %d\n",frame_size);<br>        samples =(short*) malloc(frame_size * 2 * c->channels);<br>
        outbuf_size = 10000;<br>       outbuf =( uint8_t*) malloc(outbuf_size);<br>    <br>        f = fopen(filename, "wb");<br>        if (!f) {<br>            fprintf(stderr, "could not open %s\n", filename);<br>
            exit(1);<br>        }<br>    <br>        /* encode a single tone sound */<br>        t = 0;<br>        tincr = 2 * M_PI * 440.0 / c->sample_rate;<br>        for(i=0;i<200;i++) {<br>            for(j=0;j<frame_size;j++) {<br>
                samples[2*j] = (int)(sin(t) * 10000);<br>                samples[2*j+1] = samples[2*j];<br>                t += tincr;<br>            }<br>            /* encode the samples */<br>            out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);<br>
            fwrite(outbuf, 1, out_size, f);<br>        }<br>        fclose(f);<br>        free(outbuf);<br>        free(samples);<br>        avcodec_close(c);<br>        av_free(c);<br>    }<br>    <br>    int main(int argc, char **argv)<br>
    {<br>    <br>     avcodec_register_all();<br>    <br>     audio_encode_example(argv[1]);<br>    <br>     return 0;<br>    }</p>