]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Speed up automatic scene detection (still very slow but better)
[kdenlive] / src / projectlist.cpp
index 231e6e4f7a78e4ffeb76f31de44d0febe862cbc8..a8e11723a0268c490bf32bb98f9d0421f39d5f07 100644 (file)
@@ -3508,14 +3508,24 @@ void ProjectList::startClipFilterJob(const QString &filterName, const QString &c
        // Producer params
        jobParams << QString();
        // Filter params, use a smaller region of the image to speed up operation
-       jobParams << filterName << "bounding=\"25%x25%:15%x15\" shot_change_list=0 denoise=0";
+       // In fact, it's faster to rescale whole image than using part of it (bounding=\"25%x25%:15%x15\")
+       jobParams << filterName << "shot_change_list=0 denoise=0";
        // Consumer
-       jobParams << "null" << "all=1 terminate_on_pause=1 real_time=-1";
+       jobParams << "null" << "all=1 terminate_on_pause=1 real_time=-1 rescale=nearest deinterlace_method=onefield top_field_first=-1";
        QMap <QString, QString> extraParams;
        extraParams.insert("key", "shot_change_list");
        extraParams.insert("projecttreefilter", "1");
        QString keyword("%count");
        extraParams.insert("resultmessage", i18n("Found %1 scenes.", keyword));
+       extraParams.insert("resize_profile", "160");
+       if (ui.store_data->isChecked()) {
+           // We want to save result as clip metadata
+           extraParams.insert("storedata", "1");
+       }
+       if (ui.zone_only->isChecked()) {
+           // We want to analyze only clip zone
+           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 +3566,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 +3664,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 +3684,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 +3704,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;