From e79520c5911c7eb79c4919451b14b78b03606fe5 Mon Sep 17 00:00:00 2001
From: cbwu <504-wuchengbo@htsdfp.com>
Date: Thu, 10 Oct 2024 18:20:12 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9A=90=E8=97=8F=E5=90=8A=E8=88=B1?=
=?UTF-8?q?=E6=8B=89=E6=B5=81tcp=E5=92=8Cudp=E5=88=87=E6=8D=A2=E6=96=B9?=
=?UTF-8?q?=E5=BC=8F(tcp=E6=96=B9=E5=BC=8F=E4=BC=9A=E5=AF=BC=E8=87=B4?=
=?UTF-8?q?=E5=90=8A=E8=88=B1=E6=8B=89=E6=B5=81=E4=B8=AD=E6=96=AD)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
PayloadAPP.pro | 2 +-
Src/GDDC/gddcSet.cpp | 3 +++
Src/GDDC/gddcSet.ui | 25 +++++++++++++++--------
Src/Video/cffmpeg_decode.cpp | 36 +++++++++++++++++++++++++++-------
Src/Video/ffmpegpushstream.cpp | 1 +
global.cpp | 2 +-
6 files changed, 52 insertions(+), 17 deletions(-)
diff --git a/PayloadAPP.pro b/PayloadAPP.pro
index f6f245c..505445b 100644
--- a/PayloadAPP.pro
+++ b/PayloadAPP.pro
@@ -14,7 +14,7 @@ QMAKE_PROJECT_DEPTH = 0
# QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"
#程序版本
-VERSION = 1.0.0.1009
+VERSION = 1.0.0.1010
#程序版本
QMAKE_TARGET_COMPANY = "HTSDFP"
diff --git a/Src/GDDC/gddcSet.cpp b/Src/GDDC/gddcSet.cpp
index c274131..79a4e04 100644
--- a/Src/GDDC/gddcSet.cpp
+++ b/Src/GDDC/gddcSet.cpp
@@ -9,6 +9,9 @@ GDDCSet::GDDCSet(QWidget *parent) : QWidget(parent), ui(new Ui::GDDCSet) {
initWindow();
initParam();
initUDPSocket();
+
+ ui->label_3->setVisible(false);
+ ui->comboBox_streamType->setVisible(false);
}
GDDCSet::~GDDCSet() { delete ui; }
diff --git a/Src/GDDC/gddcSet.ui b/Src/GDDC/gddcSet.ui
index 580238b..90c0ca6 100644
--- a/Src/GDDC/gddcSet.ui
+++ b/Src/GDDC/gddcSet.ui
@@ -32,10 +32,13 @@
Qt::AlignCenter
+
+ true
+
510
- 60
+ 30
51
21
@@ -45,14 +48,20 @@
+
+ true
+
560
- 60
+ 30
61
23
+
+ true
+
@@ -85,7 +94,7 @@
80
60
- 301
+ 421
23
@@ -170,7 +179,7 @@
80
100
- 411
+ 421
23
@@ -207,9 +216,9 @@
- 570
+ 560
100
- 51
+ 61
23
@@ -226,7 +235,7 @@
- 390
+ 510
60
51
21
@@ -239,7 +248,7 @@
- 440
+ 560
60
61
23
diff --git a/Src/Video/cffmpeg_decode.cpp b/Src/Video/cffmpeg_decode.cpp
index ebd601a..a52cd72 100644
--- a/Src/Video/cffmpeg_decode.cpp
+++ b/Src/Video/cffmpeg_decode.cpp
@@ -69,21 +69,31 @@ bool Cffmpeg_decode::open_input_file() {
//========================解码============================
AVDictionary *avdic = NULL;
// 如果设置失败,则设置UDP传输
- if (m_rtsp_transport == "udp")
- av_dict_set(&avdic, "rtsp_transport", "udp", 0);
- else
- av_dict_set(&avdic, "rtsp_transport", "tcp", 0);
+ // if (m_rtsp_transport == "udp")
+ // av_dict_set(&avdic, "rtsp_transport", "udp", 0);
+ // else
+ // av_dict_set(&avdic, "rtsp_transport", "tcp",
+ // 0);//注:设置tcp会导致吊舱拉流中断
+ // av_dict_set(&avdic, "rtsp_transport", "udp", 0);
// 设置缓存大小,1080p可将值调大
- av_dict_set(&avdic, "buffer_size", "4096000", 0);
+ av_dict_set(&avdic, "buffer_size", "2048000", 0);
// 设置超时断开连接时间,单位微秒//listen_timeout
// av_dict_set(&avdic, "listen_timeout", "200000", 0);
- av_dict_set(&avdic, "stimeout", "3000000", 0); // 设置超时3秒
+ av_dict_set(&avdic, "stimeout", "5000000", 0); // 设置超时5秒
av_dict_set(&avdic, "max_delay", "300000", 0); // 设置最大时延300ms
av_dict_set(&avdic, "tune", "zerolatency", 0); // 实时编码
av_dict_set(&avdic, "preset", "faster", 0); // ultrafast
av_dict_set(&avdic, "threads", "auto", 0); // 自动开启线程数
+ // av_dict_set(&avdic, "rtsp_flags", "prefer_tcp", 0); // 保持TCP连接
+ // av_dict_set(&avdic, "timeout", "500000", 0); // 超时时间设置为500ms
+ // av_dict_set(&avdic, "probesize", "50000000", 0); // 增加探针大小,1MB
+ // av_dict_set(&avdic, "analyzeduration", "5000000", 0); //
+ // 增加分析持续时间,5秒
+
+ // 打开输入流之前,设置非阻塞模式
inputFormatCtx->flags |= AVFMT_FLAG_NONBLOCK;
+ // inputFormatCtx->probesize = 50000000;
// 打开输入流
if (avformat_open_input(&inputFormatCtx, _url.toUtf8().data(), NULL, &avdic) <
@@ -186,8 +196,17 @@ void Cffmpeg_decode::run() {
// 推流使用
firstDts = AV_NOPTS_VALUE; // 初始化第一帧的DTS
startTime = av_gettime();
+ int ret11 = 0;
// 读取数据包
- while (av_read_frame(inputFormatCtx, inputPacket) >= 0) {
+ while ((ret11 = av_read_frame(inputFormatCtx, inputPacket)) >= 0) {
+ // ret = av_read_frame(inputFormatCtx, inputPacket);
+ // if (ret < 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
+ // qDebug() << "ret:" << QString::number(ret);
+ // av_packet_unref(inputPacket);
+ // frm_cnt++;
+ // continue;
+ // }
+
if (IsstopPlay) {
qDebug() << "video play stop";
break;
@@ -295,6 +314,9 @@ void Cffmpeg_decode::run() {
if (m_saveVideoFlag) {
saveDone();
}
+ if (ret11 == AVERROR_EOF && errno == 0) {
+ qDebug() << "ret:";
+ }
// QCoreApplication::processEvents();
qDebug() << "All video play done";
}
diff --git a/Src/Video/ffmpegpushstream.cpp b/Src/Video/ffmpegpushstream.cpp
index a8e7031..7ce0bcf 100644
--- a/Src/Video/ffmpegpushstream.cpp
+++ b/Src/Video/ffmpegpushstream.cpp
@@ -26,6 +26,7 @@ int FFmpegPushStream::openNetworkStream(AVFormatContext *inputFormatCtx) {
}
// 复制流信息
for (unsigned int i = 0; i < inputFormatCtx->nb_streams; ++i) {
+ // AVStream *stream = inputFormatCtx->streams[i];
if (inputFormatCtx->streams[i]->codecpar->codec_type ==
AVMEDIA_TYPE_VIDEO) {
AVStream *inputStream = inputFormatCtx->streams[i];
diff --git a/global.cpp b/global.cpp
index 8c363cc..97b3692 100644
--- a/global.cpp
+++ b/global.cpp
@@ -2,7 +2,7 @@
global::global() {}
-QString g_SoftwareVersion = "版本号:V1.0.0.1009";
+QString g_SoftwareVersion = "版本号:V1.0.0.1010";
QColor g_themeColor(51, 51, 51);
QString g_PushBtnStyle = /**正常情况下样式**/