RTSP tunneled HTTP, FFMPEG

天大地大妈咪最大 提交于 2019-12-04 14:37:26

问题


I'm trying to stream from an Axis ip camera which uses RTSP over HTTP. 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. It is supported in the source code by setting the control_transport to 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). 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.

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

回答1:


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


来源:https://stackoverflow.com/questions/14459513/rtsp-tunneled-http-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!