首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RTSP隧道HTTP,FFMPEG

RTSP隧道HTTP,FFMPEG
EN

Stack Overflow用户
提问于 2013-01-22 13:19:25
回答 1查看 6.4K关注 0票数 4

我正在尝试从Axis摄像机上流,它使用HTTP上的RTSP。我可以让正常的RTSP流工作,但是我找不到任何关于如何为流实际设置隧道模式的信息或文档。通过将control_transport设置为RTSP_MODE_TUNNEL,源代码中支持它。我的问题很简单,如何用下面的代码来完成这个任务?

代码语言:javascript
复制
 int ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip/axis-media/media.amp" UTF8String], NULL, NULL);

我尝试了以下几点:

代码语言:javascript
复制
pFormatCtx = avformat_alloc_context();
pFormatCtx->priv_data = malloc(sizeof(RTSPState));
RTSPState *rt = pFormatCtx->priv_data;
rt->control_transport = RTSP_MODE_TUNNEL;
int ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip/axis-media/media.amp" UTF8String], NULL, NULL);

但对于我来说,它只是忽略了它(它仍然继续使用RTP)。我也试过了

代码语言:javascript
复制
 int ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip/axis-media/media.amp" UTF8String], NULL, NULL);
RTSPState *rt = pFormatCtx->priv_data;
rt->control_transport = RTSP_MODE_TUNNEL;

我该怎么解决这个问题?我想这是很简单的事情,因为ENUM在那里。

工作解决方案是

代码语言:javascript
复制
AVDictionary *opts = 0;
int ret = av_dict_set(&opts, "rtsp_transport", "http", 0);


ret = avformat_open_input(&pFormatCtx, [@"rtsp://ip:80/axis-media/media.amp" UTF8String], NULL, &opts);

av_dict_free(&opts);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-22 16:42:15

你试过这个吗?

代码语言:javascript
复制
AVDictionary *opts = 0;
    if (usesTcp) {
        int ret = av_dict_set(&opts, "rtsp_transport", "tcp", 0);
    }


    err = avformat_open_input(&avfContext, filename, NULL, &opts);
    av_dict_free(&opts);
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14459513

复制
相关文章

相似问题

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