<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<div class="" style="font-family: Helvetica; font-size: 12px;">Sorry, I only speak a little English;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><br class="">
</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">You mean to say, the decoded frame->pkt_size is same as packet->size ?</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><br class="">
</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">But, the frame->pkt_size == packet->size,it is true; You need to look at annotation of AVFrame;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><br class="">
</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">If you want get the Frame data size, that is frame->linesize[x];</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">if the decoded data of audio is plane, frame->data[n] is n th channel data of samples;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">frame->nb_channels is num of channels;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">frame->nb_samples is num of samples;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><br class="">
</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">//can get all data length like this:</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">int iDataLen = 0;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">for(int i=0; i< frame->nb_channels; ++i)</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">{</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><span class="Apple-tab-span" style="white-space: pre;"></span>iDataLen +=frame->linesize[i];</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">}</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">uint8 * pData = frame->data[0];// it is continuous of all channel data;</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><br class="">
</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">may be a better way,but I do not know…..</div>
<div class="" style="font-family: Helvetica; font-size: 12px;"><br class="">
</div>
<div class="" style="font-family: Helvetica; font-size: 12px;">if it is not plane, only frame->data[0], and frame->linesize[0] is the length;</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> Libav-user <libav-user-bounces@ffmpeg.org> 代表 Aboobeker Sidhik Koyamparambil mammu <aboosidhik@gmail.com><br>
<b>发送时间:</b> 2017年1月11日 14:27<br>
<b>收件人:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br>
<b>主题:</b> Re: [Libav-user] Decoding opus</font>
<div> </div>
</div>
<div>
<div dir="ltr">No. I get the same data that I send to decoder. Not the uncompressed data (pcm) as output. In my case single frame in a single AV packet size. This I checked using a while loop that compares the packet size. 
<div><br>
</div>
<div> Regards</div>
<div>Aboo</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 11 January 2017 at 14:23, He Lei <span dir="ltr"><<a href="mailto:helei0908@hotmail.com" target="_blank">helei0908@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="auto">
<div>do you say ,you write same packet to decoder, and get frame more then in packet? </div>
<div>look at anntation as avcodec_decode_audio4();</div>
<div>that is:</div>
<div>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4643  * Some decoders may support multiple frames in a single AVPacket. Such</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4644  * decoders would then just decode the first frame and the return value would be</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4645  * less than the packet size. In this case, avcodec_decode_audio4 has to be</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4646  * called again with an AVPacket containing the remaining data in order to</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4647  * decode the second frame, etc...  Even if no frames are returned, the packet</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4648  * needs to be fed to the decoder with remaining data until it is completely</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4649  * consumed or an error occurs.</span></p>
<p style="margin:0px; font-size:12px; line-height:normal; font-family:Helvetica">
<span style="font-size:12pt">4650  *</span></p>
</div>
<div><br>
</div>
<div>good luck<br>
<div>发自我的 iPhone</div>
</div>
<div>
<div class="h5">
<div><br>
在 2017年1月11日,20:08,Aboobeker Sidhik Koyamparambil mammu <<a href="mailto:aboosidhik@gmail.com" target="_blank">aboosidhik@gmail.com</a>> 写道:<br>
<br>
</div>
<blockquote type="cite">
<div>
<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="m_434632704048584658gmail-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="m_434632704048584658gmail-question" id="m_434632704048584658gmail-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="m_434632704048584658gmail-votecell" style="padding:0px 15px 0px 0px; border:0px; vertical-align:top">
<br>
</td>
<td class="m_434632704048584658gmail-postcell" style="padding:0px; border:0px; vertical-align:top">
<div style="margin:0px; padding:0px; border:0px">
<div class="m_434632704048584658gmail-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_<wbr>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_<wbr>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="m_434632704048584658gmail_signature">Kind Regards<br>
<br>
Aboobeker Sidhik</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<blockquote type="cite">
<div><span>______________________________<wbr>_________________</span><br>
<span>Libav-user mailing list</span><br>
<span><a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a></span><br>
<span><a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a></span><br>
</div>
</blockquote>
</div>
<br>
______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">Kind Regards<br>
<br>
Aboobeker Sidhik</div>
</div>
</div>
</div>
</div>
</body>
</html>