do you say ,you write same packet to decoder, and get frame more then in packet? look at anntation as avcodec_decode_audio4??? that is?
4643 * Some decoders may support multiple frames in a single AVPacket. Such 4644 * decoders would then just decode the first frame and the return value would be 4645 * less than the packet size. In this case, avcodec_decode_audio4 has to be 4646 * called again with an AVPacket containing the remaining data in order to 4647 * decode the second frame, etc... Even if no frames are returned, the packet 4648 * needs to be fed to the decoder with remaining data until it is completely 4649 * consumed or an error occurs. 4650 * good luck ???? iPhone ? 2017?1?11??20:08?Aboobeker Sidhik Koyamparambil mammu <[email protected]<mailto:[email protected]>> ??? Dear All, I am trying to decode opus. When I use both methods 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. I followed the decoding example given in github of ffmpeg. Please help me. Why I am receiving same packet as input? 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); -- Kind Regards Aboobeker Sidhik _______________________________________________ Libav-user mailing list [email protected]<mailto:[email protected]> http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
