]> git.sesse.net Git - kdenlive/commitdiff
Allow to analyse only a zone of a clip
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 5 Nov 2012 10:58:06 +0000 (11:58 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 5 Nov 2012 10:58:06 +0000 (11:58 +0100)
src/projectlist.cpp
src/projecttree/meltjob.cpp
src/widgets/scenecutdialog_ui.ui

index 231e6e4f7a78e4ffeb76f31de44d0febe862cbc8..42a93190d0add61a22b9cb39d694811a4b0bd9eb 100644 (file)
@@ -3516,6 +3516,10 @@ void ProjectList::startClipFilterJob(const QString &filterName, const QString &c
        extraParams.insert("projecttreefilter", "1");
        QString keyword("%count");
        extraParams.insert("resultmessage", i18n("Found %1 scenes.", keyword));
+       if (ui.zone_only->isChecked()) {
+           // We want to create markers
+           extraParams.insert("zoneonly", "1");
+       }
        if (ui.add_markers->isChecked()) {
            // We want to create markers
            extraParams.insert("addmarkers", QString::number(ui.marker_type->currentIndex()));
@@ -3556,6 +3560,13 @@ void ProjectList::processClipJob(QStringList ids, const QString&destination, boo
         ProjectItem *item = getItemById(id);
         if (!item) continue;
        QStringList jobArgs;
+       if (extraParams.contains("zoneonly")) {
+           // Analyse clip zone only, remove in / out and replace with zone
+           preParams.takeFirst();
+           preParams.takeFirst();
+           QPoint zone = item->referencedClip()->zone();
+           jobArgs << QString::number(zone.x()) << QString::number(zone.y());
+       }
        jobArgs << preParams;
         if (ids.count() == 1) {
             jobArgs << consumer + ':' + destination;
@@ -3647,6 +3658,7 @@ void ProjectList::slotGotFilterJobResults(QString id, int , int , stringMap resu
     }
     bool dataProcessed = false;
     QString key = filterInfo.value("key");
+    int offset = filterInfo.value("offset").toInt();
     QStringList value = results.value(key).split(';', QString::SkipEmptyParts);
     kDebug()<<"// RESULT; "<<key<<" = "<<value;
     if (filterInfo.contains("resultmessage")) {
@@ -3666,7 +3678,7 @@ void ProjectList::slotGotFilterJobResults(QString id, int , int , stringMap resu
            int newPos = pos.section("=", 0, 0).toInt();
            // Don't use scenes shorter than 1 second
            if (newPos - cutPos < 24) continue;
-           (void) new AddClipCutCommand(this, id, cutPos, newPos, QString(), true, false, command);
+           (void) new AddClipCutCommand(this, id, cutPos + offset, newPos + offset, QString(), true, false, command);
            cutPos = newPos;
        }
        if (command->childCount() == 0)
@@ -3686,7 +3698,7 @@ void ProjectList::slotGotFilterJobResults(QString id, int , int , stringMap resu
            int newPos = pos.section("=", 0, 0).toInt();
            // Don't use scenes shorter than 1 second
            if (newPos - cutPos < 24) continue;
-           CommentedTime m(GenTime(newPos, m_fps), QString::number(index), markersType);
+           CommentedTime m(GenTime(newPos + offset, m_fps), QString::number(index), markersType);
            markersList << m;
            index++;
            cutPos = newPos;
index 5592607709d81d5c365a1343bf0d35c5e7ba3abc..1bc16c69370b272fc4f49fd6c64c02c50224ee54 100644 (file)
@@ -67,6 +67,7 @@ void MeltJob::startJob()
         return;
     }
     int in = m_params.takeFirst().toInt();
+    if (in > 0 && !m_extra.contains("offset")) m_extra.insert("offset", QString::number(in));
     int out = m_params.takeFirst().toInt();
     QString producerParams =m_params.takeFirst(); 
     QString filter = m_params.takeFirst();
@@ -97,11 +98,13 @@ void MeltJob::startJob()
     }
     if (out == -1) {
        prod = new Mlt::Producer(*m_profile,  m_url.toUtf8().constData());
+       m_length = prod->get_length();
     }
     else {
        Mlt::Producer *tmp = new Mlt::Producer(*m_profile,  m_url.toUtf8().constData());
         prod = tmp->cut(in, out);
        delete tmp;
+       m_length = prod->get_playtime();
     }
     if (m_extra.contains("producer_profile")) {
        m_profile->from_producer(*prod);
@@ -150,7 +153,6 @@ void MeltJob::startJob()
     Mlt::Playlist playlist;
     playlist.append(*prod);
     tractor.set_track(playlist, 0);
-    m_length = prod->get_length();
     m_consumer->connect(tractor);
     prod->set_speed(0);
     prod->seek(0);
index 462ff597d9d62498c51382cf282a19456e849b73..371acaf4896f53ef81aab6e6c23ae72e4dfdf2a1 100644 (file)
@@ -6,36 +6,16 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>352</width>
-    <height>90</height>
+    <width>282</width>
+    <height>115</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Scene Cut</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="3" column="0" colspan="3">
-    <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="2" column="1">
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>218</width>
-       <height>2</height>
-      </size>
-     </property>
-    </spacer>
+   <item row="0" column="1" colspan="2">
+    <widget class="QComboBox" name="marker_type"/>
    </item>
    <item row="0" column="0">
     <widget class="QCheckBox" name="add_markers">
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="2">
-    <widget class="QComboBox" name="marker_type"/>
+   <item row="2" column="0" colspan="3">
+    <widget class="QCheckBox" name="zone_only">
+     <property name="text">
+      <string>Analyse only selected zone</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0" colspan="3">
+    <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="1" column="0" colspan="3">
     <widget class="QCheckBox" name="cut_scenes">
      </property>
     </widget>
    </item>
+   <item row="3" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <resources/>