]> git.sesse.net Git - kdenlive/blobdiff - src/renderwidget.cpp
Show rendering progress in the correct Kdenlive instance:
[kdenlive] / src / renderwidget.cpp
index 65992b4aecf51f167798d10a8b4d1139589755d8..6250d230e5df4c3674a9859a72e6af5e2ce274c6 100644 (file)
@@ -57,6 +57,8 @@ const int MetaGroupRole = GroupRole + 6;
 const int ExtraRole = GroupRole + 7;
 const int BitratesRole = GroupRole + 8;
 const int DefaultBitrateRole = GroupRole + 9;
+const int AudioBitratesRole = GroupRole + 10;
+const int DefaultAudioBitrateRole = GroupRole + 11;
 
 // Running job status
 const int WAITINGJOB = 0;
@@ -220,6 +222,7 @@ RenderWidget::RenderWidget(const QString &projectfolder, bool enableProxy, QWidg
         m_view.shutdown->setEnabled(false);
 
     focusFirstVisibleItem();
+    adjustSize();
 }
 
 RenderWidget::~RenderWidget()
@@ -363,7 +366,8 @@ void RenderWidget::slotSaveProfile()
     if (customGroup.isEmpty()) customGroup = i18nc("Group Name", "Custom");
     ui.group_name->setText(customGroup);
 
-    ui.parameters->setText(m_view.advanced_params->toPlainText());
+    QStringList arguments = m_view.advanced_params->toPlainText().split(" ", QString::SkipEmptyParts);
+    ui.parameters->setText(arguments.join(" "));
     ui.extension->setText(m_view.size_list->currentItem()->data(ExtensionRole).toString());
     ui.profile_name->setFocus();
 
@@ -379,7 +383,24 @@ void RenderWidget::slotSaveProfile()
         profileElement.setAttribute("category", newGroupName);
         profileElement.setAttribute("destinationid", newMetaGroupId);
         profileElement.setAttribute("extension", ui.extension->text().simplified());
-        profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
+        QString args = ui.parameters->toPlainText().simplified();
+        profileElement.setAttribute("args", args);
+        if (args.contains("%bitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultbitrate", m_view.comboBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboBitrates->count(); i++)
+                bitrateValues << m_view.comboBitrates->itemText(i);
+            profileElement.setAttribute("bitrates", bitrateValues.join(","));
+        }
+        if (args.contains("%audiobitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultaudiobitrate", m_view.comboAudioBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboAudioBitrates->count(); i++)
+                bitrateValues << m_view.comboAudioBitrates->itemText(i);
+            profileElement.setAttribute("audiobitrates", bitrateValues.join(","));
+        }
         doc.appendChild(profileElement);
         saveProfile(doc.documentElement());
 
@@ -467,6 +488,10 @@ void RenderWidget::slotCopyToFavorites()
     profileElement.setAttribute("destinationid", "favorites");
     profileElement.setAttribute("extension", extension);
     profileElement.setAttribute("args", params);
+    profileElement.setAttribute("bitrates", item->data(BitratesRole).toStringList().join(","));
+    profileElement.setAttribute("defaultbitrate", item->data(DefaultBitrateRole).toString());
+    profileElement.setAttribute("audiobitrates", item->data(AudioBitratesRole).toStringList().join(","));
+    profileElement.setAttribute("defaultaudiobitrate", item->data(DefaultAudioBitrateRole).toString());
     doc.appendChild(profileElement);
     saveProfile(doc.documentElement());
     parseProfiles(m_view.destination_list->itemData(m_view.destination_list->currentIndex(), Qt::UserRole).toString(), currentGroup, currentProfile);
@@ -555,7 +580,25 @@ void RenderWidget::slotEditProfile()
         profileElement.setAttribute("category", newGroupName);
         profileElement.setAttribute("destinationid", newMetaGroupId);
         profileElement.setAttribute("extension", ui.extension->text().simplified());
-        profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
+        QString args = ui.parameters->toPlainText().simplified();
+        profileElement.setAttribute("args", args);
+        if (args.contains("%bitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultbitrate", m_view.comboBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboBitrates->count(); i++)
+                bitrateValues << m_view.comboBitrates->itemText(i);
+            profileElement.setAttribute("bitrates", bitrateValues.join(","));
+        }
+        if (args.contains("%audiobitrate")) {
+            // profile has a variable bitrate
+            profileElement.setAttribute("defaultaudiobitrate", m_view.comboAudioBitrates->currentText());
+            QStringList bitrateValues;
+            for (int i = 0; i < m_view.comboAudioBitrates->count(); i++)
+                bitrateValues << m_view.comboAudioBitrates->itemText(i);
+            profileElement.setAttribute("audiobitrates", bitrateValues.join(","));
+        }
+
         profiles.appendChild(profileElement);
 
         //QCString save = doc.toString().utf8();
@@ -730,6 +773,9 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     if (!scriptExport) render_process_args << "-erase";
     if (KdenliveSettings::usekuiserver()) render_process_args << "-kuiserver";
 
+    // get process id
+    render_process_args << QString("-pid:%1").arg(QCoreApplication::applicationPid());
+
     // Set locale for render process if required
     if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {
         render_process_args << QString("-locale:%1").arg(QLocale().name());
@@ -780,7 +826,9 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     if (!exportAudio) renderArgs.append(" an=1 ");
 
     // Set the thread counts
-    renderArgs.append(QString(" threads=%1").arg(KdenliveSettings::encodethreads()));
+    if (!renderArgs.contains("threads=")) {
+        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,
@@ -805,6 +853,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
 
     QScriptEngine sEngine;
     sEngine.globalObject().setProperty("bitrate", m_view.comboBitrates->currentText());
+    sEngine.globalObject().setProperty("audiobitrate", m_view.comboAudioBitrates->currentText());
     sEngine.globalObject().setProperty("dar", '@' + QString::number(m_profile.display_aspect_num) + '/' + QString::number(m_profile.display_aspect_den));
     sEngine.globalObject().setProperty("passes", static_cast<int>(m_view.checkTwoPass->isChecked()) + 1);
 
@@ -967,7 +1016,9 @@ void RenderWidget::startRendering(QTreeWidgetItem *item)
             item->setData(1, Qt::UserRole, i18n("Rendering crashed"));
             item->setIcon(0, KIcon("dialog-close"));
             item->setData(2, Qt::UserRole, 100);
-        } else KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", item->text(1)), QPixmap(), this);
+        } else {
+            KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", item->text(1)), QPixmap(), this);
+        }
     } else {
         // Script item
         if (QProcess::startDetached(item->data(1, Qt::UserRole + 3).toString()) == false) {
@@ -1256,6 +1307,7 @@ void RenderWidget::refreshParams()
     m_view.comboBitrates->clear();
     if (params.contains("bitrate")) {
         m_view.comboBitrates->setEnabled(true);
+        m_view.bitrateLabel->setEnabled(true);
         if ( item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
             QStringList bitrates = item->data(BitratesRole).toStringList();
             foreach (QString bitrate, bitrates)
@@ -1265,10 +1317,30 @@ void RenderWidget::refreshParams()
         }
     } else {
         m_view.comboBitrates->setEnabled(false);
+        m_view.bitrateLabel->setEnabled(false);
+    }
+
+    // setup comboBox with audiobitrates
+    m_view.comboAudioBitrates->clear();
+    if (params.contains("audiobitrate")) {
+        m_view.comboAudioBitrates->setEnabled(true);
+        m_view.audiobitrateLabel->setEnabled(true);
+        if ( item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
+            QStringList audiobitrates = item->data(AudioBitratesRole).toStringList();
+            foreach (QString bitrate, audiobitrates)
+                m_view.comboAudioBitrates->addItem(bitrate);
+            if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
+                m_view.comboAudioBitrates->setCurrentIndex(audiobitrates.indexOf(item->data(DefaultAudioBitrateRole).toString()));
+        }
+    } else {
+        m_view.comboAudioBitrates->setEnabled(false);
+        m_view.audiobitrateLabel->setEnabled(false);
     }
-
+    
     m_view.checkTwoPass->setEnabled(params.contains("passes"));
 
+    m_view.encoder_threads->setEnabled(!params.contains("threads="));
+
     m_view.buttonRender->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
     m_view.buttonGenerateScript->setEnabled(m_view.size_list->currentItem()->toolTip().isEmpty());
 }
@@ -1451,6 +1523,10 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             item->setData(RenderRole, "avformat");
             item->setData(StandardRole, standard);
             item->setData(ParamsRole, params);
+            item->setData(BitratesRole, profile.attribute("bitrates").split(',', QString::SkipEmptyParts));
+            item->setData(DefaultBitrateRole, profile.attribute("defaultbitrate"));
+            item->setData(AudioBitratesRole, profile.attribute("audiobitrates").split(',', QString::SkipEmptyParts));
+            item->setData(DefaultAudioBitrateRole, profile.attribute("defaultaudiobitrate"));
             if (profile.hasAttribute("url")) item->setData(ExtraRole, profile.attribute("url"));
             if (editable) {
                 item->setData(EditableRole, exportFile);
@@ -1472,7 +1548,7 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
     QString renderer;
     QString params;
     QString standard;
-    QString bitrates, defaultBitrate;
+    QString bitrates, defaultBitrate, audioBitrates, defaultAudioBitrate;
     KIcon icon;
 
     while (!groups.item(i).isNull()) {
@@ -1521,6 +1597,8 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             standard = profileElement.attribute("standard");
             bitrates = profileElement.attribute("bitrates");
             defaultBitrate = profileElement.attribute("defaultbitrate");
+            audioBitrates = profileElement.attribute("audiobitrates");
+            defaultAudioBitrate = profileElement.attribute("defaultaudiobitrate");
             params = profileElement.attribute("args");
 
             if (replaceVorbisCodec && params.contains("acodec=vorbis")) {
@@ -1543,6 +1621,8 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             item->setData(ParamsRole, params);
             item->setData(BitratesRole, bitrates.split(',', QString::SkipEmptyParts));
             item->setData(DefaultBitrateRole, defaultBitrate);
+            item->setData(AudioBitratesRole, audioBitrates.split(',', QString::SkipEmptyParts));
+            item->setData(DefaultAudioBitrateRole, defaultAudioBitrate);
             if (profileElement.hasAttribute("url")) item->setData(ExtraRole, profileElement.attribute("url"));
             if (editable) item->setData(EditableRole, exportFile);
             m_renderItems.append(item);