]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
small cleanup
[kdenlive] / src / projectlist.cpp
index 4a22c0a11ed19354fdcafb9f85f5feeb5dbf58c7..cb78f0684ae6e337bb05334db4af4e71e058c819 100644 (file)
@@ -1594,6 +1594,10 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr
                         resetThumbsProducer(clip);
                        m_render->getFileProperties(xml, clip->getId(), m_listView->iconSize().height(), replace);
                     }
+                    else if (item->numReferences() > 0) {
+                       // In some cases, like slowmotion clips, the producer is not loaded automatically be MLT
+                       m_render->getFileProperties(xml, clip->getId(), m_listView->iconSize().height(), replace);
+                   }
                 }
                 else if (clip->isPlaceHolder()) {
                     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
@@ -2191,6 +2195,37 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
     }
 }
 
+void ProjectList::extractMetadata(DocClipBase *clip)
+{
+    QMap <QString, QString> props = clip->properties();
+    if (props.contains("exiftool")) {
+       // metadata was already extracted
+       return;
+    }
+    QString codecid = props.value("videocodecid").simplified();
+    if (codecid == "h264") {
+       QProcess p;
+       QStringList args;
+       args << "-g" << "-args" << clip->fileURL().encodedPathAndQuery();
+       p.start("exiftool", args);
+       p.waitForFinished();
+       QString res = p.readAllStandardOutput();
+       QStringList list = res.split("\n");
+       QMap <QString, QString> meta;
+       foreach(QString tagline, list) {
+           if (!tagline.startsWith("-H264")) continue;
+           QString tag = tagline.section(':', 1);
+           if (tag.startsWith("ImageWidth") || tag.startsWith("ImageHeight")) continue;
+           meta.insert(tag.section('=', 0, 0), tag.section('=', 1));
+       }
+       clip->setProperty("exiftool", "1");
+       if (!meta.isEmpty()) {
+           clip->setMetadata(meta);
+           //checkCamcorderFilters(clip, meta);
+       }
+    }
+}
+
 
 void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace)
 {
@@ -2208,6 +2243,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         }
         item->setProperties(properties, metadata);
         clip->setProducer(producer, replace);
+       if (KdenliveSettings::use_exiftool()) extractMetadata(clip);
        m_render->processingDone(clipId);
 
         // Proxy stuff
@@ -2265,6 +2301,9 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             } else if (KdenliveSettings::checkfirstprojectclip() &&  m_listView->topLevelItemCount() == 1 && m_refreshed && m_allClipsProcessed) {
                 // this is the first clip loaded in project, check if we want to adjust project settings to the clip
                 updatedProfile = adjustProjectProfileToItem(item);
+               if (updatedProfile == false) {
+                   emit clipSelected(item->referencedClip());
+               }
             }
             if (updatedProfile == false) {
                 //emit clipSelected(item->referencedClip());
@@ -3729,4 +3768,20 @@ void ProjectList::slotGotFilterJobResults(QString id, int , int , stringMap resu
 }
 
 
+/*
+// Work in progress: apply filter based on clip's camcorder
+void ProjectList::checkCamcorderFilters(DocClipBase *clip, QMap <QString, QString> meta)
+{
+    KConfig conf("camcorderfilters.rc", KConfig::CascadeConfig, "appdata");
+    QStringList groups = conf.groupList();
+    foreach(QString grp, groups) {
+       if (!meta.contains(grp)) continue;
+       KConfigGroup group(&conf, grp);
+       QString value = group.readEntry(meta.value(grp));
+       if (value.isEmpty()) continue;
+       clip->setProperty(value.section(' ', 0, 0), value.section(' ', 1));
+       break;
+    }
+}*/
+
 #include "projectlist.moc"