]> git.sesse.net Git - kdenlive/commitdiff
Check that the proxy has same length as original clip, otherwise mark it as "crashed...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 22 Apr 2011 15:31:13 +0000 (15:31 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 22 Apr 2011 15:31:13 +0000 (15:31 +0000)
svn path=/trunk/kdenlive/; revision=5545

src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/renderer.h

index c7aa40f8e6e1fc71bee91b762178f6c8f417117d..61eab3d0022de37a77b9d15705830bc36b7edd61 100644 (file)
@@ -844,7 +844,7 @@ void MainWindow::slotConnectMonitors()
     connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)));
 
     connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
-    connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &)));
+    connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
 
     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
 
index 83c1bcef13bae3d10383b4af44dffa797c25b300..3ca48c99b7d2b5af156a5b6dd3e3d6b9860af396 100644 (file)
@@ -1295,10 +1295,12 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace)
     }
 }
 
-void ProjectList::slotRemoveInvalidProxy(const QString &id)
+void ProjectList::slotRemoveInvalidProxy(const QString &id, bool durationError)
 {
     ProjectItem *item = getItemById(id);
     if (item) {
+        //TODO: use durationError to display correct message to user after 0.8 release
+        if (durationError) kDebug() << "Proxy duration is wrong, try changing transcoding parameters.";
         item->setProxyStatus(PROXYCRASHED);
         QString path = item->referencedClip()->getProperty("proxy");
         KUrl proxyFolder(m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/");
@@ -1619,6 +1621,8 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
                 QString proxydir = m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/";
                 QMap <QString, QString> newProps;
                 newProps.insert("proxy", proxydir + item->referencedClip()->getClipHash() + "." + m_doc->getDocumentProperty("proxyextension"));
+                // insert required duration for proxy
+                newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                 QMap <QString, QString> oldProps = clip->properties();
                 oldProps.insert("proxy", QString());
                 EditClipCommand *command = new EditClipCommand(this, clipId, oldProps, newProps, true);
@@ -2273,6 +2277,8 @@ void ProjectList::updateProxyConfig()
                 QMap <QString, QString> newProps;
                 newProps.insert("proxy", QString());
                 newProps.insert("replace", "1");
+                // insert required duration for proxy
+                newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                 new EditClipCommand(this, item->clipId(), item->referencedClip()->properties(), newProps, true, command);
             }
         }
@@ -2338,6 +2344,8 @@ void ProjectList::slotProxyCurrentItem(bool doProxy)
                     newProps.clear();
                     QString path = proxydir + item->referencedClip()->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension"));
                     newProps.insert("proxy", path);
+                    // insert required duration for proxy
+                    newProps.insert("proxy_out", item->referencedClip()->producerProperty("out"));
                     // We need to insert empty proxy so that undo will work
                     oldProps.insert("proxy", QString());
                 }
index 3028e7ab6e537683f6c90536692835773bafba1a..96214097ab8030b543799a454f79a2e41a43b680 100644 (file)
@@ -123,9 +123,17 @@ public:
                     color = option.palette.color(QPalette::WindowText);
                 }
                 else {
-                    if (proxy == CREATINGPROXY) proxyText = i18n("Generating proxy ...");
-                    else if (proxy == PROXYWAITING) proxyText = i18n("Waiting proxy ...");
-                    else if (proxy == PROXYCRASHED) proxyText = i18n("Proxy crashed");
+                    switch (proxy)  {
+                        case CREATINGPROXY:
+                            proxyText = i18n("Generating proxy ...");
+                            break;
+                        case PROXYWAITING:
+                            proxyText = i18n("Waiting proxy ...");
+                            break;
+                        case PROXYCRASHED:
+                        default:
+                            proxyText = i18n("Proxy crashed");
+                    }
                     brush = option.palette.highlight();
                     color = option.palette.color(QPalette::HighlightedText);
                 }
@@ -218,7 +226,7 @@ public slots:
     void slotRefreshClipThumbnail(const QString &clipId, bool update = true);
     void slotRefreshClipThumbnail(QTreeWidgetItem *item, bool update = true);
     void slotRemoveInvalidClip(const QString &id, bool replace);
-    void slotRemoveInvalidProxy(const QString &id);
+    void slotRemoveInvalidProxy(const QString &id, bool durationError);
     void slotSelectClip(const QString &ix);
 
     /** @brief Prepares removing the selected items. */
index c2e34f25f40b393696fb8e21938df07f78932230..646c5611802a116faeca0bdfc81dbb2fa00d1d08 100644 (file)
@@ -545,10 +545,17 @@ void Render::slotSplitView(bool doit)
 void Render::getFileProperties(const QDomElement xml, const QString &clipId, int imageHeight, bool replaceProducer, bool selectClip)
 {
     QString path;
-    if (xml.hasAttribute("proxy") && xml.attribute("proxy") != "-") path = xml.attribute("proxy");
-    else path = xml.attribute("resource");
-    
-    
+    bool proxyProducer;
+    if (xml.hasAttribute("proxy") && xml.attribute("proxy") != "-") {
+        path = xml.attribute("proxy");
+        proxyProducer = true;
+    }
+    else {
+        path = xml.attribute("resource");
+        proxyProducer = false;
+    }
+
+
     KUrl url = KUrl(path);
     Mlt::Producer *producer = NULL;
     CLIPTYPE type = (CLIPTYPE)xml.attribute("type").toInt();
@@ -576,17 +583,23 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         producer = new Mlt::Producer(*m_mltProfile, url.path().toUtf8().constData());
     }
 
+
     if (producer == NULL || producer->is_blank() || !producer->is_valid()) {
         kDebug() << " / / / / / / / / ERROR / / / / // CANNOT LOAD PRODUCER: ";
-        if (xml.hasAttribute("proxy") && xml.attribute("proxy") != "-") {
+        if (proxyProducer) {
             // Proxy file is corrupted
-            emit removeInvalidProxy(clipId);
+            emit removeInvalidProxy(clipId, false);
         }
         else emit removeInvalidClip(clipId, replaceProducer);
         delete producer;
         return;
     }
 
+    if (proxyProducer && xml.hasAttribute("proxy_out") && producer->get_out() != xml.attribute("proxy_out").toInt()) {
+        // Proxy file length is different than original clip length, this will corrupt project so disable this proxy clip
+        emit removeInvalidProxy(clipId, true);
+    }
+
     if (xml.hasAttribute("force_aspect_ratio")) {
         double aspect = xml.attribute("force_aspect_ratio").toDouble();
         if (aspect > 0) producer->set("force_aspect_ratio", aspect);
@@ -636,11 +649,11 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         int full_luma = xml.attribute("full_luma").toInt();
         if (full_luma != 0) producer->set("set.force_full_luma", full_luma);
     }
-    
+
     int clipOut = 0;
     int duration = 0;
     if (xml.hasAttribute("out")) clipOut = xml.attribute("out").toInt();
-    
+
     // setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger
     if (type == COLOR || type == TEXT || type == IMAGE || type == SLIDESHOW) {
         int length;
@@ -762,7 +775,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
                     variance = KThumb::imageVariance(image);
                 } else
                     pix.fill(Qt::black);
-                
+
                 if (frameNumber == 0 && variance < 6) {
                     // Thumbnail is not interesting (for example all black, seek to fetch better thumb
                     frameNumber = 100;
index 86b0b928e0167a48860e5308cf13d46037c7c713..69626224bb5bb16c53b7968fd655d60c153b11b1 100644 (file)
@@ -358,8 +358,11 @@ signals:
     void rendererStopped(int);
     /** @brief The clip is not valid, should be removed from project. */
     void removeInvalidClip(const QString &, bool replaceProducer);
-    /** @brief The proxy is not valid, should be deleted. */
-    void removeInvalidProxy(const QString &);
+    /** @brief The proxy is not valid, should be deleted.
+     *  @param id The original clip's id
+     *  @param durationError Should be set to true if the proxy failed because it has not same length as original clip
+     */
+    void removeInvalidProxy(const QString &id, bool durationError);
     void refreshDocumentProducers();
 
     /** @brief A frame's image has to be shown.