<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 30, 2020 at 9:27 AM Denis Gottardello <<a href="mailto:info@denisgottardello.it">info@denisgottardello.it</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"><u></u>
<div style="font-family:"Noto Sans";font-size:10pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Hi, I need to extract audio packets from an rtsp stream and to listen them with a Qt program.</p>
<p style="margin:0px;text-indent:0px">The examples are based on <span style="font-weight:600">avcodec_decode_audio4</span> function but it is deprecated.</p>
<p style="margin:0px;text-indent:0px">Now I already have an audio packet. Now I have to trascode it in a format that I can manage with Qt, something like</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px"><span style="font-weight:600">AVAudioResampleContext</span>* resample_context_ = NULL;</p>
<p style="margin:0px;text-indent:0px">av_opt_set_int(resample_context_, "in_channel_layout", av_get_default_channel_layout(codec_context_->channels), 0);</p>
<p style="margin:0px;text-indent:0px">av_opt_set_int(resample_context_, "out_channel_layout", av_get_default_channel_layout(outputFormat_.channels), 0);</p>
<p style="margin:0px;text-indent:0px">av_opt_set_int(resample_context_, "in_sample_rate", codec_context_->sample_rate, 0);</p>
<p style="margin:0px;text-indent:0px">av_opt_set_int(resample_context_, "out_sample_rate", outputFormat_.rate, 0);</p>
<p style="margin:0px;text-indent:0px">av_opt_set_int(resample_context_, "in_sample_fmt", codec_context_->sample_fmt, 0);</p>
<p style="margin:0px;text-indent:0px">av_opt_set_int(resample_context_, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);</p>
<p style="margin:0px;text-indent:0px">if (avresample_open(resample_context_) < 0) {</p>
<p style="margin:0px;text-indent:0px">    qDebug() << "Could not open resample context.";</p>
<p style="margin:0px;text-indent:0px">    avresample_free(&resample_context_);</p>
<p style="margin:0px;text-indent:0px">    return;</p>
<p style="margin:0px;text-indent:0px">}</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">but <span style="font-weight:600">AVAudioResampleContext</span> but it is deprecated too.</p></div></blockquote><div><br></div><div>The entire libavresample library is deprecated. You should use libswresample instead. Library documentation is at <a href="https://ffmpeg.org/doxygen/trunk/group__lswr.html">https://ffmpeg.org/doxygen/trunk/group__lswr.html</a>, and there is a usage example at <a href="https://ffmpeg.org/doxygen/trunk/resampling_audio_8c-example.html">https://ffmpeg.org/doxygen/trunk/resampling_audio_8c-example.html</a>.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:"Noto Sans";font-size:10pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Can someone suggest me a way from </p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">while (av_read_frame(pAVFormatContext, &pAVPacket)>= 0 && DoStart) {</p>
<p style="margin:0px;text-indent:0px">  if (pAVPacket.stream_index== StreamAudio) {</p>
<p style="margin:0px;text-indent:0px">  ...</p>
<p style="margin:0px;text-indent:0px">  ..</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">??</p>
<p style="margin:0px;text-indent:0px">Many thanks</p>
<p style="margin:0px;text-indent:0px"><br>-- </p>
<p style="margin:0px;text-indent:0px">+39.347.4070897</p>
<p style="margin:0px;text-indent:0px"><a href="http://www.labcsp.com" target="_blank"><span style="text-decoration:underline;color:rgb(41,128,185)">http://www.labcsp.com</span></a></p>
<p style="margin:0px;text-indent:0px"><a href="http://www.denisgottardello.it" target="_blank"><span style="text-decoration:underline;color:rgb(41,128,185)">http://www.denisgottardello.it</span></a></p>
<p style="margin:0px;text-indent:0px">GMT+1</p>
<p style="margin:0px;text-indent:0px">Skype: mrdebug</p></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".</blockquote></div></div>