implemented settings for exporting ONLY video or ONLY audio

This commit is contained in:
itsmattkc
2020-01-08 02:59:30 +11:00
parent b8aabb7e01
commit b697d2faec
8 changed files with 136 additions and 65 deletions
+54 -19
View File
@@ -82,6 +82,20 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
row++;
QHBoxLayout* av_enabled_layout = new QHBoxLayout();
video_enabled_ = new QCheckBox(tr("Export Video"));
video_enabled_->setChecked(true);
av_enabled_layout->addWidget(video_enabled_);
audio_enabled_ = new QCheckBox(tr("Export Audio"));
audio_enabled_->setChecked(true);
av_enabled_layout->addWidget(audio_enabled_);
preferences_layout->addLayout(av_enabled_layout, row, 0, 1, 4);
row++;
QTabWidget* preferences_tabs = new QTabWidget();
QScrollArea* video_area = new QScrollArea();
color_manager_ = static_cast<Sequence*>(viewer_node_->parent())->project()->color_manager();
@@ -167,16 +181,29 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
void ExportDialog::accept()
{
int source_width = viewer_node_->video_params().width();
int source_height = viewer_node_->video_params().height();
if (!video_enabled_->isChecked() && !audio_enabled_->isChecked()) {
QMessageBox::warning(this,
tr("Invalid parameters"),
tr("Both video and audio are disabled. There's nothing to export."),
QMessageBox::Ok);
return;
}
QMatrix4x4 transform;
int dest_width = video_tab_->width_slider()->GetValue();
int dest_height = video_tab_->height_slider()->GetValue();
QMatrix4x4 transform = GenerateMatrix(static_cast<ExportVideoTab::ScalingMethod>(video_tab_->scaling_method_combobox()->currentData().toInt()),
source_width,
source_height,
dest_width,
dest_height);
if (video_tab_->scaling_method_combobox()->isEnabled()) {
int source_width = viewer_node_->video_params().width();
int source_height = viewer_node_->video_params().height();
transform = GenerateMatrix(static_cast<ExportVideoTab::ScalingMethod>(video_tab_->scaling_method_combobox()->currentData().toInt()),
source_width,
source_height,
dest_width,
dest_height);
}
// FIXME: Hardcoded pixel format
VideoRenderingParams video_render_params(dest_width, dest_height, video_tab_->frame_rate().flipped(), PixelFormat::PIX_FMT_RGBA32F, RenderMode::kOnline);
@@ -196,16 +223,29 @@ void ExportDialog::accept()
EncodingParams encoding_params;
encoding_params.SetFilename(filename_edit_->text()); // FIXME: Validate extension
const ExportCodec& video_codec = codecs_.at(video_tab_->codec_combobox()->currentData().toInt());
const ExportCodec& audio_codec = codecs_.at(audio_tab_->codec_combobox()->currentData().toInt());
encoding_params.EnableVideo(video_render_params,
video_codec.id());
encoding_params.EnableAudio(audio_render_params,
audio_codec.id());
if (video_enabled_->isChecked()) {
const ExportCodec& video_codec = codecs_.at(video_tab_->codec_combobox()->currentData().toInt());
encoding_params.EnableVideo(video_render_params,
video_codec.id());
}
if (audio_enabled_->isChecked()) {
const ExportCodec& audio_codec = codecs_.at(audio_tab_->codec_combobox()->currentData().toInt());
encoding_params.EnableAudio(audio_render_params,
audio_codec.id());
}
Encoder* encoder = Encoder::CreateFromID("ffmpeg", encoding_params);
OpenGLExporter* exporter = new OpenGLExporter(viewer_node_, video_render_params, audio_render_params, transform, color_processor, encoder);
OpenGLExporter* exporter = new OpenGLExporter(viewer_node_, encoder);
if (video_enabled_->isChecked()) {
exporter->EnableVideo(video_render_params, transform, color_processor);
}
if (audio_enabled_->isChecked()) {
exporter->EnableAudio(audio_render_params);
}
connect(exporter, &Exporter::ExportEnded, this, &ExportDialog::ExporterIsDone);
connect(exporter, &Exporter::ProgressChanged, progress_bar_, &QProgressBar::setValue);
@@ -269,11 +309,6 @@ void ExportDialog::ResolutionChanged()
// This catches both the width slider changing and the maintain aspect ratio checkbox changing
video_tab_->height_slider()->SetValue(qRound(static_cast<double>(video_tab_->width_slider()->GetValue()) / video_aspect_ratio_));
}
} else {
double current_ratio = static_cast<double>(video_tab_->width_slider()->GetValue()) / static_cast<double>(video_tab_->height_slider()->GetValue());
// Enable scaling method combobox only if width/height are not equal to sequence size
video_tab_->scaling_method_combobox()->setEnabled(!qFuzzyCompare(current_ratio, video_aspect_ratio_));
}
UpdateViewerDimensions();
+3
View File
@@ -33,6 +33,9 @@ private:
QList<ExportFormat> formats_;
int previously_selected_format_;
QCheckBox* video_enabled_;
QCheckBox* audio_enabled_;
QList<ExportCodec> codecs_;
ViewerWidget* preview_viewer_;
+8
View File
@@ -124,6 +124,9 @@ QWidget* ExportVideoTab::SetupResolutionSection()
scaling_method_combobox_->addItem(tr("Crop"), kCrop);
layout->addWidget(scaling_method_combobox_, row, 1);
// Automatically enable/disable the scaling method depending on maintain aspect ratio
connect(maintain_aspect_checkbox_, &QCheckBox::toggled, this, &ExportVideoTab::MaintainAspectRatioChanged);
row++;
layout->addWidget(new QLabel(tr("Frame Rate:")), row, 0);
@@ -230,3 +233,8 @@ void ExportVideoTab::ColorLookChanged()
{
emit LookChanged(looks_combobox_->currentData().toString());
}
void ExportVideoTab::MaintainAspectRatioChanged(bool val)
{
scaling_method_combobox_->setEnabled(!val);
}
+2
View File
@@ -71,6 +71,8 @@ private slots:
void ColorViewChanged();
void ColorLookChanged();
void MaintainAspectRatioChanged(bool val);
};
#endif // EXPORTVIDEOTAB_H