31 const QString baseFileName = QString(
"%1/%2.%3").arg(framesDirectory, encoderOptions.
basename, extension);
35 encoderOptions.
width = encoderOptions.
width + (encoderOptions.
width & 0x1);
40 const QSize scaledSize = doc->
image()->
bounds().size().scaled(encoderOptions.
width, encoderOptions.
height, Qt::IgnoreAspectRatio);
44 QString type = encoderOptions.
videoMimeType ==
"video/mp4" ?
"Mpeg4 (.mp4) " :
"Matroska (.mkv) ";
46 qWarning() << type <<
"requires width and height to be even, resize and try again!";
47 doc->
setErrorMessage(i18n(
"%1 requires width and height to be even numbers. Please resize or crop the image before exporting.", type));
48 QMessageBox::critical(qApp->activeWindow(), i18nc(
"@title:window",
"Krita"), i18n(
"Could not render animation:\n%1", doc->
errorMessage()));
54 const bool batchMode =
false;
79 const QFileInfo videoOutputFile(videoOutputFilePath);
80 QDir outputDir(videoOutputFile.absolutePath());
82 if (!outputDir.exists()) {
83 outputDir.mkpath(videoOutputFile.absolutePath());
88 bool videoFileWriteAllowed =
true;
89 if (videoOutputFile.exists()) {
90 QMessageBox videoOverwritePrompt;
92 videoOverwritePrompt.setText(i18n(
"Overwrite existing video?"));
93 videoOverwritePrompt.setInformativeText(i18n(
"A file already exists at the path where you want to render your video [%1]... \n\
94 Are you sure you want to overwrite the existing file?", videoOutputFilePath));
95 videoOverwritePrompt.setStandardButtons(QMessageBox::Ok | QMessageBox::Abort);
97 videoFileWriteAllowed = videoOverwritePrompt.exec() == QMessageBox::Ok ? true :
false;
101 if (videoFileWriteAllowed) {
104 QFile videoOutputFile(videoOutputFilePath);
105 if (!videoOutputFile.open(QIODevice::WriteOnly)) {
106 qWarning() <<
"Could not open" << videoOutputFile.fileName() <<
"for writing! Do you have permission to write to this file?";
109 videoOutputFile.close();
113 result =
encoder->convert(doc, savedFilesMask, encoderOptions, batchMode);
115 if (!result.
isOk()) {
116 QMessageBox::critical(qApp->activeWindow(), i18nc(
"@title:window",
"Krita"), i18n(
"Could not render animation:\n%1", result.
errorMessage()));
118 delayReturnSuccess =
false;
124 QDir d(framesDirectory);
129 Q_FOREACH(
const QString &f, savedFiles) {
138 Q_FOREACH(
const QString &f, fileNames) {
139 if (!uniqueFrameNames.contains(f)) {
147 Q_FOREACH(
const QString &f, paletteFiles) {
151 QMessageBox::critical(qApp->activeWindow(), i18nc(
"@title:window",
"Rendering error"),
"Animation frame rendering has timed out. Output files are incomplete.\nTry to increase \"Frame Rendering Timeout\" or reduce \"Frame Rendering Clones Limit\" in Krita settings");
153 QMessageBox::critical(qApp->activeWindow(), i18nc(
"@title:window",
"Rendering error"), i18n(
"Failed to render animation frames! Output files are incomplete."));
156 return delayReturnSuccess;
KisViewManager * viewManager