Commits

Anonymous committed f2e2aa0

Make audio / video bitrate easily configurable in custom render profiles: http://kdenlive.org/mantis/view.php?id=3012

  • Participants
  • Parent commits f663bdd

Comments (0)

Files changed (3)

export/profiles.xml

 </group>
 
 <group name="WebM" renderer="avformat" extension="webm" type="av">
-  <profile name="WebM" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000" defaultbitrate="8000"
+  <profile name="WebM" bitrates="200,400,600,800,1000,2000,4000,6000,8000,10000,12000,18000,25000" defaultbitrate="8000"
           audiobitrates="64,128,192,256,384" defaultaudiobitrate="128" args="acodec=vorbis ab=%audiobitrate+'k' ar=44100 aq=50 vcodec=libvpx minrate=0 vb=%bitrate+'k' aspect=%dar maxrate=%bitrate*2+'k' g=120 qmax=42 qmin=10" />
 </group>
 

src/renderwidget.cpp

     ui.parameters->setText(arguments.join(" "));
     ui.extension->setText(m_view.size_list->currentItem()->data(ExtensionRole).toString());
     ui.profile_name->setFocus();
+    QListWidgetItem *item = m_view.size_list->currentItem();
+    if (ui.parameters->toPlainText().contains("%bitrate")) {
+        if ( item && item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
+            QStringList bitrates = item->data(BitratesRole).toStringList();
+	    ui.vbitrates_list->setText(bitrates.join(","));
+            if (item->data(DefaultBitrateRole).canConvert(QVariant::String))
+                ui.default_vbitrate->setValue(item->data(DefaultBitrateRole).toInt());
+        }
+    }
+    else ui.vbitrates->setHidden(true);
+    if (ui.parameters->toPlainText().contains("%audiobitrate")) {
+      if ( item && item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
+            QStringList bitrates = item->data(AudioBitratesRole).toStringList();
+	    ui.abitrates_list->setText(bitrates.join(","));
+            if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
+                ui.default_abitrate->setValue(item->data(DefaultAudioBitrateRole).toInt());
+        }
+    }
+    else ui.abitrates->setHidden(true);
 
     if (d->exec() == QDialog::Accepted && !ui.profile_name->text().simplified().isEmpty()) {
         QString newProfileName = ui.profile_name->text().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(","));
+            profileElement.setAttribute("defaultbitrate", QString::number(ui.default_vbitrate->value()));
+            profileElement.setAttribute("bitrates", ui.vbitrates_list->text());
         }
         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(","));
+            profileElement.setAttribute("defaultaudiobitrate", QString::number(ui.default_abitrate->value()));
+            profileElement.setAttribute("audiobitrates", ui.abitrates_list->text());
         }
         doc.appendChild(profileElement);
         saveProfile(doc.documentElement());
     ui.extension->setText(extension);
     ui.parameters->setText(params);
     ui.profile_name->setFocus();
+    if (ui.parameters->toPlainText().contains("%bitrate")) {
+        if ( item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
+            QStringList bitrates = item->data(BitratesRole).toStringList();
+	    ui.vbitrates_list->setText(bitrates.join(","));
+            if (item->data(DefaultBitrateRole).canConvert(QVariant::String))
+                ui.default_vbitrate->setValue(item->data(DefaultBitrateRole).toInt());
+        }
+    }
+    else ui.vbitrates->setHidden(true);
+    if (ui.parameters->toPlainText().contains("%audiobitrate")) {
+      if ( item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
+            QStringList bitrates = item->data(AudioBitratesRole).toStringList();
+	    ui.abitrates_list->setText(bitrates.join(","));
+            if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
+                ui.default_abitrate->setValue(item->data(DefaultAudioBitrateRole).toInt());
+        }
+    }
+    else ui.abitrates->setHidden(true);
+    
     d->setWindowTitle(i18n("Edit Profile"));
     if (d->exec() == QDialog::Accepted) {
         slotDeleteProfile(false);
         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(","));
+	    profileElement.setAttribute("defaultbitrate", QString::number(ui.default_vbitrate->value()));
+            profileElement.setAttribute("bitrates", ui.vbitrates_list->text());
         }
         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(","));
+	    profileElement.setAttribute("defaultaudiobitrate", QString::number(ui.default_abitrate->value()));
+            profileElement.setAttribute("audiobitrates", ui.abitrates_list->text());
         }
 
         profiles.appendChild(profileElement);
     QStringList paramsList = renderArgs.split(' ', QString::SkipEmptyParts);
 
     QScriptEngine sEngine;
-    sEngine.globalObject().setProperty("bitrate", m_view.comboBitrates->currentText());
-    sEngine.globalObject().setProperty("audiobitrate", m_view.comboAudioBitrates->currentText());
+    sEngine.globalObject().setProperty("bitrate", m_view.comboBitrates->currentText().toInt());
+    sEngine.globalObject().setProperty("audiobitrate", m_view.comboAudioBitrates->currentText().toInt());
     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);
 

src/widgets/saveprofile_ui.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>249</width>
-    <height>229</height>
+    <width>329</width>
+    <height>495</height>
    </rect>
   </property>
   <property name="windowTitle">
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="2">
-    <widget class="KComboBox" name="destination_list"/>
+   <item row="6" column="0" colspan="3">
+    <widget class="QGroupBox" name="vbitrates">
+     <property name="title">
+      <string>Video</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_2">
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_7">
+        <property name="text">
+         <string>Default bitrate</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="KLineEdit" name="vbitrates_list"/>
+      </item>
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_6">
+        <property name="text">
+         <string>Bitrates</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QSpinBox" name="default_vbitrate">
+        <property name="maximum">
+         <number>500000</number>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="8" column="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="0" colspan="3">
+    <widget class="KTextEdit" name="parameters">
+     <property name="readOnly">
+      <bool>false</bool>
+     </property>
+     <property name="acceptRichText">
+      <bool>false</bool>
+     </property>
+    </widget>
    </item>
    <item row="1" column="0">
     <widget class="QLabel" name="label_2">
      </property>
     </widget>
    </item>
-   <item row="1" column="1" colspan="2">
-    <widget class="KLineEdit" name="group_name"/>
-   </item>
    <item row="2" column="0">
     <widget class="QLabel" name="label_3">
      <property name="text">
      </property>
     </widget>
    </item>
+   <item row="0" column="1" colspan="2">
+    <widget class="KComboBox" name="destination_list"/>
+   </item>
+   <item row="4" column="0" colspan="3">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Parameters</string>
+     </property>
+    </widget>
+   </item>
    <item row="2" column="1" colspan="2">
     <widget class="KLineEdit" name="profile_name"/>
    </item>
      </property>
     </widget>
    </item>
-   <item row="4" column="0" colspan="3">
-    <widget class="QLabel" name="label">
-     <property name="text">
-      <string>Parameters</string>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="0" colspan="3">
-    <widget class="KTextEdit" name="parameters">
-     <property name="readOnly">
-      <bool>false</bool>
-     </property>
-     <property name="acceptRichText">
-      <bool>false</bool>
-     </property>
-    </widget>
+   <item row="1" column="1" colspan="2">
+    <widget class="KLineEdit" name="group_name"/>
    </item>
-   <item row="6" column="2">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   <item row="7" column="0" colspan="3">
+    <widget class="QGroupBox" name="abitrates">
+     <property name="title">
+      <string>Audio</string>
      </property>
+     <layout class="QGridLayout" name="gridLayout_3">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label_8">
+        <property name="text">
+         <string>Bitrates</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0">
+       <widget class="QLabel" name="label_9">
+        <property name="text">
+         <string>Default bitrate</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="KLineEdit" name="abitrates_list"/>
+      </item>
+      <item row="3" column="1">
+       <widget class="QSpinBox" name="default_abitrate">
+        <property name="maximum">
+         <number>500000</number>
+        </property>
+       </widget>
+      </item>
+     </layout>
+     <zorder>label_9</zorder>
+     <zorder>label_8</zorder>
+     <zorder>abitrates_list</zorder>
+     <zorder>label_9</zorder>
+     <zorder>label_8</zorder>
+     <zorder>abitrates_list</zorder>
+     <zorder>default_abitrate</zorder>
     </widget>
    </item>
   </layout>
  </widget>
  <customwidgets>
   <customwidget>
-   <class>KLineEdit</class>
-   <extends>QLineEdit</extends>
-   <header>klineedit.h</header>
-  </customwidget>
-  <customwidget>
    <class>KComboBox</class>
    <extends>QComboBox</extends>
    <header>kcombobox.h</header>
   </customwidget>
   <customwidget>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
+  <customwidget>
    <class>KTextEdit</class>
    <extends>QTextEdit</extends>
    <header>ktextedit.h</header>