Commit 9564b409 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fixes for external proxies.

CCBUG: 455140
parent bc8c8f83
......@@ -513,6 +513,41 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool gene
qDebug() << "################### ProjectClip::setproducer #################";
QMutexLocker locker(&m_producerMutex);
FileStatus::ClipStatus currentStatus = m_clipStatus;
bool skipProducer = false;
if (pCore->currentDoc()->useExternalProxy()) {
QStringList externalParams = pCore->currentDoc()->getDocumentProperty(QStringLiteral("externalproxyparams")).split(QLatin1Char(';'));
// We have a camcorder profile, check if we have opened a proxy clip
QString path = producer->get("resource");
if (QFileInfo(path).isRelative()) {
path.prepend(pCore->currentDoc()->documentRoot());
producer->set("resource", path.toUtf8().constData());
}
if (externalParams.count() >= 6) {
QFileInfo info(path);
QDir dir = info.absoluteDir();
dir.cd(externalParams.at(3));
QString fileName = info.fileName();
if (fileName.startsWith(externalParams.at(1))) {
fileName.remove(0, externalParams.at(1).size());
fileName.prepend(externalParams.at(4));
}
if (!externalParams.at(2).isEmpty()) {
fileName.chop(externalParams.at(2).size());
}
fileName.append(externalParams.at(5));
if (dir.exists(fileName)) {
// Match, we opened a proxy clip
setProducerProperty(QStringLiteral("kdenlive:proxy"), path);
m_path = dir.absoluteFilePath(fileName);
setProducerProperty(QStringLiteral("kdenlive:originalurl"), m_path);
if (m_name == QFileInfo(path).fileName()) {
m_name = QFileInfo(m_path).fileName();
}
getFileHash();
skipProducer = true;
}
}
}
// Make sure we have a hash for this clip
updateProducer(producer);
getFileHash();
......@@ -583,7 +618,7 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool gene
updateTimelineClips({TimelineModel::IsProxyRole});
bool generateProxy = false;
QList<std::shared_ptr<ProjectClip>> clipList;
if (pCore->currentDoc()->useProxy() && pCore->currentDoc()->getDocumentProperty(QStringLiteral("generateproxy")).toInt() == 1) {
if (!m_usesProxy && pCore->currentDoc()->useProxy() && pCore->currentDoc()->getDocumentProperty(QStringLiteral("generateproxy")).toInt() == 1) {
// automatic proxy generation enabled
if (m_clipType == ClipType::Image && pCore->currentDoc()->getDocumentProperty(QStringLiteral("generateimageproxy")).toInt() == 1) {
if (getProducerIntProperty(QStringLiteral("meta.media.width")) >= KdenliveSettings::proxyimageminsize() &&
......@@ -592,32 +627,6 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool gene
}
} else if (pCore->currentDoc()->getDocumentProperty(QStringLiteral("generateproxy")).toInt() == 1 &&
(m_clipType == ClipType::AV || m_clipType == ClipType::Video) && getProducerProperty(QStringLiteral("kdenlive:proxy")) == QLatin1String()) {
bool skipProducer = false;
if (pCore->currentDoc()->useExternalProxy()) {
QStringList externalParams = pCore->currentDoc()->getDocumentProperty(QStringLiteral("externalproxyparams")).split(QLatin1Char(';'));
// We have a camcorder profile, check if we have opened a proxy clip
if (externalParams.count() >= 6) {
QFileInfo info(m_path);
QDir dir = info.absoluteDir();
dir.cd(externalParams.at(3));
QString fileName = info.fileName();
if (fileName.startsWith(externalParams.at(1))) {
fileName.remove(0, externalParams.at(1).size());
fileName.prepend(externalParams.at(4));
}
if (!externalParams.at(2).isEmpty()) {
fileName.chop(externalParams.at(2).size());
}
fileName.append(externalParams.at(5));
if (dir.exists(fileName)) {
setProducerProperty(QStringLiteral("kdenlive:proxy"), m_path);
m_path = dir.absoluteFilePath(fileName);
setProducerProperty(QStringLiteral("kdenlive:originalurl"), m_path);
getFileHash();
skipProducer = true;
}
}
}
if (!skipProducer && getProducerIntProperty(QStringLiteral("meta.media.width")) >= KdenliveSettings::proxyminsize()) {
clipList << std::static_pointer_cast<ProjectClip>(shared_from_this());
}
......
Supports Markdown
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