<div dir="ltr"><div dir="ltr">On Fri, Jul 31, 2020 at 4:55 PM u <<a href="mailto:ugurbd@gmail.com">ugurbd@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello, <br></div><div><br></div><div>I've been trying to understand how to use opus codec for quite some time. There is a thing that doesn't make sense to me. I will try to explain what it is below,</div><div><br></div><div>In <b>opus_encode() </b>function, <b>opus_int16 pcm</b> is said to have a size of <b>frame_size * channels</b>, where <b>frame_size</b> is said to be one of<b> 20, 240, 480, 960, 1920, and 2880.</b></div><div>Let's say, frame_size is 960, then opus_int16 pcm's size in bytes would be <span id="gmail-m_7193814869509904971m_5372245715281859124gmail-cwos"><b>3840</b>. Documentation page says the recommended size for <b>output payload </b>should be around <b>4000.<br></b></span></div><div><span id="gmail-m_7193814869509904971m_5372245715281859124gmail-cwos">I check the return values returned by <b>opus_encode(), </b>and they are between 250 and 300, which is the length of the encoded packet.</span></div><div><span id="gmail-m_7193814869509904971m_5372245715281859124gmail-cwos"><br></span></div><div><span id="gmail-m_7193814869509904971m_5372245715281859124gmail-cwos">Now, we are supposed to send <b>ouput_payload</b> - which is 4000 bytes long - over the network. That means sending more bytes than sending opus_int16 pcm, which is length of <b>3840 </b>in bytes<b>.</b><br></span></div><div><span id="gmail-m_7193814869509904971m_5372245715281859124gmail-cwos">So what is the advantage of encoding the data if we are to send more bytes than initially held?<br></span></div></div></blockquote><div><br></div><div>You are supposed to send the first return-value bytes of the buffer.  The 4000 number is just the size of the buffer you are providing which is a hard limit for how much the encoder could output at once.</div><div><br></div><div> <br></div></div></div>