<div dir="ltr">Dear All,<div><br></div><div>I am trying to decode opus. When I use both methodsĀ </div><div>avcodec_decode_audio4 and (avcodec_send_packet /avcodec_receive_frame) . I am receiving the same opus packet that I send for decoding. I got this by using the packet size of the decoded frame. Packet size is same as the input opus packet size.<br></div><div><br></div><div>I followed the decoding example given in github of ffmpeg. Please help me. Why I am receiving same packet as input?</div><div><br></div><div><div id="gmail-mainbar" style="margin:0px;padding:0px;border:0px;font-size:13px;float:left;width:728px;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif"><div class="gmail-question" id="gmail-question" style="margin:0px;padding:0px;border:0px;clear:both"><table style="margin:0px;padding:0px;border:0px;border-collapse:collapse"><tbody style="margin:0px;padding:0px;border:0px"><tr style="margin:0px;padding:0px;border:0px"><td class="gmail-votecell" style="padding:0px 15px 0px 0px;border:0px;vertical-align:top"><br></td><td class="gmail-postcell" style="padding:0px;border:0px;vertical-align:top"><div style="margin:0px;padding:0px;border:0px"><div class="gmail-post-text" style="margin:0px 0px 5px;padding:0px;border:0px;font-size:15px;width:660px;word-wrap:break-word;line-height:1.3"><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);word-wrap:normal"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;white-space:inherit">av_register_all();
avcodec_register_all();
AVCodec *codec;
AVCodecContext *c = NULL;
AVPacket avpkt;
AVFrame *decoded_frame = NULL;
av_init_packet(&avpkt);
codec = avcodec_find_decoder(AV_CODEC_ID_OPUS);
if (!codec) {
     printf("Codec not found\n");
     exit(1);
}
c = avcodec_alloc_context3(codec);
if (!c) {
   printf("Could not allocate audio codec context\n");
   exit(1);
}
/* put sample parameters */
c->sample_rate = 48000;
c->request_sample_fmt = AV_SAMPLE_FMT_FLT;
c->channels = 2;
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
    printf("Could not open codec\n");
    exit(1);
}

AVPacket avpkt;
AVFrame *decoded_frame = NULL;
av_init_packet(&avpkt);
avpkt.data = Buffer;  // Buffer is packet data here
avpkt.size = len;    // length of the packet
int i, ch;

if (!decoded_frame) {
    if (!(decoded_frame = av_frame_alloc())) {
        RELAY_SERVER_PRINT("Could not allocate audio frame\n");
        exit(1);
    }
}
int ret;
int got_frame = 0;
ret = avcodec_decode_audio4(client_sockt_num_1->c, decoded_frame, &got_frame, &avpkt);
if (ret < 0) {
        fprintf(stderr, "Error decoding audio frame (%s)\n", av_err2str(ret));
        return ret;
    }
printf("length %i\n", decoded_frame->pkt_size);</code></pre></div></div></td></tr></tbody></table></div></div><div><br></div>-- <br><div class="gmail_signature">Kind Regards<br><br>Aboobeker Sidhik</div>
</div></div>