[krita] plugins/extensions/animationrenderer: Fix Animation Export Dialog.

Wolthera van Hövell tot Westerflier null at kde.org
Tue Dec 18 19:15:44 GMT 2018


Git commit 42a4ce4c56ff3e5daf0f01080ec39c1bacc4c7bf by Wolthera van Hövell tot Westerflier.
Committed on 18/12/2018 at 19:11.
Pushed by woltherav into branch 'master'.

Fix Animation Export Dialog.

This does two things:

1. It makes sure that the default dialog uses the encoder config you
can set for that file format. This ensures baseline is defaulted to instead
of the default ffmpeg uses.
2. It adds in a warning dialog because mp4 and mkv don't like using uneven numbers and thus
will error out ffmpeg.

Please check if this patch doesn't break your animation workflow!

CCMAIL:kimageshop at kde.org

M  +17   -0    plugins/extensions/animationrenderer/AnimationRenderer.cpp
M  +32   -5    plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
M  +9    -0    plugins/extensions/animationrenderer/DlgAnimationRenderer.h

https://commits.kde.org/krita/42a4ce4c56ff3e5daf0f01080ec39c1bacc4c7bf

diff --git a/plugins/extensions/animationrenderer/AnimationRenderer.cpp b/plugins/extensions/animationrenderer/AnimationRenderer.cpp
index 7556a9adcd4..bd54aeb685e 100644
--- a/plugins/extensions/animationrenderer/AnimationRenderer.cpp
+++ b/plugins/extensions/animationrenderer/AnimationRenderer.cpp
@@ -100,8 +100,25 @@ void AnimaterionRenderer::slotRenderAnimation()
                 .arg(sequenceConfig->getString("basename"))
                 .arg(extension);
 
+        /**
+         * Check if the dimensions make sense before we even try to batch save.
+         */
+        KisPropertiesConfigurationSP encoderConfig = dlgAnimationRenderer.getEncoderConfiguration();
+        if ((image->height()%2 || image->width()%2)
+                && (encoderConfig->getString("mimetype") == "video/mp4" ||
+                    encoderConfig->getString("mimetype") == "video/x-matroska")) {
+            QString m = "Mastroska (.mkv)";
+            if (encoderConfig->getString("mimetype")== "video/mp4") {
+                m = "Mpeg4 (.mp4)";
+            }
+            qWarning() << m <<"requires width and height to be even, resize and try again!";
+            doc->setErrorMessage(i18n("%1 requires width and height to be even numbers.  Please resize or crop the image before exporting.", m));
+            QMessageBox::critical(0, i18nc("@title:window", "Krita"), i18n("Could not render animation:\n%1", doc->errorMessage()));
+            return;
+        }
 
         const bool batchMode = false; // TODO: fetch correctly!
+
         KisAsyncAnimationFramesSaveDialog exporter(doc->image(),
                                                    KisTimeRange::fromTime(sequenceConfig->getInt("first_frame"), sequenceConfig->getInt("last_frame")),
                                                    baseFileName,
diff --git a/plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp b/plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
index 6f5c5c988ed..27058188b63 100644
--- a/plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
+++ b/plugins/extensions/animationrenderer/DlgAnimationRenderer.cpp
@@ -282,6 +282,7 @@ KisPropertiesConfigurationSP DlgAnimationRenderer::getFrameExportConfiguration()
 {
     if (m_frameExportConfigWidget) {
         KisPropertiesConfigurationSP cfg = m_frameExportConfigWidget->configuration();
+        qDebug()<<Q_FUNC_INFO<<cfg;
         cfg->setProperty("basename", m_page->txtBasename->text());
         cfg->setProperty("directory", fetchRenderingDirectory());
         cfg->setProperty("first_frame", m_page->intStart->value());
@@ -334,8 +335,16 @@ KisPropertiesConfigurationSP DlgAnimationRenderer::getEncoderConfiguration() con
     cfg->setProperty("first_frame", m_page->intStart->value());
     cfg->setProperty("last_frame", m_page->intEnd->value());
     cfg->setProperty("framerate", m_page->intFramesPerSecond->value());
-    cfg->setProperty("height", m_page->intHeight->value());
-    cfg->setProperty("width", m_page->intWidth->value());
+    int height = m_page->intHeight->value();
+    if (height % 2) {
+        height += 1;
+    }
+    cfg->setProperty("height", height);
+    int width = m_page->intWidth->value();
+    if (width % 2) {
+        width += 1;
+    }
+    cfg->setProperty("width", width);
     cfg->setProperty("sequence_start", m_page->sequenceStart->value());
     cfg->setProperty("include_audio", m_page->chkIncludeAudio->isChecked());
 
@@ -372,25 +381,26 @@ void DlgAnimationRenderer::selectRenderType(int index)
     m_page->videoFilename->setMimeTypeFilters(QStringList() << mimetype, mimetype);
 
     m_page->videoFilename->setFileName(m_defaultFileName + "." + KisMimeDatabase::suffixesForMimeType(mimetype).first());
+    createEncoderWidget(index);
 }
 
 void DlgAnimationRenderer::selectRenderOptions()
 {
     int index = m_page->cmbRenderType->currentIndex();
-
     if (m_encoderConfigWidget) {
         m_encoderConfigWidget->deleteLater();
         m_encoderConfigWidget = 0;
     }
 
     if (index >= m_renderFilters.size()) return;
+    if (!m_encoderConfigWidget) {
+        createEncoderWidget(index);
+    }
 
     QSharedPointer<KisImportExportFilter> filter = m_renderFilters[index];
     QString mimetype = m_page->cmbRenderType->itemData(index).toString();
     if (filter) {
-        m_encoderConfigWidget = filter->createConfigurationWidget(0, KisDocument::nativeFormatMimeType(), mimetype.toLatin1());
         if (m_encoderConfigWidget) {
-            m_encoderConfigWidget->setConfiguration(filter->lastSavedConfiguration("", mimetype.toLatin1()));
             KoDialog dlg(this);
             dlg.setMainWidget(m_encoderConfigWidget);
             dlg.setButtons(KoDialog::Ok | KoDialog::Cancel);
@@ -410,6 +420,23 @@ void DlgAnimationRenderer::selectRenderOptions()
 
 }
 
+void DlgAnimationRenderer::createEncoderWidget(int index)
+{
+    if (m_encoderConfigWidget) {
+        m_encoderConfigWidget->deleteLater();
+        m_encoderConfigWidget = 0;
+    }
+    if (index >= m_renderFilters.size()) return;
+    QSharedPointer<KisImportExportFilter> filter = m_renderFilters[index];
+    QString mimetype = m_page->cmbRenderType->itemData(index).toString();
+    if (filter) {
+        m_encoderConfigWidget = filter->createConfigurationWidget(0, KisDocument::nativeFormatMimeType(), mimetype.toLatin1());
+        if (m_encoderConfigWidget) {
+            m_encoderConfigWidget->setConfiguration(filter->lastSavedConfiguration("", mimetype.toLatin1()));
+        }
+    }
+}
+
 void DlgAnimationRenderer::sequenceMimeTypeSelected()
 {
     int index = m_page->cmbMimetype->currentIndex();
diff --git a/plugins/extensions/animationrenderer/DlgAnimationRenderer.h b/plugins/extensions/animationrenderer/DlgAnimationRenderer.h
index 8336b94523e..bbae137c3e5 100644
--- a/plugins/extensions/animationrenderer/DlgAnimationRenderer.h
+++ b/plugins/extensions/animationrenderer/DlgAnimationRenderer.h
@@ -73,6 +73,15 @@ private Q_SLOTS:
 
     void selectRenderType(int i);
     void selectRenderOptions();
+    /**
+     * @brief createEncoderWidget
+     * creates a new settings widget for the filetype.
+     */
+    void createEncoderWidget(int index);
+    /**
+     * @brief sequenceMimeTypeSelected
+     * calls the dialog for the export widget.
+     */
     void sequenceMimeTypeSelected();
     void ffmpegLocationChanged(const QString&);
 


More information about the kimageshop mailing list