|
@@ -34,6 +34,12 @@ void SettingsPage::_InitConnect()
|
|
|
_fileDirEdit->setText(selectedDir);
|
|
_fileDirEdit->setText(selectedDir);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ if (_resetBestBtn) {
|
|
|
|
|
+ connect(_resetBestBtn, &QPushButton::released, [this] {
|
|
|
|
|
+ _ApplyBestDefaults();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void SettingsPage::_WriteSettings()
|
|
void SettingsPage::_WriteSettings()
|
|
@@ -41,13 +47,16 @@ void SettingsPage::_WriteSettings()
|
|
|
_param->videoParam.bitRate = _videoBitRateBox->value() * 1000;
|
|
_param->videoParam.bitRate = _videoBitRateBox->value() * 1000;
|
|
|
_param->videoParam.fps = _videoFpsBox->value();
|
|
_param->videoParam.fps = _videoFpsBox->value();
|
|
|
_param->videoParam.name = _videoEncoderBox->currentText().toStdString();
|
|
_param->videoParam.name = _videoEncoderBox->currentText().toStdString();
|
|
|
|
|
+ _param->videoParam.width = _videoWidthBox ? _videoWidthBox->value() : _param->videoParam.width;
|
|
|
|
|
+ _param->videoParam.height = _videoHeightBox ? _videoHeightBox->value() : _param->videoParam.height;
|
|
|
|
|
+
|
|
|
_param->audioParam.bitRate = _audioBitRateBox->value() * 1000;
|
|
_param->audioParam.bitRate = _audioBitRateBox->value() * 1000;
|
|
|
if (_audioEncoderBox) {
|
|
if (_audioEncoderBox) {
|
|
|
_param->audioParam.name = _audioEncoderBox->currentText().toStdString();
|
|
_param->audioParam.name = _audioEncoderBox->currentText().toStdString();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
_param->outputDir = _fileDirEdit->text().toStdString();
|
|
_param->outputDir = _fileDirEdit->text().toStdString();
|
|
|
- // _param->liveUrl = _liveUrlEdit->text().toStdString();
|
|
|
|
|
- // _param->liveName = _liveNameEdit->text().toStdString();
|
|
|
|
|
|
|
+ // 直播参数为项目内置设置,不从UI写回
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void SettingsPage::_InitUi()
|
|
void SettingsPage::_InitUi()
|
|
@@ -57,11 +66,15 @@ void SettingsPage::_InitUi()
|
|
|
layout->addWidget(_InitVideoUi());
|
|
layout->addWidget(_InitVideoUi());
|
|
|
layout->addWidget(_InitAudioUi());
|
|
layout->addWidget(_InitAudioUi());
|
|
|
layout->addWidget(_InitOutputUi());
|
|
layout->addWidget(_InitOutputUi());
|
|
|
|
|
+ // 不显示“直播”设置(项目内置配置,不需要在UI中展示)
|
|
|
auto hLayout = new QHBoxLayout;
|
|
auto hLayout = new QHBoxLayout;
|
|
|
|
|
+ _resetBestBtn = new QPushButton("最佳默认");
|
|
|
_applyBtn = new QPushButton("应用");
|
|
_applyBtn = new QPushButton("应用");
|
|
|
_cancelBtn = new QPushButton("取消");
|
|
_cancelBtn = new QPushButton("取消");
|
|
|
_yesBtn = new QPushButton("确定");
|
|
_yesBtn = new QPushButton("确定");
|
|
|
hLayout->setAlignment(Qt::AlignRight);
|
|
hLayout->setAlignment(Qt::AlignRight);
|
|
|
|
|
+ hLayout->addWidget(_resetBestBtn);
|
|
|
|
|
+ hLayout->addStretch();
|
|
|
hLayout->addWidget(_applyBtn);
|
|
hLayout->addWidget(_applyBtn);
|
|
|
hLayout->addWidget(_cancelBtn);
|
|
hLayout->addWidget(_cancelBtn);
|
|
|
hLayout->addWidget(_yesBtn);
|
|
hLayout->addWidget(_yesBtn);
|
|
@@ -78,9 +91,20 @@ QGroupBox* SettingsPage::_InitVideoUi()
|
|
|
_videoBitRateBox->setMaximum(INT_MAX);
|
|
_videoBitRateBox->setMaximum(INT_MAX);
|
|
|
_videoBitRateBox->setValue(_param->videoParam.bitRate / 1000);
|
|
_videoBitRateBox->setValue(_param->videoParam.bitRate / 1000);
|
|
|
_videoFpsBox = new QSpinBox;
|
|
_videoFpsBox = new QSpinBox;
|
|
|
- _videoFpsBox->setMinimum(0);
|
|
|
|
|
- _videoFpsBox->setMaximum(60);
|
|
|
|
|
|
|
+ _videoFpsBox->setMinimum(1);
|
|
|
|
|
+ _videoFpsBox->setMaximum(120);
|
|
|
_videoFpsBox->setValue(_param->videoParam.fps);
|
|
_videoFpsBox->setValue(_param->videoParam.fps);
|
|
|
|
|
+
|
|
|
|
|
+ // 分辨率设置
|
|
|
|
|
+ _videoWidthBox = new QSpinBox;
|
|
|
|
|
+ _videoWidthBox->setMinimum(160);
|
|
|
|
|
+ _videoWidthBox->setMaximum(7680);
|
|
|
|
|
+ _videoWidthBox->setValue(_param->videoParam.width > 0 ? _param->videoParam.width : 1920);
|
|
|
|
|
+ _videoHeightBox = new QSpinBox;
|
|
|
|
|
+ _videoHeightBox->setMinimum(120);
|
|
|
|
|
+ _videoHeightBox->setMaximum(4320);
|
|
|
|
|
+ _videoHeightBox->setValue(_param->videoParam.height > 0 ? _param->videoParam.height : 1080);
|
|
|
|
|
+
|
|
|
_videoEncoderBox = new QComboBox;
|
|
_videoEncoderBox = new QComboBox;
|
|
|
auto&& encoders = Encoder<MediaType::VIDEO>::GetUsableEncoders();
|
|
auto&& encoders = Encoder<MediaType::VIDEO>::GetUsableEncoders();
|
|
|
for (auto&& encoder : encoders) {
|
|
for (auto&& encoder : encoders) {
|
|
@@ -99,6 +123,10 @@ QGroupBox* SettingsPage::_InitVideoUi()
|
|
|
_CreateDescription("比特率(kB):", "越高的比特率越清晰, 但越占用硬件资源", _videoBitRateBox));
|
|
_CreateDescription("比特率(kB):", "越高的比特率越清晰, 但越占用硬件资源", _videoBitRateBox));
|
|
|
layout->addLayout(
|
|
layout->addLayout(
|
|
|
_CreateDescription("帧率:", "越高的帧率越流畅, 但越占用硬件资源", _videoFpsBox));
|
|
_CreateDescription("帧率:", "越高的帧率越流畅, 但越占用硬件资源", _videoFpsBox));
|
|
|
|
|
+ layout->addLayout(
|
|
|
|
|
+ _CreateDescription("分辨率-宽:", "输出视频宽度,建议与屏幕或窗口比例一致", _videoWidthBox));
|
|
|
|
|
+ layout->addLayout(
|
|
|
|
|
+ _CreateDescription("分辨率-高:", "输出视频高度,建议与屏幕或窗口比例一致", _videoHeightBox));
|
|
|
layout->addLayout(_CreateDescription(
|
|
layout->addLayout(_CreateDescription(
|
|
|
"编码器:",
|
|
"编码器:",
|
|
|
"libx264 为软件编码, CPU占用高但兼容性强, 其他为硬件编码, 效果与软件编码相反",
|
|
"libx264 为软件编码, CPU占用高但兼容性强, 其他为硬件编码, 效果与软件编码相反",
|
|
@@ -154,6 +182,37 @@ QGroupBox* SettingsPage::_InitOutputUi()
|
|
|
return groupBox;
|
|
return groupBox;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+QGroupBox* SettingsPage::_InitLiveUi()
|
|
|
|
|
+{
|
|
|
|
|
+ auto groupBox = new QGroupBox("直播");
|
|
|
|
|
+ auto layout = new QVBoxLayout;
|
|
|
|
|
+ _liveUrlEdit = new QLineEdit(QString::fromStdString(_param->liveUrl));
|
|
|
|
|
+ _liveNameEdit = new QLineEdit(QString::fromStdString(_param->liveName));
|
|
|
|
|
+ layout->addLayout(_CreateDescription("推流地址:", "例如: rtmp://<server>:1935/stream/V1 或 rtsp://...", _liveUrlEdit));
|
|
|
|
|
+ layout->addLayout(_CreateDescription("流名称:", "推流路径中的名称或Key", _liveNameEdit));
|
|
|
|
|
+ groupBox->setLayout(layout);
|
|
|
|
|
+ return groupBox;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void SettingsPage::_ApplyBestDefaults()
|
|
|
|
|
+{
|
|
|
|
|
+ // 优先选择可用编码器列表的第一项(通常为硬件加速编码器)
|
|
|
|
|
+ if (_videoEncoderBox && _videoEncoderBox->count() > 0) {
|
|
|
|
|
+ _videoEncoderBox->setCurrentIndex(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (_audioEncoderBox && _audioEncoderBox->count() > 0) {
|
|
|
|
|
+ _audioEncoderBox->setCurrentIndex(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置为通用的高质量方案:1080p@30fps, 8 Mbps;音频 160 kbps
|
|
|
|
|
+ if (_videoWidthBox) _videoWidthBox->setValue(1920);
|
|
|
|
|
+ if (_videoHeightBox) _videoHeightBox->setValue(1080);
|
|
|
|
|
+ if (_videoFpsBox) _videoFpsBox->setValue(30);
|
|
|
|
|
+ if (_videoBitRateBox) _videoBitRateBox->setValue(8000);
|
|
|
|
|
+
|
|
|
|
|
+ if (_audioBitRateBox) _audioBitRateBox->setValue(160);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
QHBoxLayout* SettingsPage::_CreateDescription(std::string_view text,
|
|
QHBoxLayout* SettingsPage::_CreateDescription(std::string_view text,
|
|
|
std::string_view textEx,
|
|
std::string_view textEx,
|
|
|
QWidget* widget)
|
|
QWidget* widget)
|