首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ffmpeg avio_open2()未能打开输出rtsp流

ffmpeg avio_open2()未能打开输出rtsp流
EN

Stack Overflow用户
提问于 2018-03-08 08:34:01
回答 1查看 1.8K关注 0票数 0

我使用ffmpeg H264编码,然后输出RTSP流。当我初始化时,我会遇到一些问题。当我通过avio_open2函数打开输出地址时,我返回错误-1330794744,这是无效的协议。我在哪里设置错误?

代码语言:javascript
复制
av_register_all(); 
avformat_network_init();
avformat_alloc_output_context2(&ofmt_ctx, NULL, "rtsp", rtsp_url);

if (!ofmt_ctx) 
{
    printf("Could not deduce output format from file extension: using MPEG.\n");
    avformat_alloc_output_context2(&ofmt_ctx, NULL, "mpeg", rtsp_url);
}
if (!ofmt_ctx) return;

this->out_fmt = ofmt_ctx->oformat;
if (!this->out_fmt)
{
    printf("Error creating outformat.\n");
    return;
}
video_st = add_stream(ofmt_ctx, &video_codec, CODEC_ID_H264, rate);
if (video_st)
{
    open_video(ofmt_ctx, video_codec, video_st);
}
int ret = avio_open2(&ofmt_ctx->pb, "rtsp://127.0.0.1:8854/live.sdp", AVIO_FLAG_WRITE, NULL, NULL);
if (ret < 0)
{
    printf("Could not open outfile '%s'.", rtsp_url);
    return;
}
EN

回答 1

Stack Overflow用户

发布于 2020-06-11 07:55:14

RTSP不同于定义为基于FLV的纯协议的RTSP是一种格式,同时也是一种协议。FFmpeg将在分配输出上下文时自动创建io上下文,因此不再需要手动调用avio_open。

只需评论avio_open2,它应该工作得很好。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49168678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档