completed audio recording implementation
This commit is contained in:
@@ -211,6 +211,7 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
|
||||
video_tab_->pixel_format_field()->SetPixelFormat(static_cast<VideoParams::Format>(Config::Current()[QStringLiteral("OnlinePixelFormat")].toInt()));
|
||||
video_tab_->interlaced_combobox()->SetInterlaceMode(vp.interlacing());
|
||||
audio_tab_->sample_rate_combobox()->SetSampleRate(ap.sample_rate());
|
||||
audio_tab_->sample_format_combobox()->SetSampleFormat(ap.format());
|
||||
audio_tab_->channel_layout_combobox()->SetChannelLayout(ap.channel_layout());
|
||||
|
||||
video_aspect_ratio_ = static_cast<double>(vp.width()) / static_cast<double>(vp.height());
|
||||
@@ -515,7 +516,7 @@ ExportParams ExportDialog::GenerateParams() const
|
||||
|
||||
AudioParams audio_render_params(audio_tab_->sample_rate_combobox()->currentData().toInt(),
|
||||
audio_tab_->channel_layout_combobox()->GetChannelLayout(),
|
||||
AudioParams::kInternalFormat);
|
||||
audio_tab_->sample_format_combobox()->GetSampleFormat());
|
||||
|
||||
ExportParams params;
|
||||
params.set_encoder(Encoder::GetTypeFromFormat(format_combobox_->GetFormat()));
|
||||
@@ -553,7 +554,7 @@ ExportParams ExportDialog::GenerateParams() const
|
||||
}
|
||||
|
||||
if (audio_enabled_->isChecked()) {
|
||||
ExportCodec::Codec audio_codec = static_cast<ExportCodec::Codec>(audio_tab_->codec_combobox()->currentData().toInt());
|
||||
ExportCodec::Codec audio_codec = audio_tab_->GetCodec();
|
||||
params.EnableAudio(audio_render_params, audio_codec);
|
||||
|
||||
params.set_audio_bit_rate(audio_tab_->bit_rate_slider()->GetValue() * 1000);
|
||||
|
||||
@@ -59,7 +59,9 @@ ExportAudioTab::ExportAudioTab(QWidget* parent) :
|
||||
row++;
|
||||
|
||||
layout->addWidget(new QLabel(tr("Format:")), row, 0);
|
||||
layout->addWidget(new QComboBox(), row, 1);
|
||||
|
||||
sample_format_combobox_ = new SampleFormatComboBox();
|
||||
layout->addWidget(sample_format_combobox_, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
@@ -68,7 +70,7 @@ ExportAudioTab::ExportAudioTab(QWidget* parent) :
|
||||
bit_rate_slider_ = new IntegerSlider();
|
||||
bit_rate_slider_->SetMinimum(32);
|
||||
bit_rate_slider_->SetMaximum(320);
|
||||
bit_rate_slider_->SetValue(256);
|
||||
bit_rate_slider_->SetValue(320);
|
||||
bit_rate_slider_->SetFormat(tr("%1 kbps"));
|
||||
layout->addWidget(bit_rate_slider_, row, 1);
|
||||
|
||||
@@ -79,9 +81,9 @@ int ExportAudioTab::SetFormat(ExportFormat::Format format)
|
||||
{
|
||||
QList<ExportCodec::Codec> acodecs = ExportFormat::GetAudioCodecs(format);
|
||||
setEnabled(!acodecs.isEmpty());
|
||||
codec_combobox()->clear();
|
||||
codec_combobox_->clear();
|
||||
foreach (ExportCodec::Codec acodec, acodecs) {
|
||||
codec_combobox()->addItem(ExportCodec::GetCodecName(acodec), acodec);
|
||||
codec_combobox_->addItem(ExportCodec::GetCodecName(acodec), acodec);
|
||||
}
|
||||
return acodecs.size();
|
||||
}
|
||||
|
||||
@@ -37,9 +37,19 @@ class ExportAudioTab : public QWidget
|
||||
public:
|
||||
ExportAudioTab(QWidget* parent = nullptr);
|
||||
|
||||
QComboBox* codec_combobox() const
|
||||
ExportCodec::Codec GetCodec() const
|
||||
{
|
||||
return codec_combobox_;
|
||||
return static_cast<ExportCodec::Codec>(codec_combobox_->currentData().toInt());
|
||||
}
|
||||
|
||||
void SetCodec(ExportCodec::Codec c)
|
||||
{
|
||||
for (int i=0; i<codec_combobox_->count(); i++) {
|
||||
if (codec_combobox_->itemData(i) == c) {
|
||||
codec_combobox_->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SampleRateComboBox* sample_rate_combobox() const
|
||||
@@ -47,6 +57,11 @@ public:
|
||||
return sample_rate_combobox_;
|
||||
}
|
||||
|
||||
SampleFormatComboBox* sample_format_combobox() const
|
||||
{
|
||||
return sample_format_combobox_;
|
||||
}
|
||||
|
||||
ChannelLayoutComboBox* channel_layout_combobox() const
|
||||
{
|
||||
return channel_layout_combobox_;
|
||||
@@ -64,6 +79,7 @@ private:
|
||||
QComboBox* codec_combobox_;
|
||||
SampleRateComboBox* sample_rate_combobox_;
|
||||
ChannelLayoutComboBox* channel_layout_combobox_;
|
||||
SampleFormatComboBox *sample_format_combobox_;
|
||||
IntegerSlider* bit_rate_slider_;
|
||||
|
||||
};
|
||||
|
||||
@@ -33,12 +33,16 @@ ExportFormatComboBox::ExportFormatComboBox(Mode mode, QWidget *parent) :
|
||||
case kShowAllFormats:
|
||||
break;
|
||||
case kShowAudioOnly:
|
||||
if (!ExportFormat::GetVideoCodecs(f).isEmpty()) {
|
||||
if (!ExportFormat::GetVideoCodecs(f).isEmpty()
|
||||
|| !ExportFormat::GetSubtitleCodecs(f).isEmpty()
|
||||
|| ExportFormat::GetAudioCodecs(f).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case kShowVideoOnly:
|
||||
if (!ExportFormat::GetAudioCodecs(f).isEmpty()) {
|
||||
if (ExportFormat::GetVideoCodecs(f).isEmpty()
|
||||
|| !ExportFormat::GetSubtitleCodecs(f).isEmpty()
|
||||
|| !ExportFormat::GetAudioCodecs(f).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#include "audio/audiomanager.h"
|
||||
#include "config/config.h"
|
||||
#include "dialog/export/exportaudiotab.h"
|
||||
#include "dialog/export/exportformatcombobox.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -99,14 +97,22 @@ PreferencesAudioTab::PreferencesAudioTab()
|
||||
|
||||
fmt_layout->addWidget(new QLabel(tr("Format:")));
|
||||
|
||||
ExportFormatComboBox *fmt_combo = new ExportFormatComboBox(ExportFormatComboBox::kShowAudioOnly);
|
||||
fmt_combo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
fmt_layout->addWidget(fmt_combo);
|
||||
record_format_combo_ = new ExportFormatComboBox(ExportFormatComboBox::kShowAudioOnly);
|
||||
record_format_combo_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
record_format_combo_->SetFormat(static_cast<ExportFormat::Format>(OLIVE_CONFIG("AudioRecordingFormat").toInt()));
|
||||
fmt_layout->addWidget(record_format_combo_);
|
||||
|
||||
ExportAudioTab *audio_recording_options = new ExportAudioTab();
|
||||
recording_layout->addWidget(audio_recording_options);
|
||||
record_options_ = new ExportAudioTab();
|
||||
record_options_->SetCodec(static_cast<ExportCodec::Codec>(OLIVE_CONFIG("AudioRecordingCodec").toInt()));
|
||||
record_options_->sample_rate_combobox()->SetSampleRate(OLIVE_CONFIG("AudioRecordingSampleRate").toInt());
|
||||
record_options_->channel_layout_combobox()->SetChannelLayout(OLIVE_CONFIG("AudioRecordingChannelLayout").toULongLong());
|
||||
record_options_->bit_rate_slider()->SetValue(OLIVE_CONFIG("AudioRecordingBitRate").toInt());
|
||||
record_options_->sample_format_combobox()->SetSampleFormat(static_cast<AudioParams::Format>(OLIVE_CONFIG("AudioRecordingSampleFormat").toInt()));
|
||||
recording_layout->addWidget(record_options_);
|
||||
|
||||
connect(fmt_combo, &ExportFormatComboBox::FormatChanged, audio_recording_options, &ExportAudioTab::SetFormat);
|
||||
connect(record_format_combo_, &ExportFormatComboBox::FormatChanged, record_options_, &ExportAudioTab::SetFormat);
|
||||
|
||||
record_options_->SetFormat(record_format_combo_->GetFormat());
|
||||
}
|
||||
|
||||
QHBoxLayout* refresh_layout = new QHBoxLayout();
|
||||
@@ -134,12 +140,19 @@ void PreferencesAudioTab::Accept(MultiUndoCommand *command)
|
||||
PaDeviceIndex input_device = audio_input_devices_->currentData().value<PaDeviceIndex>();
|
||||
|
||||
// Get device names, which seem to be the closest thing we have to a "unique identifier" for them
|
||||
Config::Current()[QStringLiteral("AudioOutput")] = audio_output_devices_->currentText();
|
||||
Config::Current()[QStringLiteral("AudioInput")] = audio_input_devices_->currentText();
|
||||
OLIVE_CONFIG("AudioOutput") = audio_output_devices_->currentText();
|
||||
OLIVE_CONFIG("AudioInput") = audio_input_devices_->currentText();
|
||||
|
||||
// Set devices to be used from now on
|
||||
AudioManager::instance()->SetOutputDevice(output_device);
|
||||
AudioManager::instance()->SetInputDevice(input_device);
|
||||
|
||||
OLIVE_CONFIG("AudioRecordingFormat") = record_format_combo_->GetFormat();
|
||||
OLIVE_CONFIG("AudioRecordingCodec") = record_options_->GetCodec();
|
||||
OLIVE_CONFIG("AudioRecordingSampleRate") = record_options_->sample_rate_combobox()->GetSampleRate();
|
||||
OLIVE_CONFIG("AudioRecordingChannelLayout") = QVariant::fromValue(record_options_->channel_layout_combobox()->GetChannelLayout());
|
||||
OLIVE_CONFIG("AudioRecordingBitRate") = QVariant::fromValue(record_options_->bit_rate_slider()->GetValue());
|
||||
OLIVE_CONFIG("AudioRecordingSampleFormat") = record_options_->sample_format_combobox()->GetSampleFormat();
|
||||
}
|
||||
|
||||
void PreferencesAudioTab::RefreshBackends()
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "dialog/configbase/configdialogbase.h"
|
||||
#include "dialog/export/exportaudiotab.h"
|
||||
#include "dialog/export/exportformatcombobox.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -59,6 +61,10 @@ private:
|
||||
*/
|
||||
QPushButton* refresh_devices_btn_;
|
||||
|
||||
ExportFormatComboBox *record_format_combo_;
|
||||
|
||||
ExportAudioTab *record_options_;
|
||||
|
||||
private slots:
|
||||
void RefreshBackends();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user