Commit 37ae2ece authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Check that the proxy has same length as original clip, otherwise mark it as...

Check that the proxy has same length as original clip, otherwise mark it as "crashed" and delete is because that would corrupt our timeline

svn path=/trunk/kdenlive/; revision=5545
parent 3615422b
......@@ -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)));
......
......@@ -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());
}
......
......@@ -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. */
......
......@@ -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;
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment