[Libav-user] Decode audio from RTSP stream

yoann yoann at woozoom.net
Mon Jan 9 03:41:43 EET 2017


At 2017-01-06 19:28:31, "Gabor Alsecz" <alseczg at gmail.com> wrote:

Hello Guys,


Do you have any up-to-date example how can i decode audio from h264 RTSP stream and save to mp3? Thanks a lot!




br,
Gabor


If the audio from your RTSP stream is already mp3, you will just have too look at remuxing.c example, add a few lines for RTSP support such as : 
avformat_network_init();
AVDictionary *open_input_dict = NULL;
av_dict_set(&open_input_dict, "rtsp_transport", "tcp", 0);

avformat_open_input(&ifmt_ctx, in_filename, 0, &open_input_dict);
and filter audio packets, checking i for AVFormatContext->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_AUDIO and sorting the packets depending on their stream index.


If you also need to re-encode the audio, have a look at decoding_encoding.c and other examples. Here are some details for the new enconding / decoding API : https://blogs.gentoo.org/lu_zero/2016/03/29/new-avcodec-api/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170109/ddf78ea1/attachment.html>


More information about the Libav-user mailing list