<div dir="ltr">You may need to compute the output number of samples, indeed the<br><div class="gmail_extra"><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">

resampler can not guarantee that the number of samples requested will<br>
be returned due to caching or missing input data (e.g. when<br>
downsampling). Check the logic in resampling_audio.c, and check the<br>
swr_convert() return value in order to understand how many samples<br>
have been converted in your buffer.<br>
<br>
A more high-level conversion function may help to simplify the code.<br></blockquote></div><br></div><div class="gmail_extra">Hi <span name="Stefano Sabatini" class="">Stefano,<br><br></span></div><div class="gmail_extra">
<span name="Stefano Sabatini" class="">You are right, because I was actually downsampling (1152 bytes per frame to 1024), swr was holding back internal buffers, somehow. In resampling_audio.c example, I can see repeated calls to swr_convert function... I tried something different: flushing all swr buffers at the end of conversion process, and it worked just fine.<br>
<br></span></div><div class="gmail_extra"><span name="Stefano Sabatini" class="">The only downside is, it adds up to RAM - for smaller files, it is no problem, but for large files (just for example 05 hours file), it will be something like:<br>
<br></span></div><div class="gmail_extra"><span name="Stefano Sabatini" class="">1152 -1024= 128 bytes per frame<br></span></div><div class="gmail_extra"><span name="Stefano Sabatini" class="">128 * 60 = 7680 bytes per second (approx)<br>
</span></div><div class="gmail_extra"><span name="Stefano Sabatini" class="">7680 * 60 = </span>460800 bytes per minute<br></div><div class="gmail_extra">460800 * 60 = 27648000 bytes per hour<br></div><div class="gmail_extra">
27648000 * 5 = 138240000 bytes for five hour recording<br></div><div class="gmail_extra">= 131.83 MB added up inside RAM<br><br></div><div class="gmail_extra">And that is, assuming I have 60 audio frames per second (I'm sure this figure is not correct, because I need to evaluate how sampling rate effects above formula, as well).<br>
<br></div><div class="gmail_extra">So although I got it to work somehow, I am not really sure if this is the most elegant way of doing it. What do you advice?<br><br></div><div class="gmail_extra">p.s. During test process I tried using <br>
<br>av_rescale_rnd(swr_get_delay(swr_ctx, src_rate) +<br>    src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);<br><br></div><div class="gmail_extra">function, but noticed artifacts in destination audio file: plays faster, data seems to be 'packed' inside each audio frame, giving me audible artifacts in destination mp4.<br>
</div></div>