]> git.sesse.net Git - kdenlive/blobdiff - src/renderwidget.cpp
Add mlt and encoder threads to render dialog.
[kdenlive] / src / renderwidget.cpp
index fccfef86767e6165f2d0a2807f332dbe685293c0..18b97b63bc12d7e36d665d6088c76b95a334392b 100644 (file)
@@ -43,6 +43,7 @@
 #include <QProcess>
 #include <QDBusConnectionInterface>
 #include <QDBusInterface>
+#include <QThread>
 
 const int GroupRole = Qt::UserRole;
 const int ExtensionRole = GroupRole + 1;
@@ -59,7 +60,7 @@ const int RUNNINGJOB = 1;
 const int FINISHEDJOB = 2;
 
 
-RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
+RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidget * parent) :
         QDialog(parent),
         m_projectFolder(projectfolder),
         m_blockProcessing(false)
@@ -86,7 +87,13 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     if (KdenliveSettings::showrenderparams()) {
         m_view.buttonInfo->setDown(true);
     } else m_view.advanced_params->hide();
+    
+    m_view.proxy_render->setHidden(!enableProxy);
 
+       m_view.encoder_threads->setMaximum(QThread::idealThreadCount());
+       m_view.encoder_threads->setValue(KdenliveSettings::encodethreads());
+       connect(m_view.encoder_threads, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateEncodeThreads(int)));
+       
     m_view.rescale_keep->setChecked(KdenliveSettings::rescalekeepratio());
     connect(m_view.rescale_width, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleWidth(int)));
     connect(m_view.rescale_height, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateRescaleHeight(int)));
@@ -753,6 +760,10 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     // disable audio if requested
     if (!exportAudio) renderArgs.append(" an=1 ");
 
+       // Set the thread counts
+       renderArgs.append(QString(" threads=%1").arg(KdenliveSettings::encodethreads()));
+       renderArgs.append(QString(" real_time=-%1").arg(KdenliveSettings::mltthreads()));
+
     // Check if the rendering profile is different from project profile,
     // in which case we need to use the producer_comsumer from MLT
     QString std = renderArgs;
@@ -778,10 +789,12 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
             break;
         }
     }
-
-    if (resizeProfile) render_process_args << "consumer:" + playlistPath;
-    else render_process_args << playlistPath;
-    render_process_args << dest;
+       
+    if (resizeProfile)
+        render_process_args << "consumer:" + (scriptExport ? "$SOURCE" : playlistPath);
+    else
+        render_process_args <<  (scriptExport ? "$SOURCE" : playlistPath);
+    render_process_args << (scriptExport ? "$TARGET" : dest);
     render_process_args << paramsList;
 
     QString group = m_view.size_list->currentItem()->data(MetaGroupRole).toString();
@@ -1611,16 +1624,17 @@ void RenderWidget::parseScriptFiles()
         QString melt;
         QFile file(scriptpath.path());
         if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
-            while (!file.atEnd()) {
-                QByteArray line = file.readLine();
+            QTextStream stream(&file);
+            while (!stream.atEnd()) {
+                QString line = stream.readLine();
                 if (line.startsWith("TARGET=")) {
-                    target = QString(line).section("TARGET=", 1).simplified();
+                    target = line.section("TARGET=", 1).simplified();
                     target.remove(QChar('"'));
                 } else if (line.startsWith("RENDERER=")) {
-                    renderer = QString(line).section("RENDERER=", 1).simplified();
+                    renderer = line.section("RENDERER=", 1).simplified();
                     renderer.remove(QChar('"'));
                 } else if (line.startsWith("MELT=")) {
-                    melt = QString(line).section("MELT=", 1).simplified();
+                    melt = line.section("MELT=", 1).simplified();
                     melt.remove(QChar('"'));
                 }
             }
@@ -1644,8 +1658,8 @@ void RenderWidget::parseScriptFiles()
     bool activate = false;
     QTreeWidgetItem *script = m_view.scripts_list->topLevelItem(0);
     if (script) {
-        script->setSelected(true);
         m_view.scripts_list->setCurrentItem(script);
+        script->setSelected(true);
         activate = true;
     }
 //    m_view.start_script->setEnabled(activate);
@@ -1854,6 +1868,11 @@ void RenderWidget::missingClips(bool hasMissing)
     } else m_view.errorBox->setHidden(true);
 }
 
+void RenderWidget::slotUpdateEncodeThreads(int val)
+{
+       KdenliveSettings::setEncodethreads(val);
+}
+
 void RenderWidget::slotUpdateRescaleWidth(int val)
 {
     KdenliveSettings::setDefaultrescalewidth(val);
@@ -1898,3 +1917,12 @@ bool RenderWidget::selectedAudioExport() const
     return (m_view.export_audio->checkState() != Qt::Unchecked);
 }
 
+void RenderWidget::updateProxyConfig(bool enable)
+{
+    m_view.proxy_render->setHidden(!enable);
+}
+
+bool RenderWidget::proxyRendering()
+{
+    return m_view.proxy_render->isChecked();
+}