Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Quick Export Feature (#725)

Jeremy Bullock3bb5efc4ee44
diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xml
index 6c9f3b87e..92a3b146c 100644
--- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml
+++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml
@@ -34,6 +34,7 @@
<separator/>
<command>MI_OutputSettings</command>
<command>MI_Render</command>
+ <command>MI_FastRender</command>
<separator/>
<command>MI_PrintXsheet</command>
<command>MI_Print</command>
diff --git a/toonz/sources/image/ffmpeg/tiio_mp4.cpp b/toonz/sources/image/ffmpeg/tiio_mp4.cpp
index 173d6275c..1e83e1a38 100644
--- a/toonz/sources/image/ffmpeg/tiio_mp4.cpp
+++ b/toonz/sources/image/ffmpeg/tiio_mp4.cpp
@@ -39,11 +39,16 @@ private:
TLevelWriterMp4::TLevelWriterMp4(const TFilePath &path, TPropertyGroup *winfo)
: TLevelWriter(path, winfo) {
if (!m_properties) m_properties = new Tiio::Mp4WriterProperties();
- std::string scale = m_properties->getProperty("Scale")->getValueAsString();
- m_scale = QString::fromStdString(scale).toInt();
- std::string quality =
- m_properties->getProperty("Quality")->getValueAsString();
- m_vidQuality = QString::fromStdString(quality).toInt();
+ if (m_properties->getPropertyCount() == 0) {
+ m_scale = 100;
+ m_vidQuality = 100;
+ } else {
+ std::string scale = m_properties->getProperty("Scale")->getValueAsString();
+ m_scale = QString::fromStdString(scale).toInt();
+ std::string quality =
+ m_properties->getProperty("Quality")->getValueAsString();
+ m_vidQuality = QString::fromStdString(quality).toInt();
+ }
ffmpegWriter = new Ffmpeg();
ffmpegWriter->setPath(m_path);
if (TSystem::doesExistFileOrLevel(m_path)) TSystem::deleteFile(m_path);
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h
index 56f7e3eff..4e3e30dd7 100644
--- a/toonz/sources/include/toonz/preferences.h
+++ b/toonz/sources/include/toonz/preferences.h
@@ -411,7 +411,8 @@ public:
bool getPrecompute() { return m_precompute; }
void setFfmpegTimeout(int seconds);
int getFfmpegTimeout() { return m_ffmpegTimeout; }
-
+ void setFastRenderPath(std::string path);
+ QString getFastRenderPath() const { return m_fastRenderPath; }
// Uncategorized - internals
void setAskForOverrideRender(bool on);
@@ -455,6 +456,7 @@ private:
QString m_units, m_cameraUnits, m_scanLevelType, m_currentRoomChoice,
m_oldUnits, m_oldCameraUnits, m_ffmpegPath, m_shortcutPreset,
m_customProjectRoot;
+ QString m_fastRenderPath;
double m_defLevelWidth, m_defLevelHeight, m_defLevelDpi;
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index 23c7403a3..1a070a6a5 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -1601,6 +1601,7 @@ void MainWindow::defineActions() {
createMenuFileAction(MI_OutputSettings, tr("&Output Settings..."), "Ctrl+O");
createMenuFileAction(MI_PreviewSettings, tr("&Preview Settings..."), "");
createMenuFileAction(MI_Render, tr("&Render"), "Ctrl+Shift+R");
+ createMenuFileAction(MI_FastRender, tr("&Fast Render to MP4"), "Alt+R");
createMenuFileAction(MI_Preview, tr("&Preview"), "Ctrl+R");
createRightClickMenuAction(MI_SavePreviewedFrames,
tr("&Save Previewed Frames"), "");
diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cpp
index c57824520..97b43987f 100644
--- a/toonz/sources/toonz/menubar.cpp
+++ b/toonz/sources/toonz/menubar.cpp
@@ -1099,6 +1099,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {
fileMenu->addSeparator();
addMenuItem(fileMenu, MI_OutputSettings);
addMenuItem(fileMenu, MI_Render);
+ addMenuItem(fileMenu, MI_FastRender);
// addMenuItem(fileMenu, MI_SavePreviewedFrames);
fileMenu->addSeparator();
addMenuItem(fileMenu, MI_PrintXsheet);
diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h
index 6c79b5e41..0b7f96bb5 100644
--- a/toonz/sources/toonz/menubarcommandids.h
+++ b/toonz/sources/toonz/menubarcommandids.h
@@ -41,6 +41,7 @@
#define MI_OutputSettings "MI_OutputSettings"
#define MI_PreviewSettings "MI_PreviewSettings"
#define MI_Render "MI_Render"
+#define MI_FastRender "MI_FastRender"
#define MI_Preview "MI_Preview"
#define MI_RegeneratePreview "MI_RegeneratePreview"
#define MI_RegenerateFramePr "MI_RegenerateFramePr"
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index d9d06f1d3..2b518ae5f 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -923,6 +923,13 @@ void PreferencesPopup::onFfmpegPathChanged() {
//-----------------------------------------------------------------------------
+void PreferencesPopup::onFastRenderPathChanged() {
+ QString text = m_fastRenderPathFileField->getPath();
+ m_pref->setFastRenderPath(text.toStdString());
+}
+
+//-----------------------------------------------------------------------------
+
void PreferencesPopup::onFfmpegTimeoutChanged() {
m_pref->setFfmpegTimeout(m_ffmpegTimeout->getValue());
}
@@ -1118,7 +1125,9 @@ PreferencesPopup::PreferencesPopup()
//--- Import/Export ------------------------------
categoryList->addItem(tr("Import/Export"));
m_ffmpegPathFileFld = new DVGui::FileField(this, QString(""));
- m_ffmpegTimeout = new DVGui::IntLineEdit(this, 30, 1);
+ m_fastRenderPathFileField =
+ new DVGui::FileField(this, QString("desktop"), false, true);
+ m_ffmpegTimeout = new DVGui::IntLineEdit(this, 30, 1);
//--- Drawing ------------------------------
categoryList->addItem(tr("Drawing"));
@@ -1342,6 +1351,8 @@ PreferencesPopup::PreferencesPopup()
//--- Import/Export ------------------------------
QString path = m_pref->getFfmpegPath();
m_ffmpegPathFileFld->setPath(path);
+ path = m_pref->getFastRenderPath();
+ m_fastRenderPathFileField->setPath(path);
m_ffmpegTimeout->setValue(m_pref->getFfmpegTimeout());
//--- Drawing ------------------------------
@@ -1755,6 +1766,14 @@ PreferencesPopup::PreferencesPopup()
ioGridLay->addWidget(new QLabel(tr("FFmpeg Timeout:")), 4, 0,
Qt::AlignRight);
ioGridLay->addWidget(m_ffmpegTimeout, 4, 1, 1, 3);
+ ioGridLay->addWidget(new QLabel(" "), 5, 0);
+ ioGridLay->addWidget(
+ new QLabel(tr("Please indicate where you would like "
+ "exports from Fast Render(MP4) to go.")),
+ 6, 0, 1, 4);
+ ioGridLay->addWidget(new QLabel(tr("Fast Render Path: ")), 7, 0,
+ Qt::AlignRight);
+ ioGridLay->addWidget(m_fastRenderPathFileField, 7, 1, 1, 3);
}
ioLay->addLayout(ioGridLay);
ioLay->addStretch(1);
@@ -2128,6 +2147,8 @@ PreferencesPopup::PreferencesPopup()
//--- Import/Export ----------------------
ret = ret && connect(m_ffmpegPathFileFld, SIGNAL(pathChanged()), this,
SLOT(onFfmpegPathChanged()));
+ ret = ret && connect(m_fastRenderPathFileField, SIGNAL(pathChanged()), this,
+ SLOT(onFastRenderPathChanged()));
ret = ret && connect(m_ffmpegTimeout, SIGNAL(editingFinished()), this,
SLOT(onFfmpegTimeoutChanged()));
diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h
index ba790d7e8..ddc1be1bf 100644
--- a/toonz/sources/toonz/preferencespopup.h
+++ b/toonz/sources/toonz/preferencespopup.h
@@ -76,7 +76,7 @@ private:
DVGui::FileField *m_customProjectRootFileField;
- DVGui::FileField *m_ffmpegPathFileFld;
+ DVGui::FileField *m_ffmpegPathFileFld, *m_fastRenderPathFileField;
QGroupBox *m_autoSaveGroup;
@@ -168,6 +168,7 @@ private slots:
void onShowKeyframesOnCellAreaChanged(int);
void onFfmpegPathChanged();
void onFfmpegTimeoutChanged();
+ void onFastRenderPathChanged();
void onUseNumpadForSwitchingStylesClicked(bool);
};
diff --git a/toonz/sources/toonz/rendercommand.cpp b/toonz/sources/toonz/rendercommand.cpp
index adaf9f8fb..5af6af177 100644
--- a/toonz/sources/toonz/rendercommand.cpp
+++ b/toonz/sources/toonz/rendercommand.cpp
@@ -214,6 +214,7 @@ public:
, m_timeStretchFactor(1)
, m_multimediaRender(0) {
setCommandHandler("MI_Render", this, &RenderCommand::onRender);
+ setCommandHandler("MI_FastRender", this, &RenderCommand::onFastRender);
setCommandHandler("MI_Preview", this, &RenderCommand::onPreview);
}
@@ -222,6 +223,7 @@ public:
void rasterRender(bool isPreview);
void multimediaRender();
void onRender();
+ void onFastRender();
void onPreview();
static void resetBgColor();
void doRender(bool isPreview);
@@ -788,6 +790,38 @@ void RenderCommand::multimediaRender() {
void RenderCommand::onRender() { doRender(false); }
+void RenderCommand::onFastRender() {
+ TOutputProperties *prop = TApp::instance()
+ ->getCurrentScene()
+ ->getScene()
+ ->getProperties()
+ ->getOutputProperties();
+ QString sceneName = QString::fromStdWString(
+ TApp::instance()->getCurrentScene()->getScene()->getSceneName());
+ QString location = Preferences::instance()->getFastRenderPath();
+ if (location == "desktop" || location == "Desktop") {
+ location =
+ QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
+ }
+ TFilePath path = TFilePath(location) + TFilePath(sceneName + ".mp4");
+ TFilePath currPath = prop->getPath();
+
+ QStringList formats;
+ TImageWriter::getSupportedFormats(formats, true);
+ TLevelWriter::getSupportedFormats(formats, true);
+ Tiio::Writer::getSupportedFormats(formats, true);
+ if (!formats.contains("mp4")) {
+ QString msg = QObject::tr(
+ "FFmpeg not found, please set the location in the Preferences and "
+ "restart.");
+ DVGui::warning(msg);
+ return;
+ }
+ prop->setPath(path);
+ doRender(false);
+ prop->setPath(currPath);
+}
+
void RenderCommand::onPreview() { doRender(true); }
//---------------------------------------------------------
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index b325637d5..3d636181e 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -294,6 +294,7 @@ Preferences::Preferences()
, m_projectRoot(0x08)
, m_customProjectRoot("")
, m_precompute(true)
+ , m_fastRenderPath("desktop")
, m_ffmpegTimeout(30)
, m_shortcutPreset("defopentoonz")
, m_useNumpadForSwitchingStyles(true) {
@@ -561,6 +562,9 @@ Preferences::Preferences()
QString ffmpegPath = m_settings->value("ffmpegPath").toString();
if (ffmpegPath != "") m_ffmpegPath = ffmpegPath;
setFfmpegPath(m_ffmpegPath.toStdString());
+ QString fastRenderPath = m_settings->value("fastRenderPath").toString();
+ if (fastRenderPath != "") m_fastRenderPath = fastRenderPath;
+ setFastRenderPath(m_fastRenderPath.toStdString());
getValue(*m_settings, "ffmpegTimeout", m_ffmpegTimeout);
QString shortcutPreset = m_settings->value("shortcutPreset").toString();
if (shortcutPreset != "") m_shortcutPreset = shortcutPreset;
@@ -1259,6 +1263,14 @@ void Preferences::setFfmpegPath(std::string path) {
//-----------------------------------------------------------------
+void Preferences::setFastRenderPath(std::string path) {
+ m_fastRenderPath = QString::fromStdString(path);
+ std::string strPath = m_ffmpegPath.toStdString();
+ m_settings->setValue("fastRenderPath", m_fastRenderPath);
+}
+
+//-----------------------------------------------------------------
+
void Preferences::setShortcutPreset(std::string preset) {
m_shortcutPreset = QString::fromStdString(preset);
m_settings->setValue("shortcutPreset", m_shortcutPreset);