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

Allow proxy clips for slideshows

BUG: 369243
parent 61fbf129
......@@ -1297,7 +1297,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<ProjectClip *> clipLi
ProjectClip *item = clipList.at(i);
ClipType t = item->clipType();
// Only allow proxy on some clip types
if ((t == Video || t == AV || t == Unknown || t == Image || t == Playlist) && item->isReady()) {
if ((t == Video || t == AV || t == Unknown || t == Image || t == Playlist || t == SlideShow) && item->isReady()) {
if ((doProxy && !force && item->hasProxy()) || (!doProxy && !item->hasProxy() && pCore->binController()->hasClip(item->clipId()))) continue;
if (pCore->producerQueue()->isProcessing(item->clipId())) {
continue;
......@@ -1309,16 +1309,25 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<ProjectClip *> clipLi
// insert required duration for proxy
newProps.insert(QStringLiteral("proxy_out"), item->getProducerProperty(QStringLiteral("out")));
newProps.insert(QStringLiteral("kdenlive:proxy"), path);
// We need to insert empty proxy so that undo will work
//TODO: how to handle clip properties
//oldProps = clip->currentProperties(newProps);
oldProps.insert(QStringLiteral("kdenlive:proxy"), QStringLiteral("-"));
}
else if (!pCore->binController()->hasClip(item->clipId())) {
// Force clip reload
newProps.insert(QStringLiteral("resource"), item->url().toLocalFile());
else {
if (t == SlideShow) {
// Revert to picture aspect ratio
newProps.insert(QStringLiteral("aspect_ratio"), QStringLiteral("1"));
}
if (!pCore->binController()->hasClip(item->clipId())) {
// Force clip reload
newProps.insert(QStringLiteral("resource"), item->url().toLocalFile());
}
}
// We need to insert empty proxy so that undo will work
//TODO: how to handle clip properties
//oldProps = clip->currentProperties(newProps);
if (doProxy) oldProps.insert(QStringLiteral("kdenlive:proxy"), QStringLiteral("-"));
new EditClipCommand(pCore->bin(), item->clipId(), oldProps, newProps, true, masterCommand);
} else {
// Cannot proxy this clip type
pCore->bin()->doDisplayMessage(i18n("Clip type does not support proxies"), KMessageWidget::Information);
}
}
if (!hasParent) {
......
......@@ -432,7 +432,6 @@ void ProducerQueue::processFileProperties()
producer->set("length", length);
int kdenlive_duration = EffectsList::property(info.xml, QStringLiteral("kdenlive:duration")).toInt();
producer->set("kdenlive:duration", kdenlive_duration > 0 ? kdenlive_duration : length);
}
if (clipOut > 0) {
producer->set_in_and_out(info.xml.attribute(QStringLiteral("in")).toInt(), clipOut);
......
......@@ -24,12 +24,12 @@
#include "bin/projectclip.h"
#include "bin/bin.h"
#include <QProcess>
#include <QTemporaryFile>
#include <QDebug>
#include <klocalizedstring.h>
ProxyJob::ProxyJob(ClipType cType, const QString &id, const QStringList& parameters)
ProxyJob::ProxyJob(ClipType cType, const QString &id, const QStringList& parameters, QTemporaryFile *playlist)
: AbstractClipJob(PROXYJOB, cType, id),
m_jobDuration(0),
m_isFfmpegJob(true)
......@@ -42,6 +42,7 @@ ProxyJob::ProxyJob(ClipType cType, const QString &id, const QStringList& paramet
m_proxyParams = parameters.at(3);
m_renderWidth = parameters.at(4).toInt();
m_renderHeight = parameters.at(5).toInt();
m_playlist = playlist;
replaceClip = true;
}
......@@ -49,7 +50,7 @@ void ProxyJob::startJob()
{
// Special case: playlist clips (.mlt or .kdenlive project files)
m_jobDuration = 0;
if (clipType == Playlist) {
if (clipType == Playlist || clipType == SlideShow) {
// change FFmpeg params to MLT format
m_isFfmpegJob = false;
QStringList mltParameters;
......@@ -167,6 +168,8 @@ void ProxyJob::startJob()
}
m_jobProcess->waitForFinished(400);
}
// remove temporary playlist if it exists
delete m_playlist;
if (m_jobStatus != JobAborted) {
int result = m_jobProcess->exitStatus();
if (result == QProcess::NormalExit) {
......@@ -265,7 +268,7 @@ QList <ProjectClip *> ProxyJob::filterClips(QList <ProjectClip *>clips)
for (int i = 0; i < clips.count(); i++) {
ProjectClip *clip = clips.at(i);
ClipType type = clip->clipType();
if (type != AV && type != Video && type != Playlist && type != Image) {
if (type != AV && type != Video && type != Playlist && type != Image && type != SlideShow) {
// Clip will not be processed by this job
continue;
}
......@@ -302,8 +305,22 @@ QHash <ProjectClip *, AbstractClipJob *> ProxyJob::prepareJob(Bin *bin, QList <P
sourcePath.prepend("consumer:");
}
QStringList parameters;
QTemporaryFile *playlist = NULL;
if (item->clipType() == SlideShow) {
// we save a temporary .mlt clip for rendering
QDomDocument doc;
QDomElement xml = item->toXml(doc, false);
playlist = new QTemporaryFile();
playlist->setFileTemplate(playlist->fileTemplate() + QStringLiteral(".mlt"));
if (playlist->open()) {
sourcePath = playlist->fileName();
QTextStream out(playlist);
out << doc.toString();
playlist->close();
}
}
parameters << path << sourcePath << item->getProducerProperty(QStringLiteral("_exif_orientation")) << params << QString::number(renderSize.width()) << QString::number(renderSize.height());
ProxyJob *job = new ProxyJob(item->clipType(), id, parameters);
ProxyJob *job = new ProxyJob(item->clipType(), id, parameters, playlist);
jobs.insert(item, job);
}
return jobs;
......
......@@ -23,6 +23,7 @@
#include "abstractclipjob.h"
class QTemporaryFile;
class Bin;
class ProjectClip;
......@@ -31,7 +32,7 @@ class ProxyJob : public AbstractClipJob
Q_OBJECT
public:
ProxyJob(ClipType cType, const QString &id, const QStringList& parameters);
ProxyJob(ClipType cType, const QString &id, const QStringList& parameters, QTemporaryFile *playlist);
virtual ~ ProxyJob();
const QString destination() const;
void startJob();
......@@ -50,6 +51,7 @@ private:
int m_renderHeight;
int m_jobDuration;
bool m_isFfmpegJob;
QTemporaryFile *m_playlist;
};
#endif
......@@ -498,7 +498,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
QRectF rec(xPos, MAX_HEIGHT + 1, chunkWidth, PREVIEW_SIZE - 1);
p.fillRect(rec, preview);
}
preview = Qt::darkRed;
preview = QColor(200, 0, 0);
preview.setAlpha(120);
foreach(int frame, m_dirtyRenderingPreviews) {
double xPos = frame * m_factor - m_offset;
......
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