-->

RTSP隧道HTTP,FFMPEG(RTSP tunneled HTTP, FFMPEG)

2019-08-07 19:28发布

我试图从使用RTSP通过HTTP安讯士网络摄像机到流。 我能得到正常的RTSP流的工作,但我无法找到如何实际设置隧道模式为流的任何资料或文件。 它在源代码中设置control_transport到RTSP_MODE_TUNNEL支持。 我的问题很简单,我怎么做到这一点下面的代码?

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

我试过如下:

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)。 我想这藏汉

 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是存在的。

工作液

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

Answer 1:

你试试这个

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


文章来源: RTSP tunneled HTTP, FFMPEG