<div dir="rtl"><div dir="ltr">I am trying to encode a file to pcm s32le.<br></div><div dir="ltr">I use the decodeing_encodeing.c example but I always recieve the folowing Error:<br><div style="margin-left:40px"><span style="background-color:rgb(255,0,0)">[pcm_s32le @ 0x11d0e00] Specified sample format 48000 is invalid or not supported</span><br>Could not open codec<br></div><br></div><div dir="ltr">The function is (Its not all the function, I marked what I have changed in yellow:<br><div style="margin-left:40px"><br></div></div><div dir="ltr"><div style="margin-left:40px">static void audio_encode_example(const char *filename)<br>{<br> AVCodec *codec;<br> AVCodecContext *c= NULL;<br> AVFrame *frame;<br> AVPacket pkt;<br> int i, j, k, ret, got_output;<br> int buffer_size;<br> FILE *f;<br> uint16_t *samples;<br> float t, tincr;<br><br> printf("Encode audio file %s\n", filename);<br><br> /* find the Wav encoder */<br> codec = avcodec_find_encoder(<span style="background-color:rgb(255,255,0)">AV_CODEC_ID_PCM_S32LE</span>);<br> if (!codec) {<br> fprintf(stderr, "Codec not found\n");<br> exit(1);<br> }<br><br> c = avcodec_alloc_context3(codec);<br> if (!c) {<br> fprintf(stderr, "Could not allocate audio codec context\n");<br> exit(1);<br> }<br><br> /* put sample parameters */<br> c->bit_rate = 64000;<br> /* check that the encoder supports S32LE pcm input */<br> c->sample_fmt = <span style="background-color:rgb(255,255,0)">AV_SAMPLE_FMT_S32</span>;<br> if (!check_sample_fmt(codec, c->sample_fmt)) {<br> fprintf(stderr, "Encoder does not support sample format %s",<br> av_get_sample_fmt_name(c->sample_fmt));<br> exit(1);<br> }<br> printf("\n");<br> <br> /* select other audio parameters supported by the encoder */<br> c->sample_rate = select_sample_rate(codec);<br> c->channel_layout = select_channel_layout(codec);<br> c->channels = av_get_channel_layout_nb_channels(c->channel_layout);<br> <br> /* open it */<br> if (avcodec_open2(c, codec, NULL) < 0) {<br> fprintf(stderr, "Could not open codec\n");<br> exit(1);<br> }<br><br></div><div style="margin-left:40px">The error is from avcodec_open2.<br></div><div style="margin-left:40px">Allso with the original example It didnt worked for me (With AV_CODEC_ID_MP2 and AV_SAMPLE_FMT_S16) and said the same error.<br></div></div><div><br>-- <br><div class="gmail_signature" style="text-align:center"><div dir="ltr">Yosef Alon<br></div></div>
</div></div>