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

First draft saving timeremap to playlist

parent f6ae1063
Pipeline #67561 passed with stage
in 8 minutes and 57 seconds
......@@ -4566,10 +4566,10 @@ void Bin::remapCurrent()
QString fName = info.fileName().section(QLatin1Char('.'),0, -2);
fName.append("-remap");
int ix = 1;
QString renderName = QString("%1%2.mlt").arg(fName).arg(QString::number(ix, 'f', 3));
QString renderName = QString("%1%2.mlt").arg(fName).arg(QString::number(ix).rightJustified(4, '0'));
while (dir.exists(renderName)) {
ix++;
renderName = QString("%1%2.mlt").arg(fName).arg(QString::number(ix, 'f', 3));
renderName = QString("%1%2.mlt").arg(fName).arg(QString::number(ix).rightJustified(4, '0'));
}
Mlt::Consumer consumer(pCore->getCurrentProfile()->profile(), "xml", dir.absoluteFilePath(renderName).toUtf8().constData());
consumer.set("terminate_on_pause", 1);
......
......@@ -952,7 +952,19 @@ std::pair<std::shared_ptr<Mlt::Producer>, bool> ProjectClip::giveMasterAndGetTim
std::shared_ptr<Mlt::Producer> ProjectClip::cloneProducer(bool removeEffects)
{
Mlt::Consumer c(pCore->getCurrentProfile()->profile(), "xml", "string");
Mlt::Service s(m_masterProducer->get_service());
Mlt::Service s;
bool playlistChain = false;
QScopedPointer<Mlt::Service> serv;
if (m_clipType == ClipType::Playlist) {
serv.reset(m_masterProducer->producer());
if (serv != nullptr) {
s = Mlt::Service(serv->get_service());
playlistChain = true;
}
}
if (!playlistChain) {
s = Mlt::Service(m_masterProducer->get_service());
}
int ignore = s.get_int("ignore_points");
if (ignore) {
s.set("ignore_points", 0);
......@@ -970,6 +982,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::cloneProducer(bool removeEffects)
}
const QByteArray clipXml = c.get("string");
std::shared_ptr<Mlt::Producer> prod;
qDebug()<<"============= CLONED CLIP: \n\n"<<clipXml<<"\n\n======================";
prod.reset(new Mlt::Producer(pCore->getCurrentProfile()->profile(), "xml-string", clipXml.constData()));
if (strcmp(prod->get("mlt_service"), "avformat") == 0) {
......
......@@ -35,6 +35,7 @@
#include <KColorScheme>
#include "klocalizedstring.h"
#include <profiles/profilemodel.hpp>
RemapView::RemapView(QWidget *parent)
: QWidget(parent)
......@@ -58,6 +59,9 @@ RemapView::RemapView(QWidget *parent)
m_offset = qCeil(m_lineHeight / 4);
setFixedHeight(size * 4);
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
timer.setInterval(500);
timer.setSingleShot(true);
connect(&timer, &QTimer::timeout, this, &RemapView::reloadProducer);
}
void RemapView::updateInPos(int pos)
......@@ -632,6 +636,41 @@ const QString RemapView::getKeyframesData() const
return result.join(QLatin1Char(';'));
}
void RemapView::reloadProducer()
{
qDebug()<<"==== RELOAD:";
if (!m_clip->clipUrl().endsWith(QLatin1String(".mlt"))) {
qDebug()<<"==== shit is not a playlist clip, aborting";
Please register or sign in to reply
return;
}
Mlt::Consumer c(pCore->getCurrentProfile()->profile(), "xml", m_clip->clipUrl().toUtf8().constData());
QScopedPointer<Mlt::Service> serv(m_clip->originalProducer()->producer());
if (serv == nullptr) {
return;
}
qDebug()<<"==== GOR PLAYLIST SERVICE: "<<serv->type()<<" / "<<serv->consumer()->type()<<", SAVING TO "<<m_clip->clipUrl();
Please register or sign in to reply
Mlt::Multitrack s2(*serv.data());
qDebug()<<"==== MULTITRACK: "<<s2.count();
Mlt::Tractor s(pCore->getCurrentProfile()->profile());
s.set_track(*s2.track(0), 0);
qDebug()<<"==== GOT TRACKS: "<<s.count();
int ignore = s.get_int("ignore_points");
if (ignore) {
s.set("ignore_points", 0);
}
c.connect(s);
c.set("time_format", "frames");
c.set("no_meta", 1);
c.set("no_root", 1);
//c.set("no_profile", 1);
c.set("root", "/");
c.set("store", "kdenlive");
c.run();
if (ignore) {
s.set("ignore_points", ignore);
}
}
std::pair<double,double> RemapView::getSpeed(std::pair<int,int>kf)
{
std::pair<double,double> speeds = {-1,-1};
......@@ -1007,6 +1046,7 @@ void TimeRemap::updateKeyframes()
qDebug()<<" ==== RES: "<< kfData;
if (m_remapLink) {
m_remapLink->set("map", kfData.toUtf8().constData());
m_view->timer.start();
qDebug()<<"==== SETTING REMAP LINK!!!!!!!!!!!!!";
}
}
......
......@@ -27,6 +27,7 @@
#include "timecodedisplay.h"
#include <QWidget>
#include <QTimer>
#include "mlt++/Mlt.h"
......@@ -48,6 +49,7 @@ public:
void setDuration(std::shared_ptr<ProjectClip> clip, int duration);
void loadKeyframes(const QString &mapData);
const QString getKeyframesData() const;
QTimer timer;
protected:
void paintEvent(QPaintEvent *event) override;
......@@ -65,6 +67,7 @@ public slots:
void updateBeforeSpeed(double speed);
void updateAfterSpeed(double speed);
void toggleMoveNext(bool moveNext);
void reloadProducer();
private:
enum MOVEMODE {NoMove, TopMove, BottomMove, CursorMove};
......
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