fix: 隐藏吊舱拉流tcp和udp切换方式(tcp方式会导致吊舱拉流中断)

video_old
cbwu 5 months ago
parent 33cf0cb360
commit e79520c591

@ -14,7 +14,7 @@ QMAKE_PROJECT_DEPTH = 0
# QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\" # QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"
#程序版本 #程序版本
VERSION = 1.0.0.1009 VERSION = 1.0.0.1010
#程序版本 #程序版本
QMAKE_TARGET_COMPANY = "HTSDFP" QMAKE_TARGET_COMPANY = "HTSDFP"

@ -9,6 +9,9 @@ GDDCSet::GDDCSet(QWidget *parent) : QWidget(parent), ui(new Ui::GDDCSet) {
initWindow(); initWindow();
initParam(); initParam();
initUDPSocket(); initUDPSocket();
ui->label_3->setVisible(false);
ui->comboBox_streamType->setVisible(false);
} }
GDDCSet::~GDDCSet() { delete ui; } GDDCSet::~GDDCSet() { delete ui; }

@ -32,10 +32,13 @@
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>510</x> <x>510</x>
<y>60</y> <y>30</y>
<width>51</width> <width>51</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -45,14 +48,20 @@
</property> </property>
</widget> </widget>
<widget class="QComboBox" name="comboBox_streamType"> <widget class="QComboBox" name="comboBox_streamType">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>560</x> <x>560</x>
<y>60</y> <y>30</y>
<width>61</width> <width>61</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
<property name="frame">
<bool>true</bool>
</property>
</widget> </widget>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="geometry"> <property name="geometry">
@ -85,7 +94,7 @@
<rect> <rect>
<x>80</x> <x>80</x>
<y>60</y> <y>60</y>
<width>301</width> <width>421</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@ -170,7 +179,7 @@
<rect> <rect>
<x>80</x> <x>80</x>
<y>100</y> <y>100</y>
<width>411</width> <width>421</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@ -207,9 +216,9 @@
<widget class="QSpinBox" name="uavIDSpinBox"> <widget class="QSpinBox" name="uavIDSpinBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>570</x> <x>560</x>
<y>100</y> <y>100</y>
<width>51</width> <width>61</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@ -226,7 +235,7 @@
<widget class="QLabel" name="label_16"> <widget class="QLabel" name="label_16">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>390</x> <x>510</x>
<y>60</y> <y>60</y>
<width>51</width> <width>51</width>
<height>21</height> <height>21</height>
@ -239,7 +248,7 @@
<widget class="QComboBox" name="comboBox_streamSource"> <widget class="QComboBox" name="comboBox_streamSource">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>440</x> <x>560</x>
<y>60</y> <y>60</y>
<width>61</width> <width>61</width>
<height>23</height> <height>23</height>

@ -69,21 +69,31 @@ bool Cffmpeg_decode::open_input_file() {
//========================解码============================ //========================解码============================
AVDictionary *avdic = NULL; AVDictionary *avdic = NULL;
// 如果设置失败则设置UDP传输 // 如果设置失败则设置UDP传输
if (m_rtsp_transport == "udp") // if (m_rtsp_transport == "udp")
av_dict_set(&avdic, "rtsp_transport", "udp", 0); // av_dict_set(&avdic, "rtsp_transport", "udp", 0);
else // else
av_dict_set(&avdic, "rtsp_transport", "tcp", 0); // av_dict_set(&avdic, "rtsp_transport", "tcp",
// 0);//注设置tcp会导致吊舱拉流中断
// av_dict_set(&avdic, "rtsp_transport", "udp", 0);
// 设置缓存大小1080p可将值调大 // 设置缓存大小1080p可将值调大
av_dict_set(&avdic, "buffer_size", "4096000", 0); av_dict_set(&avdic, "buffer_size", "2048000", 0);
// 设置超时断开连接时间,单位微秒//listen_timeout // 设置超时断开连接时间,单位微秒//listen_timeout
// av_dict_set(&avdic, "listen_timeout", "200000", 0); // 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, "max_delay", "300000", 0); // 设置最大时延300ms
av_dict_set(&avdic, "tune", "zerolatency", 0); // 实时编码 av_dict_set(&avdic, "tune", "zerolatency", 0); // 实时编码
av_dict_set(&avdic, "preset", "faster", 0); // ultrafast av_dict_set(&avdic, "preset", "faster", 0); // ultrafast
av_dict_set(&avdic, "threads", "auto", 0); // 自动开启线程数 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->flags |= AVFMT_FLAG_NONBLOCK;
// inputFormatCtx->probesize = 50000000;
// 打开输入流 // 打开输入流
if (avformat_open_input(&inputFormatCtx, _url.toUtf8().data(), NULL, &avdic) < if (avformat_open_input(&inputFormatCtx, _url.toUtf8().data(), NULL, &avdic) <
@ -186,8 +196,17 @@ void Cffmpeg_decode::run() {
// 推流使用 // 推流使用
firstDts = AV_NOPTS_VALUE; // 初始化第一帧的DTS firstDts = AV_NOPTS_VALUE; // 初始化第一帧的DTS
startTime = av_gettime(); 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) { if (IsstopPlay) {
qDebug() << "video play stop"; qDebug() << "video play stop";
break; break;
@ -295,6 +314,9 @@ void Cffmpeg_decode::run() {
if (m_saveVideoFlag) { if (m_saveVideoFlag) {
saveDone(); saveDone();
} }
if (ret11 == AVERROR_EOF && errno == 0) {
qDebug() << "ret:";
}
// QCoreApplication::processEvents(); // QCoreApplication::processEvents();
qDebug() << "All video play done"; qDebug() << "All video play done";
} }

@ -26,6 +26,7 @@ int FFmpegPushStream::openNetworkStream(AVFormatContext *inputFormatCtx) {
} }
// 复制流信息 // 复制流信息
for (unsigned int i = 0; i < inputFormatCtx->nb_streams; ++i) { for (unsigned int i = 0; i < inputFormatCtx->nb_streams; ++i) {
// AVStream *stream = inputFormatCtx->streams[i];
if (inputFormatCtx->streams[i]->codecpar->codec_type == if (inputFormatCtx->streams[i]->codecpar->codec_type ==
AVMEDIA_TYPE_VIDEO) { AVMEDIA_TYPE_VIDEO) {
AVStream *inputStream = inputFormatCtx->streams[i]; AVStream *inputStream = inputFormatCtx->streams[i];

@ -2,7 +2,7 @@
global::global() {} global::global() {}
QString g_SoftwareVersion = "版本号V1.0.0.1009"; QString g_SoftwareVersion = "版本号V1.0.0.1010";
QColor g_themeColor(51, 51, 51); QColor g_themeColor(51, 51, 51);
QString g_PushBtnStyle = /**正常情况下样式**/ QString g_PushBtnStyle = /**正常情况下样式**/

Loading…
Cancel
Save