<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I’m trying to mux an audio stream at 192 <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">KHz.</span> The audio codec is AAC which is limited to 96 KHz. Since, this codec is not compatible with 192 <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">KHz</span>, the maximum 96 <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">KHz</span> will be used and the result is an incorrect audio stream. I have based my code on the muxing.c example:</div><div class=""><br class=""></div><div class=""><a href="https://ffmpeg.org/doxygen/trunk/muxing_8c-example.html" class="">https://ffmpeg.org/doxygen/trunk/muxing_8c-example.html</a></div><div class=""><br class=""></div><div class="">This example initialises a sample rate converter at open_audio function. As per my understanding, the sample rate converter is used in the write_audio_frame function in order to convert the input audio stream sample rate into the codec sample rate.  However, in the open_audio function, during the sample rate converter initialisation:</div><div class=""><span style="color: rgb(0, 0, 0); font-family: monospace, fixed; font-size: 13px; orphans: 2; text-indent: -53px; white-space: pre-wrap; widows: 2;" class=""> </span></div><div class=""><div class="line" style="font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; overflow-wrap: break-word; text-indent: -53px; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; transition-duration: 0.5s; color: rgb(0, 0, 0); orphans: 2; widows: 2; text-decoration-thickness: initial;"><a class="code" href="https://ffmpeg.org/doxygen/trunk/group__opt__set__funcs.html#ga3adf7185c21cc080890a5ec02c2e56b2" style="color: rgb(70, 101, 162); text-decoration: none;">av_opt_set_int</a>       (<a class="code" href="https://ffmpeg.org/doxygen/trunk/vaapi__transcode_8c.html#a3e44252189bdae5212c5d1171bcd7cf4" style="color: rgb(70, 101, 162); text-decoration: none;">ost</a>->swr_ctx, <span class="stringliteral" style="color: rgb(0, 32, 128);">"in_sample_rate"</span>,     <a class="code" href="https://ffmpeg.org/doxygen/trunk/undefined_8txt.html#a12d8853991e25cc8d069554379c29ef6" style="color: rgb(70, 101, 162); text-decoration: none;">c</a>->sample_rate,    0);</div><div class="line" style="font-stretch: normal; font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; overflow-wrap: break-word; text-indent: -53px; padding-left: 53px; padding-bottom: 0px; margin: 0px; transition-property: background-color, box-shadow; transition-duration: 0.5s; color: rgb(0, 0, 0); orphans: 2; widows: 2; text-decoration-thickness: initial;"><a class="code" href="https://ffmpeg.org/doxygen/trunk/group__opt__set__funcs.html#ga3adf7185c21cc080890a5ec02c2e56b2" style="color: rgb(70, 101, 162); text-decoration: none;">av_opt_set_int</a>       (<a class="code" href="https://ffmpeg.org/doxygen/trunk/vaapi__transcode_8c.html#a3e44252189bdae5212c5d1171bcd7cf4" style="color: rgb(70, 101, 162); text-decoration: none;">ost</a>->swr_ctx, <span class="stringliteral" style="color: rgb(0, 32, 128);">"out_sample_rate"</span>,    <a class="code" href="https://ffmpeg.org/doxygen/trunk/undefined_8txt.html#a12d8853991e25cc8d069554379c29ef6" style="color: rgb(70, 101, 162); text-decoration: none;">c</a>->sample_rate,    0);</div></div><span class=""><br class=""></span><div class="">The input sample rate is the same as the output sample rate. Trying to change the input sample rate to match the audio stream sample rate results in a assertion fail in write_audio_frame function:</div><div class=""><br class=""></div><div class=""><a class="code" href="https://ffmpeg.org/doxygen/trunk/avassert_8h.html#aae204192396f78cc8c5cd7ad5c57c23f" style="color: rgb(70, 101, 162); text-decoration: none; font-family: monospace, fixed; font-size: 13px; font-variant-ligatures: normal; orphans: 2; text-indent: -53px; white-space: pre-wrap; widows: 2; background-color: rgb(251, 252, 253);">av_assert0</a><span style="color: rgb(0, 0, 0); font-family: monospace, fixed; font-size: 13px; font-variant-ligatures: normal; orphans: 2; text-indent: -53px; white-space: pre-wrap; widows: 2; background-color: rgb(251, 252, 253); text-decoration-thickness: initial;" class="">(dst_nb_samples == </span><a class="code" href="https://ffmpeg.org/doxygen/trunk/filter__design_8txt.html#a48ad71a5b40cdd5f23c601f33665a953" style="color: rgb(70, 101, 162); text-decoration: none; font-family: monospace, fixed; font-size: 13px; font-variant-ligatures: normal; orphans: 2; text-indent: -53px; white-space: pre-wrap; widows: 2; background-color: rgb(251, 252, 253);">frame</a><span style="color: rgb(0, 0, 0); font-family: monospace, fixed; font-size: 13px; font-variant-ligatures: normal; orphans: 2; text-indent: -53px; white-space: pre-wrap; widows: 2; background-color: rgb(251, 252, 253); text-decoration-thickness: initial;" class="">->nb_samples);</span></div><span class=""><br class=""></span><span class="">What is correct way of taking advantage of the already existing sample rate converter in order to have the audio stream that is being generated at 192khz, being encoded at 96Khz?</span><div class=""><br class=""></div><div class="">Thanks in advance!</div><div class=""><br class=""></div><div class="">Best regards,</div><div class=""><br class=""></div><div class="">Nuno<br class=""><div class=""><span class=""><br class=""></span></div><div class=""><span class=""><br class=""></span><span class=""><br class=""></span><span class=""><br class=""></span></div></div></body></html>