From 20d4364a78e758384f8b16fc5a697566e3ea278a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 12 Feb 2011 23:45:48 +0000 Subject: [PATCH] Check clips property before launching proxy creation so that we only proxy the HD clips svn path=/trunk/kdenlive/; revision=5396 --- src/kdenlivedoc.cpp | 2 + src/mainwindow.cpp | 8 ++ src/projectlist.cpp | 56 ++++++++---- src/projectlist.h | 4 + src/projectsettings.cpp | 22 ++++- src/projectsettings.h | 2 + src/widgets/projectsettings_ui.ui | 140 ++++++++++++++++++++---------- 7 files changed, 167 insertions(+), 67 deletions(-) diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 91d6a4a3..d3c400bc 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -76,6 +76,8 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup m_documentProperties["zoneout"] = "100"; m_documentProperties["enableproxy"] = QString::number((int) KdenliveSettings::enableproxy()); m_documentProperties["proxyparams"] = KdenliveSettings::proxyparams(); + m_documentProperties["generateproxy"] = QString::number((int) KdenliveSettings::enableproxy()); + m_documentProperties["proxyminsize"] = "1000"; if (!url.isEmpty()) { QString tmpFile; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7b99e596..0e3c59d8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1805,6 +1805,8 @@ void MainWindow::newFile(bool showProjectSettings, bool force) QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()); bool useProxy = KdenliveSettings::enableproxy(); QString proxyParams = KdenliveSettings::proxyparams(); + bool generateProxy = KdenliveSettings::enableproxy(); + int proxyMinSize = 1000; if (!showProjectSettings) { if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) @@ -1825,6 +1827,8 @@ void MainWindow::newFile(bool showProjectSettings, bool force) projectTracks = w->tracks(); useProxy = w->useProxy(); proxyParams = w->proxyParams(); + generateProxy = w->generateProxy(); + proxyMinSize = w->proxyMinSize(); delete w; } m_timelineArea->setEnabled(true); @@ -1832,6 +1836,8 @@ void MainWindow::newFile(bool showProjectSettings, bool force) KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this); doc->setDocumentProperty("useproxy", QString::number((int) useProxy)); doc->setDocumentProperty("proxyparams", proxyParams); + doc->setDocumentProperty("generateproxy", QString::number((int) generateProxy)); + doc->setDocumentProperty("proxyminsize", QString::number(proxyMinSize)); doc->m_autosave = new KAutoSaveFile(KUrl(), doc); bool ok; TrackView *trackView = new TrackView(doc, &ok, this); @@ -2226,6 +2232,8 @@ void MainWindow::slotEditProjectSettings() if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs(); if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile); m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams()); + m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy())); + m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize())); if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) { m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy())); slotUpdateProxySettings(); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index af471ae8..1c2834ec 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -585,7 +585,7 @@ void ProjectList::adjustProxyActions(ProjectItem *clip) const m_proxyAction->setEnabled(false); return; } - m_proxyAction->setEnabled(true); + m_proxyAction->setEnabled(useProxy()); m_proxyAction->blockSignals(true); m_proxyAction->setChecked(clip->hasProxy()); m_proxyAction->blockSignals(false); @@ -827,7 +827,7 @@ void ProjectList::updateButtons() const m_openAction->setEnabled(true); m_reloadAction->setEnabled(true); m_transcodeAction->setEnabled(true); - m_proxyAction->setEnabled(true); + m_proxyAction->setEnabled(useProxy()); return; } else if (item && item->type() == PROJECTFOLDERTYPE && item->childCount() > 0) { @@ -971,9 +971,10 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) CLIPTYPE t = clip->clipType(); if ((t == VIDEO || t == AV || t == UNKNOWN) && useProxy()) { if (clip->getProperty("proxy").isEmpty()) { - connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool))); - setProxyStatus(item, 1); - clip->generateProxy(m_doc->projectFolder(), proxyParams()); + + //connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool))); + //setProxyStatus(item, 1); + //clip->generateProxy(m_doc->projectFolder(), proxyParams()); } else { // Proxy clip already created @@ -983,13 +984,13 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) m_infoQueue.insert(clip->getId(), e); } } - else { + //else { // We don't use proxies // remove file_hash so that we load all properties for the clip QDomElement e = clip->toXML().cloneNode().toElement(); e.removeAttribute("file_hash"); m_infoQueue.insert(clip->getId(), e); - } + //} //m_render->getFileProperties(clip->toXML(), clip->getId(), true); } else if (!clip->getProperty("proxy").isEmpty()) { @@ -1562,9 +1563,20 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled); toReload = clipId; } - if (item->referencedClip()->getProperty("proxy").isEmpty()) setProxyStatus(item, 0); - item->referencedClip()->setProducer(producer, replace); - item->referencedClip()->askForAudioThumbs(); + if (!useProxy() && item->referencedClip()->getProperty("proxy").isEmpty()) setProxyStatus(item, 0); + QString type = properties.value("type"); + QString size = properties.value("frame_size"); + DocClipBase *clip = item->referencedClip(); + if (useProxy() && (type == "video" || type == "av") && generateProxy() && size.section('x', 0, 0).toInt() > proxyMinSize()) { + if (clip->getProperty("proxy").isEmpty()) { + connect(clip, SIGNAL(proxyReady(const QString&, bool)), this, SLOT(slotGotProxy(const QString&, bool))); + setProxyStatus(item, 1); + clip->generateProxy(m_doc->projectFolder(), proxyParams()); + + } + } + clip->setProducer(producer, replace); + clip->askForAudioThumbs(); if (!replace && item->data(0, Qt::DecorationRole).isNull()) requestClipThumbnail(clipId); if (!toReload.isEmpty()) @@ -1573,7 +1585,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce if (m_listView->isEnabled() && replace) { // update clip in clip monitor emit clipSelected(NULL); - emit clipSelected(item->referencedClip()); + emit clipSelected(clip); //TODO: Make sure the line below has no side effect toReload = clipId; } @@ -1675,6 +1687,16 @@ bool ProjectList::useProxy() const return m_doc->getDocumentProperty("enableproxy").toInt(); } +bool ProjectList::generateProxy() const +{ + return m_doc->getDocumentProperty("generateproxy").toInt(); +} + +int ProjectList::proxyMinSize() const +{ + return m_doc->getDocumentProperty("proxyminsize").toInt(); +} + QString ProjectList::proxyParams() const { return m_doc->getDocumentProperty("proxyparams").simplified(); @@ -1771,7 +1793,7 @@ void ProjectList::slotSelectClip(const QString &ix) m_deleteButton->defaultAction()->setEnabled(true); m_reloadAction->setEnabled(true); m_transcodeAction->setEnabled(true); - m_proxyAction->setEnabled(true); + m_proxyAction->setEnabled(useProxy()); if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp())); m_openAction->setEnabled(true); @@ -2028,11 +2050,13 @@ void ProjectList::updateProxyConfig() } CLIPTYPE t = item->clipType(); if ((t == VIDEO || t == AV || t == UNKNOWN) && item->referencedClip() != NULL) { - if (useProxy()) { + if (generateProxy() && useProxy()) { DocClipBase *clip = item->referencedClip(); - connect(clip, SIGNAL(proxyReady(const QString &, bool)), this, SLOT(slotGotProxy(const QString &, bool))); - setProxyStatus(item, 1); - clip->generateProxy(m_doc->projectFolder(), proxyParams()); + if (clip->getProperty("frame_size").section('x', 0, 0).toInt() > proxyMinSize()) { + connect(clip, SIGNAL(proxyReady(const QString &, bool)), this, SLOT(slotGotProxy(const QString &, bool))); + setProxyStatus(item, 1); + clip->generateProxy(m_doc->projectFolder(), proxyParams()); + } } else if (!item->referencedClip()->getProperty("proxy").isEmpty()) { // remove proxy diff --git a/src/projectlist.h b/src/projectlist.h index 198baee4..fb08f89e 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -196,6 +196,10 @@ public: bool useProxy() const; /** @brief proxy parameters for this project. */ QString proxyParams() const; + /** @brief Should we automatically create proxy clips for newly added clips. */ + bool generateProxy() const; + /** @brief Minimum clip width to create proxy. */ + int proxyMinSize() const; public slots: void setDocument(KdenliveDoc *doc); diff --git a/src/projectsettings.cpp b/src/projectsettings.cpp index 0fec99c7..f4ca1a0c 100644 --- a/src/projectsettings.cpp +++ b/src/projectsettings.cpp @@ -65,16 +65,22 @@ ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, in video_thumbs->setChecked(KdenliveSettings::videothumbnails()); audio_tracks->setValue(audiotracks); video_tracks->setValue(videotracks); - connect(enable_proxy, SIGNAL(toggled(bool)), proxy_params, SLOT(setVisible(bool))); + connect(enable_proxy, SIGNAL(toggled(bool)), proxy_box, SLOT(setEnabled(bool))); + connect(generate_proxy, SIGNAL(toggled(bool)), proxy_minsize, SLOT(setEnabled(bool))); + if (projectlist) { enable_proxy->setChecked(projectlist->useProxy()); + generate_proxy->setChecked(projectlist->generateProxy()); + proxy_minsize->setValue(projectlist->proxyMinSize()); proxy_params->setText(projectlist->proxyParams()); - proxy_params->setVisible(projectlist->useProxy()); + proxy_box->setEnabled(projectlist->useProxy()); } else { enable_proxy->setChecked(KdenliveSettings::enableproxy()); + generate_proxy->setChecked(KdenliveSettings::enableproxy()); + proxy_minsize->setValue(1000); proxy_params->setText(KdenliveSettings::proxyparams()); - proxy_params->setVisible(KdenliveSettings::enableproxy()); + proxy_box->setEnabled(KdenliveSettings::enableproxy()); } if (readOnlyTracks) { @@ -320,6 +326,16 @@ bool ProjectSettings::useProxy() const return enable_proxy->isChecked(); } +bool ProjectSettings::generateProxy() const +{ + return generate_proxy->isChecked(); +} + +int ProjectSettings::proxyMinSize() const +{ + return proxy_minsize->value(); +} + QString ProjectSettings::proxyParams() const { return proxy_params->toPlainText(); diff --git a/src/projectsettings.h b/src/projectsettings.h index 6442307b..9654d7fa 100644 --- a/src/projectsettings.h +++ b/src/projectsettings.h @@ -39,6 +39,8 @@ public: bool enableVideoThumbs() const; bool enableAudioThumbs() const; bool useProxy() const; + bool generateProxy() const; + int proxyMinSize() const; QString proxyParams() const; static QStringList extractPlaylistUrls(QString path); static QStringList extractSlideshowUrls(KUrl url); diff --git a/src/widgets/projectsettings_ui.ui b/src/widgets/projectsettings_ui.ui index 30b9cdcb..1d297ff3 100644 --- a/src/widgets/projectsettings_ui.ui +++ b/src/widgets/projectsettings_ui.ui @@ -6,8 +6,8 @@ 0 0 - 285 - 433 + 321 + 462 @@ -57,7 +57,7 @@ Settings - + @@ -65,10 +65,10 @@ - + - + Video Profile @@ -164,38 +164,42 @@ - - - - Video tracks - - - - - - - - - - Audio tracks - - - - - - - - - - Qt::Horizontal - - - - 67 - 20 - - - + + + + + + Video tracks + + + + + + + + + + Audio tracks + + + + + + + + + + Qt::Horizontal + + + + 67 + 20 + + + + + @@ -218,7 +222,7 @@ - + Qt::Horizontal @@ -231,6 +235,51 @@ + + + + Enable proxy clips + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + + + Generate proxy if clip larger than + + + + + + + pixels + + + 10000 + + + 1000 + + + + + + + + + @@ -244,16 +293,6 @@ - - - - Enable proxy clips - - - - - - @@ -407,6 +446,11 @@ + + KIntSpinBox + QSpinBox +
knuminput.h
+
KUrlRequester QFrame -- 2.39.2