1 /***************************************************************************
2 krender.cpp - description
4 begin : Fri Nov 22 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 copyright : (C) 2005 Lucio Flavio Correa
8 email : lucio.correa@gmail.com
9 copyright : (C) Marco Gittler
10 email : g.marco@freenet.de
11 copyright : (C) 2006 Jean-Baptiste Mardelle
14 ***************************************************************************/
16 /***************************************************************************
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 ***************************************************************************/
25 // ffmpeg Header files
28 #include <ffmpeg/avformat.h>
32 #include <QApplication>
36 #include <KStandardDirs>
37 #include <KMessageBox>
39 #include <KTemporaryFile>
42 #include "kdenlivesettings.h"
44 static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr) {
45 // detect if the producer has finished playing. Is there a better way to do it ?
46 //if (self->isBlocked) return;
47 if (mlt_properties_get_double(MLT_FRAME_PROPERTIES(frame_ptr), "_speed") == 0.0) {
48 self->emitConsumerStopped();
50 self->emitFrameNumber(mlt_frame_get_position(frame_ptr));
54 Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true) {
55 kDebug() << "////////// USING PROFILE: " << (char *)KdenliveSettings::current_profile().toUtf8().data();
56 m_mltProfile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
57 refreshTimer = new QTimer(this);
58 connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
60 m_connectTimer = new QTimer(this);
61 connect(m_connectTimer, SIGNAL(timeout()), this, SLOT(connectPlaylist()));
63 if (rendererName == "project") m_monitorId = 10000;
64 else m_monitorId = 10001;
65 osdTimer = new QTimer(this);
66 connect(osdTimer, SIGNAL(timeout()), this, SLOT(slotOsdTimeout()));
68 m_osdProfile = KStandardDirs::locate("data", "kdenlive/profiles/metadata.properties");
69 //if (rendererName == "clip")
71 //Mlt::Consumer *consumer = new Mlt::Consumer( profile , "sdl_preview");
72 m_mltConsumer = new Mlt::Consumer(*m_mltProfile , "sdl_preview"); //consumer;
73 m_mltConsumer->set("resize", 1);
74 m_mltConsumer->set("window_id", winid);
75 m_mltConsumer->set("terminate_on_pause", 1);
76 m_externalwinid = extid;
78 m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
79 Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", "<westley><playlist><producer mlt_service=\"colour\" colour=\"blue\" /></playlist></westley>");
80 m_mltProducer = producer;
81 m_mltConsumer->connect(*m_mltProducer);
82 m_mltProducer->set_speed(0.0);
83 //m_mltConsumer->start();
87 /*m_osdInfo = new Mlt::Filter("data_show");
88 char *tmp = decodedString(m_osdProfile);
89 m_osdInfo->set("resource", tmp);
91 // Does it do anything usefull? I mean, RenderThread doesn't do anything useful at the moment
92 // (except being cpu hungry :)
94 /* if(!s_renderThread) {
95 s_renderThread = new RenderThread;
96 s_renderThread->start();
105 void Render::closeMlt() {
106 delete m_connectTimer;
110 delete m_mltConsumer;
112 delete m_mltProducer;
118 int Render::resetProfile(QString profile) {
119 if (!m_mltConsumer) return 0;
120 if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
121 m_mltConsumer->set("refresh", 0);
122 m_mltConsumer->purge();
123 //TODO: we should also rebuild filters and delete existing m_mltProfile
125 //delete m_mltProfile;
126 m_mltProfile = new Mlt::Profile((char*) profile.toUtf8().data());
127 kDebug() << " ++++++++++ RESET CONSUMER WITH PROFILE: " << m_mltProfile->width();
128 // mlt_properties properties = MLT_CONSUMER_PROPERTIES(m_mltConsumer->get_consumer());
129 //mlt_profile prof = m_mltProfile->get_profile();
130 //mlt_properties_set_data(properties, "_profile", prof, 0, (mlt_destructor)mlt_profile_close, NULL);
131 //mlt_properties_set(properties, "profile", "hdv_1080_50i");
132 m_mltConsumer->set("profile", (char *) profile.toUtf8().data());
133 //apply_profile_properties( m_mltProfile, m_mltConsumer->get_consumer(), properties );
138 /** Wraps the VEML command of the same name; Seeks the renderer clip to the given time. */
139 void Render::seek(GenTime time) {
140 sendSeekCommand(time);
141 //emit positionChanged(time);
145 char *Render::decodedString(QString str) {
146 /*QCString fn = QFile::encodeName(str);
147 char *t = new char[fn.length() + 1];
148 strcpy(t, (const char *)fn);*/
150 return (char *) qstrdup(str.toUtf8().data()); //toLatin1
154 QPixmap Render::frameThumbnail(Mlt::Frame *frame, int width, int height, bool border) {
155 QPixmap pix(width, height);
157 mlt_image_format format = mlt_image_rgb24a;
158 uint8_t *thumb = frame->get_image(format, width, height);
159 QImage image(thumb, width, height, QImage::Format_ARGB32);
161 if (!image.isNull()) {
162 pix = pix.fromImage(image);
164 QPainter painter(&pix);
165 painter.drawRect(0, 0, width - 1, height - 1);
167 } else pix.fill(Qt::black);
172 QPixmap Render::extractFrame(int frame_position, int width, int height) {
173 QPixmap pix(width, height);
174 if (!m_mltProducer) {
178 Mlt::Producer *mlt_producer = m_mltProducer->cut(frame_position, frame_position + 1);
179 Mlt::Filter m_convert(*m_mltProfile, "avcolour_space");
180 m_convert.set("forced", mlt_image_rgb24a);
181 mlt_producer->attach(m_convert);
182 Mlt::Frame *frame = mlt_producer->get_frame();
185 pix = frameThumbnail(frame, width, height);
187 } else pix.fill(Qt::black);
192 QPixmap Render::getImageThumbnail(KUrl url, int width, int height) {
195 if (url.fileName().startsWith(".all.")) { // check for slideshow
196 QString fileType = url.fileName().right(3);
198 QStringList::Iterator it;
200 QDir dir(url.directory());
201 more = dir.entryList(QDir::Files);
203 for (it = more.begin() ; it != more.end() ; ++it) {
204 if ((*it).endsWith("." + fileType, Qt::CaseInsensitive)) {
205 im.load(url.directory() + "/" + *it);
209 } else im.load(url.path());
210 //pixmap = im.scaled(width, height);
215 QPixmap Render::getVideoThumbnail(char *profile, QString file, int frame_position, int width, int height) {
216 QPixmap pix(width, height);
217 char *tmp = decodedString(file);
218 Mlt::Profile *prof = new Mlt::Profile(profile);
219 Mlt::Producer m_producer(*prof, tmp);
221 if (m_producer.is_blank()) {
226 Mlt::Filter m_convert(*prof, "avcolour_space");
227 m_convert.set("forced", mlt_image_rgb24a);
228 m_producer.attach(m_convert);
229 m_producer.seek(frame_position);
230 Mlt::Frame * frame = m_producer.get_frame();
232 pix = frameThumbnail(frame, width, height, true);
235 if (prof) delete prof;
240 void Render::getImage(KUrl url, int frame_position, QPoint size)
242 char *tmp = decodedString(url.path());
243 Mlt::Producer m_producer(tmp);
245 if (m_producer.is_blank()) {
248 Mlt::Filter m_convert("avcolour_space");
249 m_convert.set("forced", mlt_image_rgb24a);
250 m_producer.attach(m_convert);
251 m_producer.seek(frame_position);
253 Mlt::Frame * frame = m_producer.get_frame();
256 QPixmap pix = frameThumbnail(frame, size.x(), size.y(), true);
258 emit replyGetImage(url, frame_position, pix, size.x(), size.y());
262 /* Create thumbnail for color */
263 /*void Render::getImage(int id, QString color, QPoint size)
265 QPixmap pixmap(size.x() - 2, size.y() - 2);
266 color = color.replace(0, 2, "#");
267 color = color.left(7);
268 pixmap.fill(QColor(color));
269 QPixmap result(size.x(), size.y());
270 result.fill(Qt::black);
271 //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
272 emit replyGetImage(id, result, size.x(), size.y());
276 /* Create thumbnail for image */
277 /*void Render::getImage(KUrl url, QPoint size)
281 if (url.fileName().startsWith(".all.")) { // check for slideshow
282 QString fileType = url.fileName().right(3);
284 QStringList::Iterator it;
286 QDir dir( url.directory() );
287 more = dir.entryList( QDir::Files );
288 for ( it = more.begin() ; it != more.end() ; ++it ) {
289 if ((*it).endsWith("."+fileType, Qt::CaseInsensitive)) {
290 if (!im.load(url.directory() + "/" + *it))
291 kDebug()<<"++ ERROR LOADIN IMAGE: "<<url.directory() + "/" + *it;
296 else im.load(url.path());
298 //pixmap = im.smoothScale(size.x() - 2, size.y() - 2);
299 QPixmap result(size.x(), size.y());
300 result.fill(Qt::black);
301 //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
302 emit replyGetImage(url, 1, result, size.x(), size.y());
306 double Render::consumerRatio() const {
307 if (!m_mltConsumer) return 1.0;
308 return (m_mltConsumer->get_double("aspect_ratio_num") / m_mltConsumer->get_double("aspect_ratio_den"));
312 int Render::getLength() {
315 // kDebug()<<"////// LENGTH: "<<mlt_producer_get_playtime(m_mltProducer->get_producer());
316 return mlt_producer_get_playtime(m_mltProducer->get_producer());
321 bool Render::isValid(KUrl url) {
322 char *tmp = decodedString(url.path());
323 Mlt::Producer producer(*m_mltProfile, tmp);
325 if (producer.is_blank())
331 void Render::getFileProperties(const QDomElement &xml, int clipId) {
333 int width = height * 16 / 9.0; //KdenliveSettings::displayratio();
335 QDomElement westley = doc.createElement("westley");
336 doc.appendChild(westley);
337 westley.appendChild(doc.importNode(xml, true));
338 kDebug() << "////////////\n" << doc.toString() << "////////////////\n";
339 char *tmp = decodedString(doc.toString());
341 Mlt::Producer producer(*m_mltProfile, "westley-xml", tmp);
344 if (producer.is_blank()) {
347 int frameNumber = xml.attribute("frame_thumbnail", 0).toInt();
348 if (frameNumber != 0) producer.seek(frameNumber);
349 mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer.get_producer());
351 QMap < QString, QString > filePropertyMap;
352 QMap < QString, QString > metadataPropertyMap;
354 KUrl url = xml.attribute("resource", QString::null);
355 filePropertyMap["filename"] = url.path();
356 filePropertyMap["duration"] = QString::number(producer.get_playtime());
357 kDebug() << "/////// PRODUCER: " << url.path() << " IS: " << producer.get_playtime();
358 Mlt::Filter m_convert(*m_mltProfile, "avcolour_space");
359 m_convert.set("forced", mlt_image_rgb24a);
360 producer.attach(m_convert);
361 Mlt::Frame * frame = producer.get_frame();
363 filePropertyMap["fps"] =
364 QString::number(mlt_producer_get_fps(producer.get_producer()));
366 if (frame && frame->is_valid()) {
367 filePropertyMap["width"] =
368 QString::number(frame->get_int("width"));
369 filePropertyMap["height"] =
370 QString::number(frame->get_int("height"));
371 filePropertyMap["frequency"] =
372 QString::number(frame->get_int("frequency"));
373 filePropertyMap["channels"] =
374 QString::number(frame->get_int("channels"));
376 if (frame->get_int("test_image") == 0) {
377 if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
378 filePropertyMap["type"] = "playlist";
379 metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get(MLT_SERVICE_PROPERTIES(producer.get_service()), "title"));
380 } else if (frame->get_int("test_audio") == 0)
381 filePropertyMap["type"] = "av";
383 filePropertyMap["type"] = "video";
385 // Generate thumbnail for this frame
386 QPixmap pixmap = frameThumbnail(frame, width, height, true);
388 emit replyGetImage(clipId, 0, pixmap, width, height);
390 } else if (frame->get_int("test_audio") == 0) {
391 QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
392 emit replyGetImage(clipId, 0, pixmap, width, height);
393 filePropertyMap["type"] = "audio";
397 // Retrieve audio / video codec name
399 // Fetch the video_context
400 #if 0 //until the reason for the chrashs is found
401 AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data(properties, "video_context", NULL);
402 if (context != NULL) {
403 // Get the video_index
404 int index = mlt_properties_get_int(properties, "video_index");
405 if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
406 filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
408 context = (AVFormatContext *) mlt_properties_get_data(properties, "audio_context", NULL);
409 if (context != NULL) {
410 // Get the video_index
411 int index = mlt_properties_get_int(properties, "audio_index");
412 if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
413 filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
420 mlt_properties metadata = mlt_properties_new();
421 mlt_properties_pass(metadata, properties, "meta.attr.");
422 int count = mlt_properties_count(metadata);
423 for (int i = 0; i < count; i ++) {
424 QString name = mlt_properties_get_name(metadata, i);
425 QString value = QString::fromUtf8(mlt_properties_get_value(metadata, i));
426 if (name.endsWith("markup") && !value.isEmpty())
427 metadataPropertyMap[ name.section(".", 0, -2)] = value;
430 emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
431 kDebug() << "REquested fuile info for: " << url.path();
432 if (frame) delete frame;
435 /** Create the producer from the Westley QDomDocument */
436 void Render::initSceneList() {
437 kDebug() << "-------- INIT SCENE LIST ------_";
439 QDomElement westley = doc.createElement("westley");
440 doc.appendChild(westley);
441 QDomElement prod = doc.createElement("producer");
442 prod.setAttribute("resource", "colour");
443 prod.setAttribute("colour", "red");
444 prod.setAttribute("id", "black");
445 prod.setAttribute("in", "0");
446 prod.setAttribute("out", "0");
448 QDomElement tractor = doc.createElement("tractor");
449 QDomElement multitrack = doc.createElement("multitrack");
451 QDomElement playlist1 = doc.createElement("playlist");
452 playlist1.appendChild(prod);
453 multitrack.appendChild(playlist1);
454 QDomElement playlist2 = doc.createElement("playlist");
455 multitrack.appendChild(playlist2);
456 QDomElement playlist3 = doc.createElement("playlist");
457 multitrack.appendChild(playlist3);
458 QDomElement playlist4 = doc.createElement("playlist");
459 multitrack.appendChild(playlist4);
460 QDomElement playlist5 = doc.createElement("playlist");
461 multitrack.appendChild(playlist5);
462 tractor.appendChild(multitrack);
463 westley.appendChild(tractor);
464 // kDebug()<<doc.toString();
466 QString tmp = QString("<westley><producer resource=\"colour\" colour=\"red\" id=\"red\" /><tractor><multitrack><playlist></playlist><playlist></playlist><playlist /><playlist /><playlist></playlist></multitrack></tractor></westley>");*/
467 setSceneList(doc, 0);
470 /** Create the producer from the Westley QDomDocument */
471 void Render::setSceneList(QDomDocument list, int position) {
472 setSceneList(list.toString(), position);
475 /** Create the producer from the Westley QDomDocument */
476 void Render::setSceneList(QString playlist, int position) {
477 if (m_winid == -1) return;
478 m_generateScenelist = true;
480 kWarning() << "////// RENDER, SET SCENE LIST: " << playlist;
484 if (!clip.is_valid()) {
485 kWarning()<<" ++++ WARNING, UNABLE TO CREATE MLT PRODUCER";
486 m_generateScenelist = false;
491 m_mltConsumer->set("refresh", 0);
492 if (!m_mltConsumer->is_stopped()) {
493 //emitConsumerStopped();
494 m_mltConsumer->stop();
499 m_mltProducer->set_speed(0.0);
500 //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
502 delete m_mltProducer;
503 m_mltProducer = NULL;
507 char *tmp = decodedString(playlist);
508 m_mltProducer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
510 if (!m_mltProducer || !m_mltProducer->is_valid()) kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << tmp;
511 //m_mltProducer->optimise();
512 if (position != 0) m_mltProducer->seek(position);
514 /*if (KdenliveSettings::osdtimecode()) {
515 // Attach filter for on screen display of timecode
517 QString attr = "attr_check";
518 mlt_filter filter = mlt_factory_filter( "data_feed", (char*) attr.ascii() );
519 mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_fezzik", 1 );
520 mlt_producer_attach( m_mltProducer->get_producer(), filter );
521 mlt_filter_close( filter );
523 m_osdInfo = new Mlt::Filter("data_show");
524 tmp = decodedString(m_osdProfile);
525 m_osdInfo->set("resource", tmp);
527 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
528 mlt_properties_set_int( properties, "meta.attr.timecode", 1);
529 mlt_properties_set( properties, "meta.attr.timecode.markup", "#timecode#");
530 m_osdInfo->set("dynamic", "1");
532 if (m_mltProducer->attach(*m_osdInfo) == 1) kDebug()<<"////// error attaching filter";
534 m_osdInfo->set("dynamic", "0");
537 m_fps = m_mltProducer->get_fps();
538 emit durationChanged(m_mltProducer->get_playtime());
539 //m_connectTimer->start( 500 );
541 m_generateScenelist = false;
545 /** Create the producer from the Westley QDomDocument */
546 QString Render::sceneList() {
547 if (m_winid == -1) return QString();
552 saveSceneList(temp.fileName());
553 QFile file(temp.fileName());
554 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
557 QTextStream in(&file);
558 while (!in.atEnd()) {
559 result.append(in.readLine());
565 void Render::saveSceneList(QString path) {
566 char *tmppath = decodedString("westley:" + path);
567 Mlt::Consumer westleyConsumer(*m_mltProfile , tmppath);
569 westleyConsumer.set("terminate_on_pause", 1);
570 Mlt::Producer prod(m_mltProducer->get_producer());
571 westleyConsumer.connect(prod);
572 westleyConsumer.start();
576 const double Render::fps() const {
580 void Render::connectPlaylist() {
582 m_connectTimer->stop();
583 m_mltConsumer->connect(*m_mltProducer);
584 m_mltProducer->set_speed(0.0);
585 m_mltConsumer->start();
588 if (m_mltConsumer->start() == -1) {
589 KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
590 m_mltConsumer = NULL;
597 void Render::refreshDisplay() {
599 if (!m_mltProducer) return;
600 m_mltConsumer->set("refresh", 0);
602 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
603 /*if (KdenliveSettings::osdtimecode()) {
604 mlt_properties_set_int( properties, "meta.attr.timecode", 1);
605 mlt_properties_set( properties, "meta.attr.timecode.markup", "#timecode#");
606 m_osdInfo->set("dynamic", "1");
607 m_mltProducer->attach(*m_osdInfo);
610 m_mltProducer->detach(*m_osdInfo);
611 m_osdInfo->set("dynamic", "0");
616 void Render::setVolume(double volume) {
617 if (!m_mltConsumer || !m_mltProducer) return;
619 m_mltConsumer->set("refresh", 0);
620 // Attach filter for on screen display of timecode
621 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
622 mlt_properties_set_double( properties, "meta.volume", volume );
623 mlt_properties_set_int( properties, "meta.attr.osdvolume", 1);
624 mlt_properties_set( properties, "meta.attr.osdvolume.markup", i18n("Volume: ") + QString::number(volume * 100));
626 if (!KdenliveSettings::osdtimecode()) {
627 m_mltProducer->detach(*m_osdInfo);
628 mlt_properties_set_int( properties, "meta.attr.timecode", 0);
629 if (m_mltProducer->attach(*m_osdInfo) == 1) kDebug()<<"////// error attaching filter";
632 osdTimer->setSingleShot(2500);
635 void Render::slotOsdTimeout() {
636 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
637 mlt_properties_set_int(properties, "meta.attr.osdvolume", 0);
638 mlt_properties_set(properties, "meta.attr.osdvolume.markup", NULL);
639 //if (!KdenliveSettings::osdtimecode()) m_mltProducer->detach(*m_osdInfo);
643 void Render::start() {
644 kDebug() << "----- STARTING MONITOR: " << m_name;
646 kDebug() << "----- BROKEN MONITOR: " << m_name << ", RESTART";
650 if (m_mltConsumer->is_stopped()) {
651 kDebug() << "----- MONITOR: " << m_name << " WAS STOPPED";
652 if (m_mltConsumer->start() == -1) {
653 KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it."));
654 m_mltConsumer = NULL;
657 kDebug() << "----- MONITOR: " << m_name << " REFRESH";
664 void Render::clear() {
666 m_mltConsumer->set("refresh", 0);
667 if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
671 //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
672 m_mltProducer->set_speed(0.0);
673 delete m_mltProducer;
674 m_mltProducer = NULL;
679 void Render::stop() {
680 if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
681 kDebug() << "///////////// RENDER STOPPED: " << m_name;
682 m_mltConsumer->set("refresh", 0);
683 m_mltConsumer->stop();
685 kDebug() << "///////////// RENDER STOP2-------";
689 m_mltProducer->set_speed(0.0);
690 m_mltProducer->set("out", m_mltProducer->get_length() - 1);
692 kDebug() << "///////////// RENDER STOP3-------";
695 void Render::stop(const GenTime & startTime) {
696 kDebug() << "///////////// RENDER STOP-------2";
698 m_mltProducer->set_speed(0.0);
699 m_mltProducer->seek((int) startTime.frames(m_fps));
701 m_mltConsumer->purge();
704 void Render::switchPlay() {
707 if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0);
709 m_mltProducer->set_speed(0.0);
710 kDebug() << "// POSITON: " << m_framePosition;
711 m_mltProducer->seek((int) m_framePosition);
714 /*if (speed == 0.0) {
715 m_mltProducer->seek((int) m_framePosition + 1);
716 m_mltConsumer->purge();
721 void Render::play(double speed) {
724 if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1);
725 m_mltProducer->set_speed(speed);
726 /*if (speed == 0.0) {
727 m_mltProducer->seek((int) m_framePosition + 1);
728 m_mltConsumer->purge();
733 void Render::play(double speed, const GenTime & startTime) {
734 kDebug() << "///////////// RENDER PLAY2-------" << speed;
737 //m_mltProducer->set("out", m_mltProducer->get_length() - 1);
738 //if (speed == 0.0) m_mltConsumer->set("refresh", 0);
739 m_mltProducer->set_speed(speed);
740 m_mltProducer->seek((int)(startTime.frames(m_fps)));
741 //m_mltConsumer->purge();
745 void Render::play(double speed, const GenTime & startTime,
746 const GenTime & stopTime) {
747 kDebug() << "///////////// RENDER PLAY3-------" << speed;
750 m_mltProducer->set("out", stopTime.frames(m_fps));
751 m_mltProducer->seek((int)(startTime.frames(m_fps)));
752 m_mltConsumer->purge();
753 m_mltProducer->set_speed(speed);
758 void Render::sendSeekCommand(GenTime time) {
761 //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
762 m_mltProducer->seek((int)(time.frames(m_fps)));
766 void Render::seekToFrame(int pos) {
769 //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
770 m_mltProducer->seek(pos);
774 void Render::askForRefresh() {
775 // Use a Timer so that we don't refresh too much
776 refreshTimer->start(200);
779 void Render::doRefresh() {
780 // Use a Timer so that we don't refresh too much
784 void Render::refresh() {
785 if (!m_mltProducer || m_isBlocked)
787 refreshTimer->stop();
789 m_mltConsumer->set("refresh", 1);
793 /** Sets the description of this renderer to desc. */
794 void Render::setDescription(const QString & description) {
795 m_description = description;
798 /** Returns the description of this renderer */
799 QString Render::description() {
800 return m_description;
804 double Render::playSpeed() {
805 if (m_mltProducer) return m_mltProducer->get_speed();
809 const GenTime & Render::seekPosition() const {
810 if (m_mltProducer) return GenTime((int) m_mltProducer->position(), m_fps);
811 else return GenTime();
815 const QString & Render::rendererName() const {
820 void Render::emitFrameNumber(double position) {
821 //kDebug()<<"// POSITON: "<<m_framePosition;
822 if (m_generateScenelist) return;
823 m_framePosition = position;
824 emit rendererPosition((int) position);
825 //if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent( GenTime((int) position, m_fps), m_monitorId));
828 void Render::emitConsumerStopped() {
829 // This is used to know when the playing stopped
830 if (m_mltProducer && !m_generateScenelist) {
831 double pos = m_mltProducer->position();
832 emit rendererStopped((int) pos);
833 //if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent(GenTime((int) pos, m_fps), m_monitorId + 100));
834 //new QCustomEvent(10002));
840 void Render::exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime) {
841 KMessageBox::sorry(0, i18n("Firewire is not enabled on your system.\n Please install Libiec61883 and recompile Kdenlive"));
845 void Render::exportCurrentFrame(KUrl url, bool notify) {
846 if (!m_mltProducer) {
847 KMessageBox::sorry(qApp->activeWindow(), i18n("There is no clip, cannot extract frame."));
851 int height = 1080;//KdenliveSettings::defaultheight();
852 int width = 1940; //KdenliveSettings::displaywidth();
854 QPixmap pix(width, height);
855 Mlt::Filter m_convert(*m_mltProfile, "avcolour_space");
856 m_convert.set("forced", mlt_image_rgb24a);
857 m_mltProducer->attach(m_convert);
858 Mlt::Frame * frame = m_mltProducer->get_frame();
859 m_mltProducer->detach(m_convert);
861 pix = frameThumbnail(frame, width, height);
864 pix.save(url.path(), "PNG");
865 //if (notify) QApplication::postEvent(qApp->activeWindow(), new UrlEvent(url, 10003));
868 /** MLT PLAYLIST DIRECT MANIPULATON **/
871 void Render::mltCheckLength() {
872 //kDebug()<<"checking track length: "<<track<<"..........";
873 Mlt::Service service(m_mltProducer->get_service());
874 Mlt::Tractor tractor(service);
876 int trackNb = tractor.count();
878 double trackDuration;
880 Mlt::Producer trackProducer(tractor.track(0));
881 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
882 duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
883 m_mltProducer->set("out", duration);
884 emit durationChanged(duration);
887 while (trackNb > 1) {
888 Mlt::Producer trackProducer(tractor.track(trackNb - 1));
889 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
890 trackDuration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
892 kDebug() << " / / /DURATON FOR TRACK " << trackNb - 1 << " = " << trackDuration;
893 if (trackDuration > duration) duration = trackDuration;
897 Mlt::Producer blackTrackProducer(tractor.track(0));
898 Mlt::Playlist blackTrackPlaylist((mlt_playlist) blackTrackProducer.get_service());
899 double blackDuration = Mlt::Producer(blackTrackPlaylist.get_producer()).get_playtime() - 1;
900 kDebug() << " / / /DURATON FOR TRACK 0 = " << blackDuration;
901 if (blackDuration != duration) {
902 blackTrackPlaylist.remove_region(0, blackDuration);
906 QDomElement black = doc.createElement("producer");
907 black.setAttribute("mlt_service", "colour");
908 black.setAttribute("colour", "black");
909 black.setAttribute("in", "0");
910 black.setAttribute("out", "13999");
911 while (dur > 14000) { // <producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" />
912 mltInsertClip(0, GenTime(i * 14000, m_fps), black);
916 black.setAttribute("out", QString::number(dur));
917 mltInsertClip(0, GenTime(), black);
919 m_mltProducer->set("out", duration);
920 emit durationChanged(duration);
925 void Render::mltInsertClip(int track, GenTime position, QDomElement element) {
926 if (!m_mltProducer) {
927 kDebug() << "PLAYLIST NOT INITIALISED //////";
930 Mlt::Producer parentProd(m_mltProducer->parent());
931 if (parentProd.get_producer() == NULL) {
932 kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
936 Mlt::Service service(parentProd.get_service());
937 Mlt::Tractor tractor(service);
940 doc.appendChild(doc.importNode(element, true));
941 QString resource = doc.toString();
942 kDebug() << "/////// ADDING CLIP TMLNE: " << resource << " ON TRACK: " << track;
943 Mlt::Producer trackProducer(tractor.track(track));
944 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
945 char *tmp = decodedString(resource);
946 Mlt::Producer clip(*m_mltProfile, "westley-xml", tmp);
947 //clip.set_in_and_out(in.frames(m_fps), out.frames(m_fps));
950 trackPlaylist.insert_at(position.frames(m_fps), clip, 1);
951 tractor.multitrack()->refresh();
953 if (track != 0) mltCheckLength();
957 void Render::mltCutClip(int track, GenTime position) {
959 Mlt::Service service(m_mltProducer->parent().get_service());
960 Mlt::Tractor tractor(service);
961 Mlt::Producer trackProducer(tractor.track(track));
962 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
963 trackPlaylist.split_at(position.frames(m_fps));
964 trackPlaylist.consolidate_blanks(0);
965 kDebug() << "/ / / /CUTTING CLIP AT: " << position.frames(m_fps);
970 void Render::mltRemoveClip(int track, GenTime position) {
972 Mlt::Service service(m_mltProducer->parent().get_service());
973 Mlt::Tractor tractor(service);
974 Mlt::Producer trackProducer(tractor.track(track));
975 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
976 int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
977 //trackPlaylist.remove(clipIndex);
978 trackPlaylist.replace_with_blank(clipIndex);
979 trackPlaylist.consolidate_blanks(0);
980 if (track != 0) mltCheckLength();
981 //emit durationChanged();
985 void Render::mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh) {
987 Mlt::Service service(m_mltProducer->parent().get_service());
989 Mlt::Tractor tractor(service);
990 Mlt::Producer trackProducer(tractor.track(track));
991 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
992 //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
993 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
995 kDebug() << " / / / CANNOT FIND CLIP TO REMOVE EFFECT";
999 Mlt::Service clipService(clip->get_service());
1001 // if (tag.startsWith("ladspa")) tag = "ladspa";
1004 Mlt::Filter *filter = clipService.filter(ct);
1006 if (index == "-1" || filter->get("kdenlive_ix") == index) {// && filter->get("kdenlive_id") == id) {
1007 clipService.detach(*filter);
1008 kDebug() << " / / / DLEETED EFFECT: " << ct;
1010 filter = clipService.filter(ct);
1012 m_isBlocked = false;
1013 if (doRefresh) refresh();
1017 void Render::mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh) {
1018 Mlt::Service service(m_mltProducer->parent().get_service());
1019 Mlt::Tractor tractor(service);
1020 Mlt::Producer trackProducer(tractor.track(track));
1021 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
1023 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1026 kDebug() << "********** CANNOT FIND CLIP TO APPLY EFFECT-----------";
1029 Mlt::Service clipService(clip->get_service());
1032 QString tag = args.value("tag");
1033 //kDebug()<<" / / INSERTING EFFECT: "<<id;
1034 if (tag.startsWith("ladspa")) tag = "ladspa";
1035 char *filterId = decodedString(tag);
1036 Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterId);
1037 if (filter && filter->is_valid())
1038 filter->set("kdenlive_id", filterId);
1040 kDebug() << "filter is NULL";
1044 QMap<QString, QString>::Iterator it;
1045 QString keyFrameNumber = "#0";
1047 for (it = args.begin(); it != args.end(); ++it) {
1048 //kDebug()<<" / / INSERTING EFFECT ARGS: "<<it.key()<<": "<<it.data();
1050 QString currentKeyFrameNumber;
1051 if (it.key().startsWith("#")) {
1052 currentKeyFrameNumber = it.key().section(":", 0, 0);
1053 if (currentKeyFrameNumber != keyFrameNumber) {
1054 // attach filter to the clip
1055 clipService.attach(*filter);
1056 filter = new Mlt::Filter(*m_mltProfile, filterId);
1057 filter->set("kdenlive_id", filterId);
1058 keyFrameNumber = currentKeyFrameNumber;
1060 key = it.key().section(":", 1);
1061 } else key = it.key();
1062 char *name = decodedString(key);
1063 char *value = decodedString(it.value());
1064 filter->set(name, value);
1068 // attach filter to the clip
1069 clipService.attach(*filter);
1071 m_isBlocked = false;
1072 if (doRefresh) refresh();
1076 void Render::mltEditEffect(int track, GenTime position, QMap <QString, QString> args) {
1077 QString index = args.value("kdenlive_ix");
1078 QString tag = args.value("tag");
1079 QMap<QString, QString>::Iterator it = args.begin();
1080 if (it.key().startsWith("#") || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") {
1081 // This is a keyframe effect, to edit it, we remove it and re-add it.
1082 mltRemoveEffect(track, position, index);
1083 mltAddEffect(track, position, args);
1088 Mlt::Service service(m_mltProducer->parent().get_service());
1090 Mlt::Tractor tractor(service);
1091 Mlt::Producer trackProducer(tractor.track(track));
1092 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
1093 //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1094 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1096 kDebug() << "WARINIG, CANNOT FIND CLIP ON track: " << track << ", AT POS: " << position.frames(m_fps);
1097 m_isBlocked = false;
1101 Mlt::Service clipService(clip->get_service());
1103 // if (tag.startsWith("ladspa")) tag = "ladspa";
1106 Mlt::Filter *filter = clipService.filter(ct);
1108 if (filter->get("kdenlive_ix") == index) {
1112 filter = clipService.filter(ct);
1117 kDebug() << "WARINIG, FILTER FOR EDITING NOT FOUND, ADDING IT!!!!!";
1118 mltAddEffect(track, position, args);
1119 m_isBlocked = false;
1123 for (it = args.begin(); it != args.end(); ++it) {
1124 kDebug() << " / / EDITING EFFECT ARGS: " << it.key() << ": " << it.value();
1125 char *name = decodedString(it.key());
1126 char *value = decodedString(it.value());
1127 filter->set(name, value);
1131 m_isBlocked = false;
1135 void Render::mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out) {
1137 Mlt::Service service(m_mltProducer->parent().get_service());
1139 Mlt::Tractor tractor(service);
1140 Mlt::Producer trackProducer(tractor.track(track));
1141 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
1142 if (trackPlaylist.is_blank_at(pos.frames(m_fps) + 1))
1143 kDebug() << "//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
1144 int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps) + 1);
1146 int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
1147 int newDuration = out.frames(m_fps) - 1;
1149 kDebug() << " ** RESIZING CLIP END:" << clipIndex << " on track:" << track << ", mid pos: " << pos.frames(25) << ", in: " << in.frames(25) << ", out: " << out.frames(25) << ", PREVIOUS duration: " << previousDuration;
1150 trackPlaylist.resize_clip(clipIndex, in.frames(m_fps), newDuration);
1151 trackPlaylist.consolidate_blanks(0);
1152 if (previousDuration < newDuration) {
1153 // clip was made longer, trim next blank if there is one.
1154 if (trackPlaylist.is_blank(clipIndex + 1)) {
1155 trackPlaylist.split(clipIndex + 1, newDuration - previousDuration);
1156 trackPlaylist.remove(clipIndex + 1);
1158 } else trackPlaylist.insert_blank(clipIndex + 1, previousDuration - newDuration - 1);
1160 trackPlaylist.consolidate_blanks(0);
1161 tractor.multitrack()->refresh();
1163 if (track != 0) mltCheckLength();
1164 m_isBlocked = false;
1167 void Render::mltChangeTrackState(int track, bool mute, bool blind) {
1168 Mlt::Service service(m_mltProducer->parent().get_service());
1170 Mlt::Tractor tractor(service);
1171 Mlt::Producer trackProducer(tractor.track(track));
1172 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
1174 if (blind) trackProducer.set("hide", 3);
1175 else trackProducer.set("hide", 2);
1177 trackProducer.set("hide", 1);
1179 trackProducer.set("hide", 0);
1181 tractor.multitrack()->refresh();
1186 void Render::mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out) {
1188 Mlt::Service service(m_mltProducer->parent().get_service());
1189 int moveFrame = (moveEnd - moveStart).frames(m_fps);
1191 Mlt::Tractor tractor(service);
1192 Mlt::Producer trackProducer(tractor.track(track));
1193 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
1194 if (trackPlaylist.is_blank_at(pos.frames(m_fps) - 1))
1195 kDebug() << "//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
1196 int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps) - 1);
1197 kDebug() << " ** RESIZING CLIP START:" << clipIndex << " on track:" << track << ", mid pos: " << pos.frames(25) << ", moving: " << moveFrame << ", in: " << in.frames(25) << ", out: " << out.frames(25);
1199 trackPlaylist.resize_clip(clipIndex, in.frames(m_fps), out.frames(m_fps));
1200 if (moveFrame > 0) trackPlaylist.insert_blank(clipIndex, moveFrame - 1);
1202 int midpos = moveStart.frames(m_fps) - 1; //+ (moveFrame / 2)
1203 int blankIndex = trackPlaylist.get_clip_index_at(midpos);
1204 int blankLength = trackPlaylist.clip_length(blankIndex);
1206 kDebug() << " + resizing blank: " << blankIndex << ", Mid: " << midpos << ", Length: " << blankLength << ", SIZE DIFF: " << moveFrame;
1209 if (blankLength + moveFrame == 0) trackPlaylist.remove(blankIndex);
1210 else trackPlaylist.resize_clip(blankIndex, 0, blankLength + moveFrame - 1);
1212 trackPlaylist.consolidate_blanks(0);
1213 m_isBlocked = false;
1214 kDebug() << "-----------------\n" << "CLIP 0: " << trackPlaylist.clip_start(0) << ", LENGT: " << trackPlaylist.clip_length(0);
1215 kDebug() << "CLIP 1: " << trackPlaylist.clip_start(1) << ", LENGT: " << trackPlaylist.clip_length(1);
1216 kDebug() << "CLIP 2: " << trackPlaylist.clip_start(2) << ", LENGT: " << trackPlaylist.clip_length(2);
1217 kDebug() << "CLIP 3: " << trackPlaylist.clip_start(3) << ", LENGT: " << trackPlaylist.clip_length(3);
1218 kDebug() << "CLIP 4: " << trackPlaylist.clip_start(4) << ", LENGT: " << trackPlaylist.clip_length(4);
1221 void Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd) {
1222 mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps));
1226 void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd) {
1228 //m_mltConsumer->set("refresh", 0);
1229 Mlt::Service service(m_mltProducer->parent().get_service());
1231 Mlt::Tractor tractor(service);
1232 Mlt::Producer trackProducer(tractor.track(startTrack));
1233 Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
1234 int clipIndex = trackPlaylist.get_clip_index_at(moveStart + 1);
1235 mlt_field field = mlt_tractor_field(tractor.get_tractor());
1236 mlt_multitrack multitrack = mlt_field_multitrack(field); //mlt_tractor_multitrack(tractor.get_tractor());
1237 kDebug() << " -- CURRENT MULTIOTRACK HAS: " << mlt_multitrack_count(multitrack) << " tracks";;
1238 mlt_service multiprod = mlt_multitrack_service(multitrack);
1240 Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
1241 trackPlaylist.consolidate_blanks(0);
1242 mlt_events_block(MLT_PRODUCER_PROPERTIES(trackProducer.get_producer()), NULL);
1244 if (endTrack == startTrack) {
1245 if (!trackPlaylist.is_blank_at(moveEnd)) {
1246 kWarning() << "// ERROR, CLIP COLLISION----------";
1247 int ix = trackPlaylist.get_clip_index_at(moveEnd);
1248 kDebug() << "BAD CLIP STARTS AT: " << trackPlaylist.clip_start(ix) << ", LENGT: " << trackPlaylist.clip_length(ix);
1250 trackPlaylist.insert_at(moveEnd, clipProducer, 1);
1251 trackPlaylist.consolidate_blanks(0);
1253 trackPlaylist.consolidate_blanks(0);
1254 Mlt::Producer destTrackProducer(tractor.track(endTrack));
1255 Mlt::Playlist destTrackPlaylist((mlt_playlist) destTrackProducer.get_service());
1256 destTrackPlaylist.consolidate_blanks(1);
1257 destTrackPlaylist.insert_at(moveEnd, clipProducer, 1);
1258 destTrackPlaylist.consolidate_blanks(0);
1262 mlt_events_unblock(MLT_PRODUCER_PROPERTIES(trackProducer.get_producer()), NULL);
1263 m_isBlocked = false;
1264 m_mltConsumer->set("refresh", 1);
1267 void Render::mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut) {
1269 m_mltConsumer->set("refresh", 0);
1270 mlt_service serv = m_mltProducer->parent().get_service();
1272 mlt_service nextservice = mlt_service_get_producer(serv);
1273 mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
1274 QString mlt_type = mlt_properties_get(properties, "mlt_type");
1275 QString resource = mlt_properties_get(properties, "mlt_service");
1276 int old_pos = (oldIn.frames(m_fps) + oldOut.frames(m_fps)) / 2;
1278 int new_in = newIn.frames(m_fps);
1279 int new_out = newOut.frames(m_fps) - 1;
1280 while (mlt_type == "transition") {
1281 mlt_transition tr = (mlt_transition) nextservice;
1282 int currentTrack = mlt_transition_get_b_track(tr);
1283 int currentIn = (int) mlt_transition_get_in(tr);
1284 int currentOut = (int) mlt_transition_get_out(tr);
1285 kDebug() << "// FOUND EXISTING TRANS, IN: " << currentIn << ", OUT: " << currentOut << ", TRACK: " << currentTrack;
1286 //kDebug()<<"// LOOKING FOR IN: "<<old_in<<", OUT: "<<old_out;
1287 kDebug() << "// OLD IN: " << oldIn.frames(m_fps) << " // OLD OUT: " << oldOut.frames(m_fps) << ", TRACK: " << startTrack << ", MID POS: " << old_pos;
1288 if (resource == type && startTrack == currentTrack && currentIn <= old_pos && currentOut >= old_pos) {
1289 mlt_transition_set_in_and_out(tr, new_in, new_out);
1290 if (trackOffset != 0) {
1291 mlt_properties properties = MLT_TRANSITION_PROPERTIES(tr);
1292 mlt_properties_set_int(properties, "a_track", mlt_transition_get_a_track(tr) + trackOffset);
1293 mlt_properties_set_int(properties, "b_track", mlt_transition_get_b_track(tr) + trackOffset);
1297 nextservice = mlt_service_producer(nextservice);
1298 properties = MLT_SERVICE_PROPERTIES(nextservice);
1299 mlt_type = mlt_properties_get(properties, "mlt_type");
1300 resource = mlt_properties_get(properties, "mlt_service");
1302 m_isBlocked = false;
1305 void Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args) {
1307 Mlt::Service service(m_mltProducer->parent().get_service());
1309 Mlt::Tractor tractor(service);
1310 Mlt::Field *field = tractor.field();
1311 char *transId = decodedString(tag);
1312 Mlt::Transition *transition = new Mlt::Transition(*m_mltProfile, transId);
1313 transition->set_in_and_out((int) in.frames(m_fps), (int) out.frames(m_fps));
1314 QMap<QString, QString>::Iterator it;
1317 kDebug() << " ------ ADDING TRANSITION PARAMs: " << args.count();
1319 for (it = args.begin(); it != args.end(); ++it) {
1321 char *name = decodedString(key);
1322 char *value = decodedString(it.value());
1323 transition->set(name, value);
1324 kDebug() << " ------ ADDING TRANS PARAM: " << name << ": " << value;
1325 //filter->set("kdenlive_id", id);
1329 // attach filter to the clip
1330 field->plant_transition(*transition, a_track, b_track);
1332 m_isBlocked = false;
1337 void Render::mltSavePlaylist() {
1338 kWarning() << "// UPDATING PLAYLIST TO DISK++++++++++++++++";
1339 Mlt::Consumer *fileConsumer = new Mlt::Consumer(*m_mltProfile, "westley");
1340 fileConsumer->set("resource", "/home/one/playlist.xml");
1342 Mlt::Service service(m_mltProducer->get_service());
1343 Mlt::Tractor tractor(service);
1345 fileConsumer->connect(service);
1346 fileConsumer->start();
1350 #include "renderer.moc"