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)));
}
}
-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/");
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);
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);
}
}
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());
}
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);
}
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. */
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();
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);
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;
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;
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.