videoffmpegrtplibavlibavformat

How to set RTP payload type in libavformat?


I am trying to write a video streaming application using libavformat. While ffmpeg and libavformat gives 96 & 97 as default payload types, I want to specify custom RTP payload type. I already know how to set it in ffmpeg's command line, as I answered here, however I want to give it inside the code. I tried the following:

AVFormatContext *ctx = avformat_alloc_context();
ctx->oformat = av_guess_format("rtp", NULL, NULL);
AVDictionary *options = NULL;
av_dict_set(&options, "payload_type", "128", 0);
//Assume url is set here
avio_open2(&ctx->pb, ctx->url, AVIO_FLAG_WRITE, NULL, &options);

However it does not work. Any suggestions how to set RTP payload type in libavformat?


Solution

  • rtp is a muxer in libavformat, not a protocol, so the options are passed to avformat_write_header.