Commit 7e511e09 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix clip proxy on autorotate

BUG: 397762
parent 5dec8103
......@@ -281,6 +281,13 @@ void ProjectClip::reloadProducer(bool refreshOnly)
if (refreshOnly) {
// set a special flag to request thumbnail only
xml.setAttribute(QStringLiteral("refreshOnly"), QStringLiteral("1"));
} else {
bin()->discardJobs(m_id, AbstractClipJob::PROXYJOB);
if (hasProxy()) {
// If we have a proxy, delete it
xml.setAttribute(QStringLiteral("overwriteproxy"), QStringLiteral("1"));
setProducerProperty(QStringLiteral("_overwriteproxy"), QStringLiteral("1"));
}
}
bin()->reloadProducer(m_id, xml);
}
......@@ -629,7 +636,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
bin()->emitItemUpdated(this);
refreshPanel = true;
}
timelineProperties << QStringLiteral("force_aspect_ratio") << QStringLiteral("video_index") << QStringLiteral("audio_index") << QStringLiteral("set.force_full_luma") << QStringLiteral("full_luma") << QStringLiteral("threads") << QStringLiteral("force_colorspace") << QStringLiteral("force_tff") << QStringLiteral("force_progressive") << QStringLiteral("force_fps");
timelineProperties << QStringLiteral("force_aspect_ratio") << QStringLiteral("video_index") << QStringLiteral("audio_index") << QStringLiteral("set.force_full_luma") << QStringLiteral("full_luma") << QStringLiteral("threads") << QStringLiteral("force_colorspace") << QStringLiteral("force_tff") << QStringLiteral("force_progressive") << QStringLiteral("force_fps") << QStringLiteral("autorotate");
QStringList keys;
keys << QStringLiteral("luma_duration") << QStringLiteral("luma_file") << QStringLiteral("fade") << QStringLiteral("ttl") << QStringLiteral("softness") << QStringLiteral("crop") << QStringLiteral("animation");
while (i.hasNext()) {
......@@ -663,10 +670,9 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
}
} else if (properties.contains(QStringLiteral("resource")) || properties.contains(QStringLiteral("templatetext")) || properties.contains(QStringLiteral("autorotate"))) {
// Clip resource changed, update thumbnail
reload = true;
if (m_type != Color) {
reloadProducer();
} else {
reload = true;
refreshOnly = false;
}
}
if (properties.contains(QStringLiteral("xmldata")) || !passProperties.isEmpty()) {
......
......@@ -143,6 +143,8 @@ void Core::initialize(const QString &mltPath)
m_producerQueue = new ProducerQueue(m_binController);
connect(m_producerQueue, SIGNAL(gotFileProperties(requestClipInfo, ClipController *)), m_binWidget, SLOT(slotProducerReady(requestClipInfo, ClipController *)), Qt::DirectConnection);
connect(m_producerQueue, &ProducerQueue::replyGetImage, m_binWidget, &Bin::slotThumbnailReady);
connect(m_producerQueue, &ProducerQueue::requestProxy,
[this](const QString &id){ m_binWidget->startJob(id, AbstractClipJob::PROXYJOB);});
connect(m_producerQueue, &ProducerQueue::removeInvalidClip, m_binWidget, &Bin::slotRemoveInvalidClip, Qt::DirectConnection);
connect(m_producerQueue, SIGNAL(addClip(QString, QMap<QString, QString>)), m_binWidget, SLOT(slotAddUrl(QString, QMap<QString, QString>)));
connect(m_binController, SIGNAL(createThumb(QDomElement, QString, int)), m_producerQueue, SLOT(getFileProperties(QDomElement, QString, int)));
......
......@@ -191,7 +191,7 @@ void ProducerQueue::processFileProperties()
} else {
path = proxy;
// Check for missing proxies
if (QFileInfo(path).size() <= 0) {
if (QFileInfo(path).size() <= 0 || info.xml.hasAttribute(QStringLiteral("overwriteproxy"))) {
// proxy is missing, re-create it
emit requestProxy(info.clipId);
proxyProducer = false;
......
......@@ -84,14 +84,18 @@ QStringList JobManager::getPendingJobs(const QString &id)
void JobManager::discardJobs(const QString &id, AbstractClipJob::JOBTYPE type)
{
QMutexLocker lock(&m_jobMutex);
bool jobFound = false;
for (int i = 0; i < m_jobList.count(); ++i) {
if (m_jobList.at(i)->clipId() == id && (type == AbstractClipJob::NOJOBTYPE || m_jobList.at(i)->jobType == type)) {
// discard this job
m_jobList.at(i)->setStatus(JobAborted);
jobFound = true;
}
}
emit updateJobStatus(id, type, JobAborted);
updateJobCount();
if (jobFound) {
emit updateJobStatus(id, type, JobAborted);
updateJobCount();
}
}
bool JobManager::hasPendingJob(const QString &clipId, AbstractClipJob::JOBTYPE type)
......
......@@ -173,6 +173,8 @@ void ProxyJob::startJob()
return;
}
QStringList parameters;
// Make sure we don't block when proxy file already exists
parameters << QStringLiteral("-y");
if (m_proxyParams.contains(QStringLiteral("-noautorotate"))) {
// The noautorotate flag must be passed before input source
parameters << QStringLiteral("-noautorotate");
......@@ -192,9 +194,6 @@ void ProxyJob::startJob()
}
}
}
// Make sure we don't block when proxy file already exists
parameters << QStringLiteral("-y");
parameters << m_dest;
m_jobProcess = new QProcess;
m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
......@@ -330,6 +329,10 @@ QHash<ProjectClip *, AbstractClipJob *> ProxyJob::prepareJob(Bin *bin, const QLi
for (int i = 0; i < clips.count(); i++) {
ProjectClip *item = clips.at(i);
QString id = item->clipId();
QString local_params = params;
if (item->getProducerProperty(QStringLiteral("autorotate")) == QStringLiteral("0")) {
local_params.append(QStringLiteral(" -noautorotate"));
}
QString path = item->getProducerProperty(QStringLiteral("kdenlive:proxy"));
if (path.isEmpty()) {
item->setJobStatus(AbstractClipJob::PROXYJOB, JobCrashed, -1, i18n("Failed to create proxy, empty path."));
......@@ -337,12 +340,13 @@ QHash<ProjectClip *, AbstractClipJob *> ProxyJob::prepareJob(Bin *bin, const QLi
}
// Reset proxy path until it is really created
item->setProducerProperty(QStringLiteral("kdenlive:proxy"), QString());
if (QFileInfo(path).size() > 0) {
if (item->getProducerIntProperty(QStringLiteral("_overwriteproxy")) == 0 && QFileInfo(path).size() > 0) {
// Proxy already created
item->setJobStatus(AbstractClipJob::PROXYJOB, JobDone);
bin->gotProxy(id, path);
continue;
}
item->setProducerProperty(QStringLiteral("_overwriteproxy"), QString());
QString sourcePath = item->url();
if (item->clipType() == Playlist) {
// Special case: playlists use the special 'consumer' producer to support resizing
......@@ -365,7 +369,7 @@ QHash<ProjectClip *, AbstractClipJob *> ProxyJob::prepareJob(Bin *bin, const QLi
}
}
qCDebug(KDENLIVE_LOG)<<" * *PROXY PATH: "<<path<<", "<<sourcePath;
parameters << path << sourcePath << item->getProducerProperty(QStringLiteral("_exif_orientation")) << params << QString::number(renderSize.width()) << QString::number(renderSize.height());
parameters << path << sourcePath << item->getProducerProperty(QStringLiteral("_exif_orientation")) << local_params << QString::number(renderSize.width()) << QString::number(renderSize.height());
ProxyJob *job = new ProxyJob(item->clipType(), id, parameters, playlist);
jobs.insert(item, job);
}
......
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