From fdc9506eb31f71c30d82c8f86c978451e78040ae Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 13 Jul 2018 20:43:17 +0100 Subject: [PATCH] added #83 --- dialogs/exportdialog.cpp | 33 +++++++++++++++++++++++++-------- io/exportthread.cpp | 4 ++-- mainwindow.cpp | 2 ++ panels/project.cpp | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 9e89f85fb..59bab8c06 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -435,6 +435,7 @@ void ExportDialog::on_pushButton_clicked() break; default: qDebug() << "[ERROR] Invalid format - this is a bug, please inform the developers"; + QMessageBox::critical(this, "Invalid format", "Couldn't determine output format. This is a bug, please contact the developers.", QMessageBox::Ok); return; } QString filename = QFileDialog::getSaveFileName(this, "Export Media", "", format_strings[ui->formatCombobox->currentIndex()] + " (*." + ext + ")"); @@ -442,6 +443,18 @@ void ExportDialog::on_pushButton_clicked() if (!filename.endsWith("." + ext, Qt::CaseInsensitive)) { filename += "." + ext; } + + if (ui->formatCombobox->currentIndex() == FORMAT_IMG) { + int ext_location = filename.lastIndexOf('.'); + if (ext_location > filename.lastIndexOf('/')) { + filename.insert(ext_location, 'd'); + filename.insert(ext_location, '5'); + filename.insert(ext_location, '0'); + filename.insert(ext_location, '%'); + } + } + + et = new ExportThread(); et->surface.create(); @@ -460,15 +473,19 @@ void ExportDialog::on_pushButton_clicked() et->filename = filename; et->video_enabled = ui->videoGroupbox->isChecked(); - et->video_codec = format_vcodecs.at(ui->vcodecCombobox->currentIndex()); - et->video_width = ui->widthSpinbox->value(); - et->video_height = ui->heightSpinbox->value(); - et->video_frame_rate = ui->framerateSpinbox->value(); - et->video_bitrate = ui->videobitrateSpinbox->value(); + if (et->video_enabled) { + et->video_codec = format_vcodecs.at(ui->vcodecCombobox->currentIndex()); + et->video_width = ui->widthSpinbox->value(); + et->video_height = ui->heightSpinbox->value(); + et->video_frame_rate = ui->framerateSpinbox->value(); + et->video_bitrate = ui->videobitrateSpinbox->value(); + } et->audio_enabled = ui->audioGroupbox->isChecked(); - et->audio_codec = format_acodecs.at(ui->acodecCombobox->currentIndex()); - et->audio_sampling_rate = 48000; - et->audio_bitrate = ui->audiobitrateSpinbox->value(); + if (et->audio_enabled) { + et->audio_codec = format_acodecs.at(ui->acodecCombobox->currentIndex()); + et->audio_sampling_rate = 48000; + et->audio_bitrate = ui->audiobitrateSpinbox->value(); + } et->ed = this; cancelled = false; diff --git a/io/exportthread.cpp b/io/exportthread.cpp index 9c3199c91..0ba0ac752 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -158,7 +158,7 @@ void ExportThread::run() { AV_PIX_FMT_RGBA, video_width, video_height, - AV_PIX_FMT_YUV420P, + vcodec_ctx->pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, @@ -166,7 +166,7 @@ void ExportThread::run() { ); sws_frame = av_frame_alloc(); - sws_frame->format = AV_PIX_FMT_YUV420P; + sws_frame->format = vcodec_ctx->pix_fmt; sws_frame->width = video_frame->width; sws_frame->height = video_frame->height; av_frame_get_buffer(sws_frame, 0); diff --git a/mainwindow.cpp b/mainwindow.cpp index 7e15330de..9fc14d4a9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -359,6 +359,8 @@ void MainWindow::on_action_Open_Project_triggered() void MainWindow::on_actionProject_triggered() { if (can_close_project()) { + project_url.clear(); + project_changed = false; panel_project->new_project(); } } diff --git a/panels/project.cpp b/panels/project.cpp index d1f5864ae..b98716f7a 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -269,7 +269,7 @@ void Project::process_file_list(QStringList& files) { // heuristic to determine whether file is part of an image sequence int lastcharindex = file.lastIndexOf(".")-1; - if (lastcharindex == -2) { + if (lastcharindex == -2 || lastcharindex <= file.lastIndexOf('/')) { lastcharindex = file.length() - 1; } if (file[lastcharindex].isDigit()) {