我正在尝试从Axis摄像机上流,它使用HTTP上的RTSP。我可以让正常的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);发布于 2013-01-22 16:42:15
你试过这个吗?
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
复制相似问题