|
@@ -133,17 +133,18 @@ bool RTSPClient::initialize_input() {
|
|
|
input_format_ctx_->interrupt_callback.callback = interrupt_callback;
|
|
|
input_format_ctx_->interrupt_callback.opaque = this;
|
|
|
|
|
|
- // 设置RTSP选项(优化快速失败检测)
|
|
|
+ // 设置RTSP选项(Docker环境优化)
|
|
|
AVDictionary* options = nullptr;
|
|
|
av_dict_set(&options, "rtsp_transport", "tcp", 0);
|
|
|
- av_dict_set(&options, "timeout", "3000000", 0); // 3秒连接超时
|
|
|
- av_dict_set(&options, "stimeout", "2000000", 0); // 2秒读取超时
|
|
|
- av_dict_set(&options, "max_delay", "500000", 0); // 最大延迟500ms
|
|
|
+ av_dict_set(&options, "timeout", "10000000", 0); // 10秒连接超时
|
|
|
+ av_dict_set(&options, "stimeout", "5000000", 0); // 5秒读取超时
|
|
|
+ av_dict_set(&options, "max_delay", "1000000", 0); // 最大延迟1秒
|
|
|
av_dict_set(&options, "reorder_queue_size", "10", 0); // 减小缓冲队列
|
|
|
+ av_dict_set(&options, "buffer_size", "65536", 0); // 设置缓冲区大小
|
|
|
|
|
|
// 设置超时时间(用于中断回调)
|
|
|
start_time_us_ = av_gettime();
|
|
|
- timeout_us_ = 3000000LL; // 3秒超时
|
|
|
+ timeout_us_ = connection_timeout_ * 1000000LL; // 使用配置的连接超时
|
|
|
|
|
|
std::cout << "尝试连接RTSP流: " << config_.rtsp_url << std::endl;
|
|
|
|
|
@@ -167,9 +168,9 @@ bool RTSPClient::initialize_input() {
|
|
|
|
|
|
std::cout << "成功连接RTSP流,获取流信息..." << std::endl;
|
|
|
|
|
|
- // 获取流信息(使用较短超时)
|
|
|
+ // 获取流信息(使用配置的超时)
|
|
|
start_time_us_ = av_gettime();
|
|
|
- timeout_us_ = 2000000LL; // 2秒超时
|
|
|
+ timeout_us_ = read_timeout_ * 1000000LL; // 使用配置的读取超时
|
|
|
|
|
|
ret = avformat_find_stream_info(input_format_ctx_, nullptr);
|
|
|
if (ret < 0) {
|