* Fix stabilized clips not loading:

http://www.kdenlive.org/mantis/view.php?id=2711
parent 1f9ce41f
......@@ -6209,7 +6209,7 @@ void CustomTrackView::setAudioAlignReference()
if (clip->clipType() == AV || clip->clipType() == AUDIO) {
m_audioAlignmentReference = clip;
AudioEnvelope *envelope = new AudioEnvelope(clip->getProducer(clip->track()));
AudioEnvelope *envelope = new AudioEnvelope(clip->baseClip()->fileURL().path(), clip->getProducer(clip->track()));
m_audioCorrelator = new AudioCorrelation(envelope);
......@@ -6254,9 +6254,7 @@ void CustomTrackView::alignAudio()
}
if (clip->clipType() == AV || clip->clipType() == AUDIO) {
AudioEnvelope *envelope = new AudioEnvelope(clip->getProducer(clip->track()),
clip->info().cropStart.frames(m_document->fps()),
clip->info().cropDuration.frames(m_document->fps()));
AudioEnvelope *envelope = new AudioEnvelope(clip->baseClip()->fileURL().path(), clip->getProducer(clip->track()), clip->info().cropStart.frames(m_document->fps()), clip->info().cropDuration.frames(m_document->fps()));
// FFT only for larger vectors. We could use it all time, but for small vectors
// the (anyway not noticeable) overhead is smaller with a nested for loop correlation.
......
......@@ -692,6 +692,10 @@ Mlt::Producer *DocClipBase::cloneProducer(Mlt::Producer *source)
{
Mlt::Producer *result = NULL;
QString url = QString::fromUtf8(source->get("resource"));
if (url == "<playlist>" || url == "<tractor>" || url == "<producer>") {
// Xml producer sometimes loses the correct url
url = m_properties.value("resource");
}
if (m_clipType == SLIDESHOW || KIO::NetAccess::exists(KUrl(url), KIO::NetAccess::SourceSide, 0)) {
result = new Mlt::Producer(*(source->profile()), url.toUtf8().constData());
}
......
......@@ -11,12 +11,13 @@
#include "audioEnvelope.h"
#include "audioStreamInfo.h"
#include <QDebug>
#include <QImage>
#include <QTime>
#include <cmath>
#include <iostream>
AudioEnvelope::AudioEnvelope(Mlt::Producer *producer, int offset, int length) :
AudioEnvelope::AudioEnvelope(const QString &url, Mlt::Producer *producer, int offset, int length) :
m_envelope(NULL),
m_offset(offset),
m_length(length),
......@@ -28,7 +29,13 @@ AudioEnvelope::AudioEnvelope(Mlt::Producer *producer, int offset, int length) :
m_envelopeIsNormalized(false)
{
// make a copy of the producer to avoid audio playback issues
m_producer = new Mlt::Producer(*(producer->profile()), producer->get("resource"));
QString path = QString::fromUtf8(producer->get("resource"));
if (path == "<playlist>" || path == "<tractor>" || path == "<producer>")
path = url;
m_producer = new Mlt::Producer(*(producer->profile()), path.toUtf8().constData());
if (!m_producer || !m_producer->is_valid()) {
qDebug()<<"// Cannot create envelope for producer: "<<path;
}
m_info = new AudioInfo(m_producer);
Q_ASSERT(m_offset >= 0);
......
......@@ -26,7 +26,7 @@ class QImage;
class AudioEnvelope
{
public:
explicit AudioEnvelope(Mlt::Producer *producer, int offset = 0, int length = 0);
explicit AudioEnvelope(const QString &url, Mlt::Producer *producer, int offset = 0, int length = 0);
~AudioEnvelope();
/// Returns the envelope, calculates it if necessary.
......
......@@ -2967,7 +2967,7 @@ void ProjectList::slotProcessJobs()
if (job->jobType == MLTJOB) {
MeltJob *jb = static_cast<MeltJob *> (job);
jb->setProducer(currentClip->getProducer());
jb->setProducer(currentClip->getProducer(), currentClip->fileURL());
}
job->startJob();
if (job->jobStatus == JOBDONE) {
......
......@@ -23,6 +23,7 @@
#include "kdenlivedoc.h"
#include <KDebug>
#include <KUrl>
#include <KLocale>
#include <mlt++/Mlt.h>
......@@ -49,9 +50,12 @@ MeltJob::MeltJob(CLIPTYPE cType, const QString &id, QStringList parameters) : Ab
if (consum.contains(':')) m_dest = consum.section(':', 1);
}
void MeltJob::setProducer(Mlt::Producer *producer)
void MeltJob::setProducer(Mlt::Producer *producer, KUrl url)
{
m_producer = producer;
m_url = QString::fromUtf8(m_producer->get("resource"));
if (m_url == "<playlist>" || m_url == "<tractor>" || m_url == "<producer>")
m_url == url.path();
}
void MeltJob::startJob()
......@@ -92,8 +96,7 @@ void MeltJob::startJob()
Mlt::Producer *prod;
if (out == -1) {
QString url = QString::fromUtf8(m_producer->get("resource"));
prod = new Mlt::Producer(*m_profile, url.toUtf8().constData());
prod = new Mlt::Producer(*m_profile, m_url.toUtf8().constData());
}
else
prod = m_producer->cut(in, out);
......
......@@ -26,6 +26,8 @@
#include "abstractclipjob.h"
class KUrl;
namespace Mlt{
class Profile;
class Producer;
......@@ -46,7 +48,7 @@ public:
stringMap cancelProperties();
bool addClipToProject;
const QString statusMessage();
void setProducer(Mlt::Producer *producer);
void setProducer(Mlt::Producer *producer, KUrl url);
void emitFrameNumber();
private:
......@@ -56,6 +58,7 @@ private:
Mlt::Event *m_showFrameEvent;
QStringList m_params;
QString m_dest;
QString m_url;
int m_length;
};
......
......@@ -127,12 +127,12 @@ int main(int argc, char *argv[])
// Build the audio envelopes for the correlation
AudioEnvelope *envelopeMain = new AudioEnvelope(&prodMain);
AudioEnvelope *envelopeMain = new AudioEnvelope(fileMain.c_str(), &prodMain);
envelopeMain->loadEnvelope();
envelopeMain->loadStdDev();
envelopeMain->dumpInfo();
AudioEnvelope *envelopeSub = new AudioEnvelope(&prodSub);
AudioEnvelope *envelopeSub = new AudioEnvelope(fileSub.c_str(), &prodSub);
envelopeSub->loadEnvelope();
envelopeSub->loadStdDev();
envelopeSub->dumpInfo();
......
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