Bootstrap

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

    AVDictionary* options = NULL;
    #使用 TCP 方式
	av_dict_set(&options, "rtsp_transport", "tcp", 0);
	#设置 接收包间隔最大延迟,微秒
	av_dict_set(&options, "max_delay", "200000", 0);
	# rtmp、rtsp延迟控制到最小
	av_dict_set(&options, "fflags", "nobuffer", 0);
	# 在进行网络操作时允许的最大等待时间。5秒
	av_dict_set(&options, "timeout", "5000000", 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;
;