简体   繁体   English

RTSP隧道HTTP,FFMPEG

[英]RTSP tunneled HTTP, FFMPEG

I'm trying to stream from an Axis ip camera which uses RTSP over HTTP. 我正在尝试从使用RTSP over HTTP的Axis ip camera流式传输。 I can get the normal RTSP stream to work, but I can't find any information or documentation on how to actually set the tunneling mode for the stream. 我可以使普通的RTSP流工作,但是我找不到有关如何为流实际设置隧道模式的任何信息或文档。 It is supported in the source code by setting the control_transport to RTSP_MODE_TUNNEL . 通过将control_transport设置为RTSP_MODE_TUNNEL,源代码支持它。 My question is simple how do I do this with the following code? 我的问题很简单,如何使用以下代码执行此操作?

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

I tried the following: 我尝试了以下方法:

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

But it simply ignores it for me (It still keeps using RTP). 但它只是忽略了它(它仍然继续使用RTP)。 I tried this aswell 我试过这个

 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;

How would I solve this? 我该如何解决这个问题? I'm thinking it's something really simple since the ENUM is there. 我认为这很简单,因为ENUM就在那里。

Working solution is 工作解决方案是

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

did you try this 你试过这个吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM