我正在尝试使用 libavformat 编写视频流应用程序。虽然 ffmpeg 和 libavformat 将 96 和 97 作为默认负载类型,但我想指定自定义 RTP 负载类型。我已经知道如何在 ffmpeg 的命令行中设置它,正如我回答 here ,但是我想在代码中给出它。我尝试了以下方法:
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 中的复用器,而不是协议(protocol),因此选项传递给 avformat_write_header
.
关于video - 如何在 libavformat 中设置 RTP 有效负载类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71827116/