<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 27, 2021 at 7:19 PM Baumgarten, Julien <<a href="mailto:julien.baumgarten@viadialog.com">julien.baumgarten@viadialog.com</a>> wrote:<br></div><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>Thx Bob for your advice.<br>I'll try to re-sample then encode.</div><div><br></div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div><table style="vertical-align:-webkit-baseline-middle;font-size:medium;font-family:Arial" cellspacing="0" cellpadding="0"><tbody><tr><td><table style="vertical-align:-webkit-baseline-middle;font-family:Arial" cellspacing="0" cellpadding="0"><tbody><tr><td style="vertical-align:middle" width="150"><img alt="avatar" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/avatars/avatar-julien-baumgarten.jfif" style="max-width: 130px; border-color: rgb(94, 134, 195); border-radius: 50%; border-style: solid; border-width: 4px;" width="130"> <a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_logo" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><img alt="viadialog" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/viadialog-logo-color.png" style="margin-top: 5px; max-width: 130px;" width="130"></a></td><td width="30"><div style="width:30px"></div></td><td color="#5e86c3" style="width:3px;background-color:rgb(94,134,195);border-bottom:none;border-radius:1.5px" width="3"></td><td width="30"><div style="width:30px"></div></td><td style="vertical-align:bottom"><h3 color="#000000" style="margin:0px;font-size:18px;color:rgb(0,0,0)">Julien BAUMGARTEN</h3><p color="#000000" style="margin:0px 0px 15px;color:rgb(235,101,29);font-size:15px;line-height:22px">Chef de Projet Développement</p><a href="tel:0177453094" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">01 77 45 30 94</p></a><a href="mailto:julien.baumgarten@viadialog.com" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">julien.baumgarten@viadialog.com</p></a><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_link" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">www.viadialog.com</p></a><p color="#000000" style="margin:0px;color:rgb(102,102,102);font-size:14px;line-height:22px">152 Boulevard Pereire, 75017 Paris</p><table style="vertical-align:-webkit-baseline-middle;font-family:Arial;width:100%" cellspacing="0" cellpadding="0"><tbody><tr><td style="vertical-align:top"><table style="vertical-align:-webkit-baseline-middle;font-family:Arial;display:inline-block" cellspacing="0" cellpadding="0"><tbody><tr style="text-align:right"><td><a rel="noopener noreferrer" href="https://www.facebook.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/facebook.png" alt="facebook" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td><td><a rel="noopener noreferrer" href="https://twitter.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/twitter.png" alt="twitter" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td><td><a rel="noopener noreferrer" href="https://www.linkedin.com/company/viatelecom" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/linkedin.png" alt="linkedin" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td height="20"></td></tr><tr><td><span style="display:block"><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_banner" style="border-width:initial;border-style:none;border-color:initial;display:inline-block;background-color:transparent;color:rgb(255,255,255);font-weight:700;text-align:center;line-height:1;font-size:12px;border-radius:3px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/banner-viadialog.png" style="max-width: 728px;"></a></span></td></tr><tr><td height="20"></td></tr><tr><td><span style="display:block;font-size:8px;color:rgb(136,136,136);padding-top:5px">This
email message (including its attachments) is confidential and may
contain privileged information and is intended solely for the use of the
individual and/or entity to whom it is addressed. If you are not the
intended recipient of this e-mail you may not share, distribute or copy
this e-mail (including its attachments), or any part thereof. If this
e-mail is received in error, please notify the sender immediately by
return e-mail and make sure that this e-mail (including its
attachments), and all copies thereof, are immediately deleted from your
system. Please further note that when you communicate with us via email
or visit our website we process your personal data. See our privacy
policy for more information about how we process it:
<a href="https://www.viadialog.com/mentions-legales" target="_blank">https://www.viadialog.com/mentions-legales</a></span></td></tr></tbody></table>
</div>
</div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 27 août 2021 à 17:31, Bob Kirnum <<a href="mailto:bkirnum@gmail.com" target="_blank">bkirnum@gmail.com</a>> a écrit :<br></div><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">My understanding is that re-sampling is done on linear PCM, not encoded audio (G.711 PCM). I always encode after re-sampling.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 27, 2021 at 6:38 AM Baumgarten, Julien <<a href="mailto:julien.baumgarten@viadialog.com" target="_blank">julien.baumgarten@viadialog.com</a>> wrote:<br></div><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">I don't succeed in encode with ffmpeg library.<div>So I do the encoding before the resampling.</div><div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div><table style="vertical-align:-webkit-baseline-middle;font-size:medium;font-family:Arial" cellspacing="0" cellpadding="0"><tbody><tr><td><table style="vertical-align:-webkit-baseline-middle;font-family:Arial" cellspacing="0" cellpadding="0"><tbody><tr><td style="vertical-align:middle" width="150"><img alt="avatar" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/avatars/avatar-julien-baumgarten.jfif" style="max-width: 130px; border-color: rgb(94, 134, 195); border-radius: 50%; border-style: solid; border-width: 4px;" width="130"> <a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_logo" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><img alt="viadialog" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/viadialog-logo-color.png" style="margin-top: 5px; max-width: 130px;" width="130"></a></td><td width="30"><div style="width:30px"></div></td><td color="#5e86c3" style="width:3px;background-color:rgb(94,134,195);border-bottom:none;border-radius:1.5px" width="3"></td><td width="30"><div style="width:30px"></div></td><td style="vertical-align:bottom"><h3 color="#000000" style="margin:0px;font-size:18px;color:rgb(0,0,0)">Julien BAUMGARTEN</h3><p color="#000000" style="margin:0px 0px 15px;color:rgb(235,101,29);font-size:15px;line-height:22px">Chef de Projet Développement</p><a href="tel:0177453094" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">01 77 45 30 94</p></a><a href="mailto:julien.baumgarten@viadialog.com" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">julien.baumgarten@viadialog.com</p></a><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_link" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">www.viadialog.com</p></a><p color="#000000" style="margin:0px;color:rgb(102,102,102);font-size:14px;line-height:22px">152 Boulevard Pereire, 75017 Paris</p><table style="vertical-align:-webkit-baseline-middle;font-family:Arial;width:100%" cellspacing="0" cellpadding="0"><tbody><tr><td style="vertical-align:top"><table style="vertical-align:-webkit-baseline-middle;font-family:Arial;display:inline-block" cellspacing="0" cellpadding="0"><tbody><tr style="text-align:right"><td><a rel="noopener noreferrer" href="https://www.facebook.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/facebook.png" alt="facebook" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td><td><a rel="noopener noreferrer" href="https://twitter.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/twitter.png" alt="twitter" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td><td><a rel="noopener noreferrer" href="https://www.linkedin.com/company/viatelecom" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/linkedin.png" alt="linkedin" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td height="20"></td></tr><tr><td><span style="display:block"><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_banner" style="border-width:initial;border-style:none;border-color:initial;display:inline-block;background-color:transparent;color:rgb(255,255,255);font-weight:700;text-align:center;line-height:1;font-size:12px;border-radius:3px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/banner-viadialog.png" style="max-width: 728px;"></a></span></td></tr><tr><td height="20"></td></tr><tr><td><span style="display:block;font-size:8px;color:rgb(136,136,136);padding-top:5px">This
email message (including its attachments) is confidential and may
contain privileged information and is intended solely for the use of the
individual and/or entity to whom it is addressed. If you are not the
intended recipient of this e-mail you may not share, distribute or copy
this e-mail (including its attachments), or any part thereof. If this
e-mail is received in error, please notify the sender immediately by
return e-mail and make sure that this e-mail (including its
attachments), and all copies thereof, are immediately deleted from your
system. Please further note that when you communicate with us via email
or visit our website we process your personal data. See our privacy
policy for more information about how we process it:
<a href="https://www.viadialog.com/mentions-legales" target="_blank">https://www.viadialog.com/mentions-legales</a></span></td></tr></tbody></table>
</div>
</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 27 août 2021 à 12:55, Bob Kirnum <<a href="mailto:bkirnum@gmail.com" target="_blank">bkirnum@gmail.com</a>> a écrit :<br></div><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">In addition to re-sampling from 16 kHz to 8 kHz, are you then encoding the resulting 8 kHz linear PCM (16 bit?) to G.711 (Alaw?)?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 27, 2021 at 2:08 AM Baumgarten, Julien <<a href="mailto:julien.baumgarten@viadialog.com" target="_blank">julien.baumgarten@viadialog.com</a>> wrote:<br></div><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">Hi Polochon,<div><br></div><div>Thx for your answer. I know I'll lose on audio quality by resampling 16kHZ to 8kHZ but I need to play the audio on VOIP calls which requires G711 a-law 8k HZ samples :(</div><div>If I work with your command line, the sound is faaaaaaaaaaar much better. No noise at all</div><div><br></div><div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div><table style="vertical-align:-webkit-baseline-middle;font-size:medium;font-family:Arial" cellspacing="0" cellpadding="0"><tbody><tr><td><table style="vertical-align:-webkit-baseline-middle;font-family:Arial" cellspacing="0" cellpadding="0"><tbody><tr><td style="vertical-align:middle" width="150"><img alt="avatar" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/avatars/avatar-julien-baumgarten.jfif" style="max-width: 130px; border-color: rgb(94, 134, 195); border-radius: 50%; border-style: solid; border-width: 4px;" width="130"> <a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_logo" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><img alt="viadialog" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/viadialog-logo-color.png" style="margin-top: 5px; max-width: 130px;" width="130"></a></td><td width="30"><div style="width:30px"></div></td><td color="#5e86c3" style="width:3px;background-color:rgb(94,134,195);border-bottom:none;border-radius:1.5px" width="3"></td><td width="30"><div style="width:30px"></div></td><td style="vertical-align:bottom"><h3 color="#000000" style="margin:0px;font-size:18px;color:rgb(0,0,0)">Julien BAUMGARTEN</h3><p color="#000000" style="margin:0px 0px 15px;color:rgb(235,101,29);font-size:15px;line-height:22px">Chef de Projet Développement</p><a href="tel:0177453094" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">01 77 45 30 94</p></a><a href="mailto:julien.baumgarten@viadialog.com" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">julien.baumgarten@viadialog.com</p></a><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_link" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><p color="#000000" style="margin:0px;font-size:14px;line-height:22px">www.viadialog.com</p></a><p color="#000000" style="margin:0px;color:rgb(102,102,102);font-size:14px;line-height:22px">152 Boulevard Pereire, 75017 Paris</p><table style="vertical-align:-webkit-baseline-middle;font-family:Arial;width:100%" cellspacing="0" cellpadding="0"><tbody><tr><td style="vertical-align:top"><table style="vertical-align:-webkit-baseline-middle;font-family:Arial;display:inline-block" cellspacing="0" cellpadding="0"><tbody><tr style="text-align:right"><td><a rel="noopener noreferrer" href="https://www.facebook.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/facebook.png" alt="facebook" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td><td><a rel="noopener noreferrer" href="https://twitter.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/twitter.png" alt="twitter" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td><td><a rel="noopener noreferrer" href="https://www.linkedin.com/company/viatelecom" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/linkedin.png" alt="linkedin" style="max-width: 135px; display: block;" height="24"></a></td><td width="5"><div></div></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td height="20"></td></tr><tr><td><span style="display:block"><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_banner" style="border-width:initial;border-style:none;border-color:initial;display:inline-block;background-color:transparent;color:rgb(255,255,255);font-weight:700;text-align:center;line-height:1;font-size:12px;border-radius:3px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/banner-viadialog.png" style="max-width: 728px;"></a></span></td></tr><tr><td height="20"></td></tr><tr><td><span style="display:block;font-size:8px;color:rgb(136,136,136);padding-top:5px">This
email message (including its attachments) is confidential and may
contain privileged information and is intended solely for the use of the
individual and/or entity to whom it is addressed. If you are not the
intended recipient of this e-mail you may not share, distribute or copy
this e-mail (including its attachments), or any part thereof. If this
e-mail is received in error, please notify the sender immediately by
return e-mail and make sure that this e-mail (including its
attachments), and all copies thereof, are immediately deleted from your
system. Please further note that when you communicate with us via email
or visit our website we process your personal data. See our privacy
policy for more information about how we process it:
<a href="https://www.viadialog.com/mentions-legales" target="_blank">https://www.viadialog.com/mentions-legales</a></span></td></tr></tbody></table>
</div>
</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 27 août 2021 à 00:00, Polochon Street <<a href="mailto:polochonstreet@gmx.fr" target="_blank">polochonstreet@gmx.fr</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hi,</p>
<p>I'm by no means an expert, but just a remark - 8kHz is somewhat
low quality, so maybe that's why the audio sounds awful?</p>
<p>Does it sound better when you try resampling it manually via
something like `ffmpeg -i input.wav -ar 8000 output.wav`?</p>
<p>Best,<br>
Paul<br>
</p>
<div> Le 26/08/2021 à 20:55, Baumgarten,
Julien a écrit :<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>Hi guys,</div>
<div><br>
I made a previous post in order to get some help in
converting + resampling 16bit PCM (16k HZ) samples to A-law
PCM (8k HZ) samples.</div>
<div>I succeeded in converting with another library than ffmpeg
but it works.<br>
I am focusing now on the resampling.</div>
<div><br>
</div>
<div>I tried the following source code:</div>
<div><br>
</div>
<div>
<pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace"><span style="color:rgb(185,188,209)">int64_t </span>src_ch_layout = <span style="color:rgb(144,139,37)">AV_CH_LAYOUT_MONO</span><span style="color:rgb(204,120,50)">, </span>dst_ch_layout = <span style="color:rgb(144,139,37)">AV_CH_LAYOUT_MONO</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> int </span>src_rate = <span style="color:rgb(104,151,187)">16000</span><span style="color:rgb(204,120,50)">, </span>dst_rate = <span style="color:rgb(104,151,187)">8000</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(185,188,209)">uint8_t </span>**src_data = <span style="color:rgb(144,139,37)">NULL</span><span style="color:rgb(204,120,50)">, </span>**dst_data = <span style="color:rgb(144,139,37)">NULL</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> int </span>src_nb_channels = <span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">, </span>dst_nb_channels = <span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> int </span>src_linesize = <span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">, </span>dst_linesize = <span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> int </span>src_nb_samples = <span style="color:rgb(204,120,50)">this</span>-><span style="color:rgb(147,115,165)">_nbSamplesReceived</span><span style="color:rgb(204,120,50)">, </span>dst_nb_samples<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> enum </span><span style="color:rgb(181,182,227)">AVSampleFormat </span>src_sample_fmt = <span style="color:rgb(152,118,170);font-style:italic">AV_SAMPLE_FMT_U8</span><span style="color:rgb(204,120,50)">, </span>dst_sample_fmt = <span style="color:rgb(152,118,170);font-style:italic">AV_SAMPLE_FMT_U8</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> const char </span>*dst_filename = <span style="color:rgb(106,135,89)">"/tmp/resample.raw"</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(185,188,209)">FILE </span>*dst_file<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> int </span>dst_bufsize<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> const char </span>*fmt<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> struct </span><span style="color:rgb(181,182,227)">SwrContext </span>*swr_ctx<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> int </span>ret<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span><span style="color:rgb(204,120,50)"> </span>dst_file = fopen(dst_filename<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"wb"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(!dst_file) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Could not open destination file %s</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span><span style="color:rgb(204,120,50)">, </span>dst_filename)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>exit(<span style="color:rgb(104,151,187)">1</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>}
swr_ctx = swr_alloc()<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(!swr_ctx) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Could not allocate resampler context</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>ret = <span style="color:rgb(144,139,37)">AVERROR</span>(ENOMEM)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(128,128,128)">// goto end;
</span><span style="color:rgb(128,128,128)"> </span>}
<span style="color:rgb(128,128,128)">/* set in options */
</span><span style="color:rgb(128,128,128)"> </span>av_opt_set_int(swr_ctx<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"in_channel_layout"</span><span style="color:rgb(204,120,50)">, </span>src_ch_layout<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>av_opt_set_int(swr_ctx<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"in_sample_rate"</span><span style="color:rgb(204,120,50)">, </span>src_rate<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>av_opt_set_sample_fmt(swr_ctx<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"in_sample_fmt"</span><span style="color:rgb(204,120,50)">, </span>src_sample_fmt<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">/* set out options */
</span><span style="color:rgb(128,128,128)"> </span>av_opt_set_int(swr_ctx<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"out_channel_layout"</span><span style="color:rgb(204,120,50)">, </span>dst_ch_layout<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>av_opt_set_int(swr_ctx<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"out_sample_rate"</span><span style="color:rgb(204,120,50)">, </span>dst_rate<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>av_opt_set_sample_fmt(swr_ctx<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"out_sample_fmt"</span><span style="color:rgb(204,120,50)">, </span>dst_sample_fmt<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">/* initialize the resampling context */
</span><span style="color:rgb(128,128,128)"> </span><span style="color:rgb(204,120,50)">if </span>((ret = swr_init(swr_ctx)) < <span style="color:rgb(104,151,187)">0</span>) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Failed to initialize the resampling context</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(128,128,128)">// goto end;
</span><span style="color:rgb(128,128,128)"> </span>}
<span style="color:rgb(128,128,128)">/* Define nb channels */
</span><span style="color:rgb(128,128,128)"> </span>src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>dst_nb_channels = av_get_channel_layout_nb_channels(dst_ch_layout)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">// Define ouput nb samples
</span><span style="color:rgb(128,128,128)"> </span>dst_nb_samples = av_rescale_rnd(src_nb_samples<span style="color:rgb(204,120,50)">, </span>dst_rate<span style="color:rgb(204,120,50)">, </span>src_rate<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(152,118,170);font-style:italic">AV_ROUND_UP</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>ret = av_samples_alloc_array_and_samples(&src_data<span style="color:rgb(204,120,50)">, </span>&src_linesize<span style="color:rgb(204,120,50)">, </span>src_nb_channels<span style="color:rgb(204,120,50)">, </span>src_nb_samples<span style="color:rgb(204,120,50)">, </span>src_sample_fmt<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(ret < <span style="color:rgb(104,151,187)">0</span>) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Could not allocate source samples</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(128,128,128)">// goto end;
</span><span style="color:rgb(128,128,128)"> </span>}
ret = av_samples_alloc_array_and_samples(&dst_data<span style="color:rgb(204,120,50)">, </span>&dst_linesize<span style="color:rgb(204,120,50)">, </span>dst_nb_channels<span style="color:rgb(204,120,50)">, </span>dst_nb_samples<span style="color:rgb(204,120,50)">, </span>dst_sample_fmt<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(ret < <span style="color:rgb(104,151,187)">0</span>) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Could not allocate destination samples</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(128,128,128)">// goto end;
</span><span style="color:rgb(128,128,128)"> </span>}
<span style="color:rgb(128,128,128)">// Fill source samples buffer with A-law samples
</span><span style="color:rgb(128,128,128)"> </span><span style="color:rgb(204,120,50)">unsigned int </span>i = <span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(181,182,227)">std</span>::for_each(<span style="color:rgb(204,120,50)">this</span>-><span style="color:rgb(147,115,165)">_test1</span>.begin()<span style="color:rgb(204,120,50)">, this</span>-><span style="color:rgb(147,115,165)">_test1</span>.end()<span style="color:rgb(204,120,50)">, </span>[<span style="color:rgb(204,120,50)">this, </span>&src_data<span style="color:rgb(204,120,50)">, </span>&i](<span style="color:rgb(204,120,50)">const </span><span style="color:rgb(185,188,209)">uint8_t </span>&data) {
src_data[<span style="color:rgb(104,151,187)">0</span>][i++] = data<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>})<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(128,128,128)">
</span><span style="color:rgb(128,128,128)"> /* convert to destination format */
</span><span style="color:rgb(128,128,128)"> </span>ret = swr_convert(swr_ctx<span style="color:rgb(204,120,50)">, </span>dst_data<span style="color:rgb(204,120,50)">, </span>dst_nb_samples<span style="color:rgb(204,120,50)">, </span>(<span style="color:rgb(204,120,50)">const </span><span style="color:rgb(185,188,209)">uint8_t </span>**)src_data<span style="color:rgb(204,120,50)">, </span>src_nb_samples)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(ret < <span style="color:rgb(104,151,187)">0</span>) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Error while converting</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">// </span><span style="color:rgb(168,192,35);font-style:italic">TODO: handle error
</span><span style="color:rgb(168,192,35);font-style:italic"> </span>}
dst_bufsize = av_samples_get_buffer_size(&dst_linesize<span style="color:rgb(204,120,50)">, </span>dst_nb_channels<span style="color:rgb(204,120,50)">, </span>ret<span style="color:rgb(204,120,50)">, </span>dst_sample_fmt<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">1</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(dst_bufsize < <span style="color:rgb(104,151,187)">0</span>) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Could not get sample buffer size</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">// </span><span style="color:rgb(168,192,35);font-style:italic">TODO: handle error
</span><span style="color:rgb(168,192,35);font-style:italic"> </span>}
<span style="color:rgb(128,128,128)">// Write resampled data into file
</span><span style="color:rgb(128,128,128)"> </span>fwrite(dst_data[<span style="color:rgb(104,151,187)">0</span>]<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">1</span><span style="color:rgb(204,120,50)">, </span>dst_bufsize<span style="color:rgb(204,120,50)">, </span>dst_file)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>((ret = get_format_from_sample_fmt(&fmt<span style="color:rgb(204,120,50)">, </span>dst_sample_fmt)) < <span style="color:rgb(104,151,187)">0</span>) {
fprintf(<span style="color:rgb(144,139,37)">stderr</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"Resampling failed.</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">// </span><span style="color:rgb(168,192,35);font-style:italic">TODO: handle error
</span><span style="color:rgb(168,192,35);font-style:italic"> </span>}
<span style="color:rgb(128,128,128)">// Close out file
</span><span style="color:rgb(128,128,128)"> </span>fclose(dst_file)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(128,128,128)">// Release memory
</span><span style="color:rgb(128,128,128)"> </span><span style="color:rgb(204,120,50)">if </span>(src_data) av_freep(&src_data[<span style="color:rgb(104,151,187)">0</span>])<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>av_freep(&src_data)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> if </span>(dst_data) av_freep(&dst_data[<span style="color:rgb(104,151,187)">0</span>])<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>av_freep(&dst_data)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)"> </span>swr_free(&swr_ctx)<span style="color:rgb(204,120,50)">;</span></pre>
</div>
<div>When dst_rate is equal to src_rate, the output is OK
without any noise.</div>
<div>However, when dst_rate is lower than src_rate, the audio is
awful with too much noise.</div>
<div><br>
</div>
<div>Did I miss something or am I doing something wrong?<br>
<br>
Yours sincerely,</div>
<div>Julien BAUMGARTEN</div>
<div><br>
</div>
<br clear="all">
<div>
<div dir="ltr">
<div dir="ltr">
<div>
<table style="vertical-align:-webkit-baseline-middle;font-size:medium;font-family:Arial" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="vertical-align:-webkit-baseline-middle;font-family:Arial" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="vertical-align:middle" width="150"><img alt="avatar" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/avatars/avatar-julien-baumgarten.jfif" style="max-width: 130px; border-color: rgb(94, 134, 195); border-radius: 50%; border-style: solid; border-width: 4px;" width="130"> <a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_logo" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank"><img alt="viadialog" src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/viadialog-logo-color.png" style="margin-top: 5px; max-width: 130px;" width="130"></a></td>
<td width="30"><br>
</td>
<td color="#5e86c3" style="width:3px;background-color:rgb(94,134,195);border-bottom:none;border-radius:1.5px" width="3"><br>
</td>
<td width="30"><br>
</td>
<td style="vertical-align:bottom">
<h3 color="#000000" style="margin:0px;font-size:18px;color:rgb(0,0,0)">Julien BAUMGARTEN</h3>
<p color="#000000" style="margin:0px 0px 15px;color:rgb(235,101,29);font-size:15px;line-height:22px">Chef
de Projet Développement</p>
<a href="tel:0177453094" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank">
<p color="#000000" style="margin:0px;font-size:14px;line-height:22px">01
77 45 30 94</p>
</a><a href="mailto:julien.baumgarten@viadialog.com" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank">
<p color="#000000" style="margin:0px;font-size:14px;line-height:22px">julien.baumgarten@viadialog.com</p>
</a><a rel="noopener noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_link" color="#000000" style="color:rgb(102,102,102);font-size:12px" target="_blank">
<p color="#000000" style="margin:0px;font-size:14px;line-height:22px">www.viadialog.com</p>
</a>
<p color="#000000" style="margin:0px;color:rgb(102,102,102);font-size:14px;line-height:22px">152
Boulevard Pereire, 75017 Paris</p>
<table style="vertical-align:-webkit-baseline-middle;font-family:Arial;width:100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="vertical-align:top">
<table style="vertical-align:-webkit-baseline-middle;font-family:Arial;display:inline-block" cellspacing="0" cellpadding="0">
<tbody>
<tr style="text-align:right">
<td><a rel="noopener
noreferrer" href="https://www.facebook.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/facebook.png" alt="facebook" style="max-width: 135px; display: block;" height="24"></a></td>
<td width="5"><br>
</td>
<td><a rel="noopener
noreferrer" href="https://twitter.com/viadialog" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/twitter.png" alt="twitter" style="max-width: 135px; display: block;" height="24"></a></td>
<td width="5"><br>
</td>
<td><a rel="noopener
noreferrer" href="https://www.linkedin.com/company/viatelecom" style="display:inline-block;padding:0px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/linkedin.png" alt="linkedin" style="max-width: 135px; display: block;" height="24"></a></td>
<td width="5"><br>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="20"><br>
</td>
</tr>
<tr>
<td><span style="display:block"><a rel="noopener
noreferrer" href="https://www.viadialog.com/?utm_source=signature&utm_medium=email&utm_campaign=email_signature_banner" style="border-width:initial;border-style:none;border-color:initial;display:inline-block;background-color:transparent;color:rgb(255,255,255);font-weight:700;text-align:center;line-height:1;font-size:12px;border-radius:3px" target="_blank"><img src="https://viadialog-signature-assets.s3-eu-west-1.amazonaws.com/shared/banner-viadialog.png" style="max-width: 728px;"></a></span></td>
</tr>
<tr>
<td height="20"><br>
</td>
</tr>
<tr>
<td><span style="display:block;font-size:8px;color:rgb(136,136,136);padding-top:5px">This
email message (including its attachments) is
confidential and may contain privileged
information and is intended solely for the use
of the individual and/or entity to whom it is
addressed. If you are not the intended
recipient of this e-mail you may not share,
distribute or copy this e-mail (including its
attachments), or any part thereof. If this
e-mail is received in error, please notify the
sender immediately by return e-mail and make
sure that this e-mail (including its
attachments), and all copies thereof, are
immediately deleted from your system. Please
further note that when you communicate with us
via email or visit our website we process your
personal data. See our privacy policy for more
information about how we process it: <a href="https://www.viadialog.com/mentions-legales" target="_blank">https://www.viadialog.com/mentions-legales</a></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Libav-user mailing list
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a>
To unsubscribe, visit link above, or email
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".
</pre>
</blockquote>
</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div><br clear="all"><div><br></div><div>Hello, </div><div><br></div><div>Also make sure that the number of samples set while opening the encoder matches the actual number of samples that you are feeding the encoder and that number of samples matches what you set in the stream's container. For me when these numbers were off I always had problems with the sound. </div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><br>Regards<br>Strahinja Radman</div></div>