ffmpeg打开rtsp流应该设置的几个参数

    AVDictionary* options = NULL;
    #使用 TCP 方式
	av_dict_set(&options, "rtsp_transport", "tcp", 0);
	#设置 接收包间隔最大延迟,微秒
	av_dict_set(&options, "max_delay", "500", 0);
	# rtmp、rtsp延迟控制到最小
	av_dict_set(&options, "fflags", "nobuffer", 0);
	#设置 阻塞超时,否则可能在流断开时连接发生阻塞,微秒
	av_dict_set(&options, "stimeout", "3000000", 0);
	#设置 find_stream_info 最大时长,微秒
    av_dict_set(&options, "analyzeduration", "1000000", 0);

	avformat_open_input(&in_format_context, rtsp_url.c_str(), NULL, &options);
	
	av_dict_free(&opts);

防止av_read_frame()阻塞的回调

pFmtCtx->interrupt_callback.callback = stream_noblock_cb;
pFmtCtx->interrupt_callback.opaque = &data;

你可能感兴趣的:(C++,ffmpeg,实时音视频)