diff --git a/Src/GDDC/gddcSet.cpp b/Src/GDDC/gddcSet.cpp index 2f2fe8e..f53c10a 100644 --- a/Src/GDDC/gddcSet.cpp +++ b/Src/GDDC/gddcSet.cpp @@ -42,6 +42,8 @@ void GDDCSet::initParam() { "rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid"); ui->comboBox_playURL1->setEditable(true); + ui->lineEdit_pushURL->setText( + QStringLiteral("rtmp://182.92.130.23/app/stream99")); /*"rtsp://192.168.1.160:554/live/track0"*/ /*"rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid"*/ diff --git a/Src/ModelCamera/modelcameradlg.cpp b/Src/ModelCamera/modelcameradlg.cpp index f2a08d3..a2bb3b0 100644 --- a/Src/ModelCamera/modelcameradlg.cpp +++ b/Src/ModelCamera/modelcameradlg.cpp @@ -5,10 +5,9 @@ ModelCameraDlg::ModelCameraDlg(QWidget *parent) : QDialog(parent), ui(new Ui::ModelCameraDlg) { ui->setupUi(this); ui->videoIPLineEdit->setText(QStringLiteral( - "rtmp://liteavapp.qcloud.com/live/" - "liteavdemoplayerstreamid")); // rtsp://192.168.5.70:8554/LIVE + "rtsp://192.168.5.70:8554/LIVE")); // rtsp://192.168.5.70:8554/LIVE ui->pushStreamIPEdit->setText( - QStringLiteral("rtmp://182.92.130.23/app/stream999")); + QStringLiteral("rtmp://182.92.130.23/app/stream99")); ui->cameraVideoWidget->setVedioSaveFileDirPath("./3DCameraVideo"); InitialComboBox(); cameraCMDThread = new QThread(); @@ -172,6 +171,14 @@ void ModelCameraDlg::on_pushButton_5_clicked() { ffmpegvideoDlg *videoDlg = ui->cameraVideoWidget; if (str == "播放视频") { QString streamIP = ui->videoIPLineEdit->text(); + if (streamIP.isEmpty()) { + QMessageBox::warning(NULL, "提示", "拉流地址为空!", QMessageBox::Ok); + return; + } + if (!(streamIP.left(4) == "rtmp" || streamIP.left(4) == "rtsp")) { + QMessageBox::warning(NULL, "提示", "拉流地址有误!", QMessageBox::Ok); + return; + } videoDlg->setStreamIP(streamIP); videoDlg->setPlayVideo(true); ui->pushButton_5->setText("暂停播放"); @@ -188,6 +195,19 @@ void ModelCameraDlg::on_pushStreamBtn_clicked() { if (str == "开始推流") { QString streamIP = ui->videoIPLineEdit->text(); QString pushIP = ui->pushStreamIPEdit->text(); + if (streamIP.isEmpty() || pushIP.isEmpty()) { + QMessageBox::warning(NULL, "提示", "拉流或推流地址为空!", + QMessageBox::Ok); + return; + } + if (!(streamIP.left(4) == "rtmp" || streamIP.left(4) == "rtsp")) { + QMessageBox::warning(NULL, "提示", "拉流地址有误!", QMessageBox::Ok); + return; + } + if (!(pushIP.left(4) == "rtmp" || pushIP.left(4) == "rtsp")) { + QMessageBox::warning(NULL, "提示", "推流地址有误!", QMessageBox::Ok); + return; + } videoDlg->setStreamIP(streamIP); videoDlg->setPushStreamIP(pushIP); videoDlg->setPushStream(true); diff --git a/Src/ModelCamera/modelcameradlg.h b/Src/ModelCamera/modelcameradlg.h index 5e42614..61e8512 100644 --- a/Src/ModelCamera/modelcameradlg.h +++ b/Src/ModelCamera/modelcameradlg.h @@ -5,6 +5,7 @@ #include "encodemodelcamera.h" #include #include +#include #include #include namespace Ui { diff --git a/Src/Video/cffmpeg_decode.cpp b/Src/Video/cffmpeg_decode.cpp index 049ef6b..ebd601a 100644 --- a/Src/Video/cffmpeg_decode.cpp +++ b/Src/Video/cffmpeg_decode.cpp @@ -80,8 +80,8 @@ bool Cffmpeg_decode::open_input_file() { av_dict_set(&avdic, "stimeout", "3000000", 0); // 设置超时3秒 av_dict_set(&avdic, "max_delay", "300000", 0); // 设置最大时延300ms av_dict_set(&avdic, "tune", "zerolatency", 0); // 实时编码 - av_dict_set(&avdic, "preset", "ultrafast", 0); - av_dict_set(&avdic, "threads", "auto", 0); // 自动开启线程数 + av_dict_set(&avdic, "preset", "faster", 0); // ultrafast + av_dict_set(&avdic, "threads", "auto", 0); // 自动开启线程数 inputFormatCtx->flags |= AVFMT_FLAG_NONBLOCK; @@ -267,8 +267,8 @@ void Cffmpeg_decode::run() { double elapsed_system_time = av_gettime() - first_frame_system_time; // 计算需要等待的时间(us) double wait_time = elapsed_pts_time - elapsed_system_time; - qDebug() << "pull stream sleep time:" - << QString::number(wait_time / 1000.0); + // qDebug() << "pull stream sleep time:" + // << QString::number(wait_time / 1000.0); if (wait_time > 0) { av_usleep(wait_time); // 延时以同步 PTS } diff --git a/Src/Video/cffmpeg_decode.h b/Src/Video/cffmpeg_decode.h index 079327a..c3c3609 100644 --- a/Src/Video/cffmpeg_decode.h +++ b/Src/Video/cffmpeg_decode.h @@ -94,6 +94,8 @@ private: bool m_writeHeader = false; // 是否写入文件头 QString m_rtsp_transport; // 拉流打开方式,UDP或TCP + bool m_bSetRtspTransport = false; + private: bool m_saveVideoFlag = false; /** diff --git a/Src/Video/ffmpegvideodlg.cpp b/Src/Video/ffmpegvideodlg.cpp index ef70037..dfcee90 100644 --- a/Src/Video/ffmpegvideodlg.cpp +++ b/Src/Video/ffmpegvideodlg.cpp @@ -161,7 +161,7 @@ void ffmpegvideoDlg::setPushStream(bool bPush) { Qt::UniqueConnection); // ffmpeg->bPushStreamFlag = true; } - qDebug() << "video threadID:" << QThread::currentThreadId(); + // qDebug() << "video threadID:" << QThread::currentThreadId(); ffmpeg->setPushStream(true); } else { // 停止推流 ffmpeg->setPushStream(false);