[Libav-user] How to extract audio from an rtsp stream

Richard Hussong rhussong at westpond.com
Fri May 1 22:53:36 EEST 2020


On Thu, Apr 30, 2020 at 9:27 AM Denis Gottardello <info at denisgottardello.it>
wrote:

>
>
> Hi, I need to extract audio packets from an rtsp stream and to listen them
> with a Qt program.
>
> The examples are based on avcodec_decode_audio4 function but it is
> deprecated.
>
> Now I already have an audio packet. Now I have to trascode it in a format
> that I can manage with Qt, something like
>
>
>
> AVAudioResampleContext* resample_context_ = NULL;
>
> av_opt_set_int(resample_context_, "in_channel_layout",
> av_get_default_channel_layout(codec_context_->channels), 0);
>
> av_opt_set_int(resample_context_, "out_channel_layout",
> av_get_default_channel_layout(outputFormat_.channels), 0);
>
> av_opt_set_int(resample_context_, "in_sample_rate",
> codec_context_->sample_rate, 0);
>
> av_opt_set_int(resample_context_, "out_sample_rate", outputFormat_.rate,
> 0);
>
> av_opt_set_int(resample_context_, "in_sample_fmt",
> codec_context_->sample_fmt, 0);
>
> av_opt_set_int(resample_context_, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
>
> if (avresample_open(resample_context_) < 0) {
>
> qDebug() << "Could not open resample context.";
>
> avresample_free(&resample_context_);
>
> return;
>
> }
>
>
>
> but AVAudioResampleContext but it is deprecated too.
>

The entire libavresample library is deprecated. You should use
libswresample instead. Library documentation is at
https://ffmpeg.org/doxygen/trunk/group__lswr.html, and there is a usage
example at https://ffmpeg.org/doxygen/trunk/resampling_audio_8c-example.html
.

>
>
> Can someone suggest me a way from
>
>
>
> while (av_read_frame(pAVFormatContext, &pAVPacket)>= 0 && DoStart) {
>
> if (pAVPacket.stream_index== StreamAudio) {
>
> ...
>
> ..
>
>
>
> ??
>
> Many thanks
>
>
> --
>
> +39.347.4070897
>
> http://www.labcsp.com
>
> http://www.denisgottardello.it
>
> GMT+1
>
> Skype: mrdebug
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200501/ad39083a/attachment.html>


More information about the Libav-user mailing list