From d4eba74b4e5bf7febef259fd83cf6516d233bc8f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 27 Nov 2011 19:55:54 +0100 Subject: [PATCH] Some cleanup in proxy creation --- src/projectlist.cpp | 101 +++++++++++++++++++++++++------------------- src/renderer.cpp | 5 +++ src/renderer.h | 1 + 3 files changed, 64 insertions(+), 43 deletions(-) diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 5ce8e42d..50ba864f 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1888,7 +1888,8 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce if (queue == 0) { monitorItemEditing(true); if (item && m_thumbnailQueue.isEmpty()) { - m_listView->setCurrentItem(item); + if (!item->hasProxy() || m_render->activeClipId() == item->clipId()) + m_listView->setCurrentItem(item); bool updatedProfile = false; if (item->parent()) { if (item->parent()->type() == PROJECTFOLDERTYPE) @@ -2385,12 +2386,14 @@ void ProjectList::slotAbortProxy(const QString id, const QString path) { QTreeWidgetItemIterator it(m_listView); ProjectItem *item = getItemById(id); - setProxyStatus(item, NOPROXY); - slotGotProxy(item); if (!path.isEmpty() && m_processingProxy.contains(path)) { m_abortProxy << path; setProxyStatus(item, NOPROXY); } + else { + setProxyStatus(item, NOPROXY); + slotGotProxy(item); + } } void ProjectList::slotGenerateProxy() @@ -2401,7 +2404,7 @@ void ProjectList::slotGenerateProxy() if (m_abortProxy.contains(info.dest)) { m_abortProxy.removeAll(info.dest); continue; - } + } // Get the list of clips that will need to get progress info QTreeWidgetItemIterator it(m_listView); QList processingItems; @@ -2581,7 +2584,6 @@ void ProjectList::slotGenerateProxy() } else continue; result = -2; - } else { QString log = QString(myProcess.readAll()); @@ -2597,7 +2599,7 @@ void ProjectList::slotGenerateProxy() } // FFmpeg process terminated normally, but make sure proxy clip exists - if (QFileInfo(info.dest).size() == 0) { + if (result != -2 && QFileInfo(info.dest).size() == 0) { result = QProcess::CrashExit; } @@ -2715,58 +2717,71 @@ void ProjectList::slotProxyCurrentItem(bool doProxy, ProjectItem *itemToProxy) QList list; if (itemToProxy == NULL) list = m_listView->selectedItems(); else list << itemToProxy; + + // expand list (folders, subclips) to get real clips QTreeWidgetItem *listItem; - QUndoCommand *command = new QUndoCommand(); - if (doProxy) command->setText(i18np("Add proxy clip", "Add proxy clips", list.count())); - else command->setText(i18np("Remove proxy clip", "Remove proxy clips", list.count())); - - // Make sure the proxy folder exists - QString proxydir = m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/"; - KStandardDirs::makeDir(proxydir); - - QMap newProps; - QMap oldProps; - if (!doProxy) newProps.insert("proxy", "-"); + QList clipList; for (int i = 0; i < list.count(); i++) { listItem = list.at(i); if (listItem->type() == PROJECTFOLDERTYPE) { for (int j = 0; j < listItem->childCount(); j++) { QTreeWidgetItem *sub = listItem->child(j); - if (!list.contains(sub)) list.append(sub); + if (sub->type() == PROJECTCLIPTYPE) { + ProjectItem *item = static_cast (sub); + if (!clipList.contains(item)) clipList.append(item); + } } } else if (listItem->type() == PROJECTSUBCLIPTYPE) { QTreeWidgetItem *sub = listItem->parent(); - if (!list.contains(sub)) list.append(sub); + ProjectItem *item = static_cast (sub); + if (!clipList.contains(item)) clipList.append(item); } else if (listItem->type() == PROJECTCLIPTYPE) { ProjectItem *item = static_cast (listItem); - CLIPTYPE t = item->clipType(); - if ((t == VIDEO || t == AV || t == UNKNOWN || t == IMAGE || t == PLAYLIST) && item->referencedClip()) { - if ((doProxy && item->hasProxy()) || (!doProxy && !item->hasProxy() && item->referencedClip()->getProducer() != NULL)) continue; - DocClipBase *clip = item->referencedClip(); - if (!clip || !clip->isClean() || m_render->isProcessing(item->clipId())) { - kDebug()<<"//// TRYING TO PROXY: "<clipId()<<", but it is busy"; - continue; - } + if (!clipList.contains(item)) clipList.append(item); + } + } + + QUndoCommand *command = new QUndoCommand(); + if (doProxy) command->setText(i18np("Add proxy clip", "Add proxy clips", clipList.count())); + else command->setText(i18np("Remove proxy clip", "Remove proxy clips", clipList.count())); + + // Make sure the proxy folder exists + QString proxydir = m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/"; + KStandardDirs::makeDir(proxydir); - resetThumbsProducer(clip); - oldProps = clip->properties(); - if (doProxy) { - newProps.clear(); - QString path = proxydir + clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension")); - // insert required duration for proxy - newProps.insert("proxy_out", clip->producerProperty("out")); - newProps.insert("proxy", path); - // We need to insert empty proxy so that undo will work - oldProps.insert("proxy", QString()); - } - else if (item->referencedClip()->getProducer() == NULL) { - // Force clip reload - newProps.insert("resource", item->referencedClip()->getProperty("resource")); - } - new EditClipCommand(this, item->clipId(), oldProps, newProps, true, command); + QMap newProps; + QMap oldProps; + if (!doProxy) newProps.insert("proxy", "-"); + for (int i = 0; i < clipList.count(); i++) { + ProjectItem *item = clipList.at(i); + CLIPTYPE t = item->clipType(); + if ((t == VIDEO || t == AV || t == UNKNOWN || t == IMAGE || t == PLAYLIST) && item->referencedClip()) { + if ((doProxy && item->hasProxy()) || (!doProxy && !item->hasProxy() && item->referencedClip()->getProducer() != NULL)) continue; + DocClipBase *clip = item->referencedClip(); + if (!clip || !clip->isClean() || m_render->isProcessing(item->clipId())) { + kDebug()<<"//// TRYING TO PROXY: "<clipId()<<", but it is busy"; + continue; + } + + resetThumbsProducer(clip); + oldProps = clip->properties(); + if (doProxy) { + newProps.clear(); + QString path = proxydir + clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension")); + // insert required duration for proxy + newProps.insert("proxy_out", clip->producerProperty("out")); + newProps.insert("proxy", path); + // We need to insert empty proxy so that undo will work + oldProps.insert("proxy", QString()); + } + else if (item->referencedClip()->getProducer() == NULL) { + // Force clip reload + kDebug()<<"// CLIP HAD NULL PROD------------"; + newProps.insert("resource", item->referencedClip()->getProperty("resource")); } + new EditClipCommand(this, item->clipId(), oldProps, newProps, true, command); } } if (command->childCount() > 0) { diff --git a/src/renderer.cpp b/src/renderer.cpp index ea95bf53..272acaf5 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -4186,6 +4186,11 @@ Mlt::Producer* Render::getProducer() return m_mltProducer; } +const QString Render::activeClipId() +{ + if (m_mltProducer) return m_mltProducer->get("id"); + return QString(); +} #include "renderer.moc" diff --git a/src/renderer.h b/src/renderer.h index 34a516ab..809fc4fb 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -303,6 +303,7 @@ Q_OBJECT public: Mlt::Tractor *lockService(); /** @brief Unlock the MLT service */ void unlockService(Mlt::Tractor *tractor); + const QString activeClipId(); private: -- 2.39.2