如何在 libavformat 中设置 RTP 负载类型?

How to set RTP payload type in libavformat?

我正在尝试使用 libavformat 编写视频流应用程序。虽然 ffmpeg 和 libavformat 提供 96 和 97 作为默认负载类型,但我想指定自定义 RTP 负载类型。正如我回答的那样,我已经知道如何在 ffmpeg 的命令行中设置它 ,但是我想在代码中给出它。我尝试了以下方法:

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);

然而它不起作用。关于如何在 libavformat 中设置 RTP 负载类型有什么建议吗?

rtp 是 libavformat 中的多路复用器,而不是协议,因此选项被传递给 avformat_write_header