Hi Jake,
On 10/24/2011 10:18 AM, Jake Alley wrote:
> Is there any trick to get audio encoding to initialize properly on
> win32? I used the latest autobuilds from win32.libav.org and copied
> api-example.c. avcodec_open(c, codec) always seems to return -22.
> Decoding works fine.
>
> Thanks.
>
> printf("Audio encoding\n");
>
> /* find the MP2 encoder */
> codec = avcodec_find_encoder(CODEC_ID_MP2);
> if (!codec) {
> fprintf(stderr, "codec not found\n");
> exit(1);
> }
>
> c = avcodec_alloc_context3(codec);
>
> /* put sample parameters */
> c->bit_rate = 64000;
> c->sample_rate = 44100;
> c->channels = 2;
>
> /* open it */
> int r = avcodec_open(c, codec);
> // always returns -22
> if (r < 0) {
> fprintf(stderr, "could not open codec\n");
> exit(1);
> }
You're missing:
c->sample_fmt = AV_SAMPLE_FMT_S16;
-Justin
_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api