Commit 42a4ce4c authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

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@kde.org
parent c0d1b7d7
......@@ -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,
......
......@@ -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();
......
......@@ -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&);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment