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>
41 #include <mlt++/Mlt.h>
46 Render::Render(const QString & rendererName, QWidget *parent):QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_sceneList(QDomDocument()), m_winid(-1), m_framePosition(0), m_generateScenelist(false), isBlocked(true)
48 refreshTimer = new QTimer( this );
49 connect( refreshTimer, SIGNAL(timeout()), this, SLOT( refresh()) );
51 m_connectTimer = new QTimer( this );
52 connect( m_connectTimer, SIGNAL(timeout()), this, SLOT(connectPlaylist()) );
54 if (rendererName == "project") m_monitorId = 10000;
55 else m_monitorId = 10001;
56 osdTimer = new QTimer( this );
57 connect( osdTimer, SIGNAL(timeout()), this, SLOT(slotOsdTimeout()) );
59 m_osdProfile = KStandardDirs::locate("data", "kdenlive/profiles/metadata.properties");
60 /*m_osdInfo = new Mlt::Filter("data_show");
61 char *tmp = decodedString(m_osdProfile);
62 m_osdInfo->set("resource", tmp);
64 // Does it do anything usefull? I mean, RenderThread doesn't do anything useful at the moment
65 // (except being cpu hungry :)
67 /* if(!s_renderThread) {
68 s_renderThread = new RenderThread;
69 s_renderThread->start();
79 void Render::closeMlt()
81 delete m_connectTimer;
93 static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr)
95 // detect if the producer has finished playing. Is there a better way to do it ?
96 //if (self->isBlocked) return;
97 if (mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame_ptr ), "_speed" ) == 0.0) {
98 self->emitConsumerStopped();
101 self->emitFrameNumber(mlt_frame_get_position(frame_ptr));
105 /** Wraps the VEML command of the same name; requests that the renderer
106 should create a video window. If show is true, then the window should be
107 displayed, otherwise it should be hidden. Render will emit the signal
108 replyCreateVideoXWindow() once the renderer has replied. */
110 void Render::createVideoXWindow(WId winid, WId externalMonitor)
113 delete m_mltConsumer;
116 m_mltConsumer = new Mlt::Consumer("sdl_preview");
117 if (!m_mltConsumer || !m_mltConsumer->is_valid()) {
118 KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install.\n Exiting now..."));
119 kError()<<"Sorry, cannot create MLT consumer, check your MLT install you miss SDL libraries support in MLT";
123 //only as is saw, if we want to lock something with the sdl lock
124 /*if (!KdenliveSettings::videoprofile().isEmpty())
125 m_mltConsumer->set("profile", KdenliveSettings::videoprofile().ascii());*/
127 m_mltConsumer->set("profile", "hdv_1080_50i"); //KdenliveSettings::videoprofile().ascii());
128 /*m_mltConsumer->set("app_locked", 1);
129 m_mltConsumer->set("app_lock", (void *) &my_lock, 0);
130 m_mltConsumer->set("app_unlock", (void *) &my_unlock, 0);*/
131 m_externalwinid = (int) externalMonitor;
132 m_winid = (int) winid;
134 m_mltConsumer->set("window_id", m_winid);
135 m_mltConsumer->set("resize", 1);
137 m_mltConsumer->set("terminate_on_pause", 1);
138 /*QString aDevice = KdenliveSettings::audiodevice();
139 if (!KdenliveSettings::videodriver().isEmpty()) m_mltConsumer->set("video_driver", KdenliveSettings::videodriver().ascii());
140 if (!KdenliveSettings::audiodriver().isEmpty()) m_mltConsumer->set("audio_driver", KdenliveSettings::audiodriver().ascii());
141 m_mltConsumer->set("audio_device", aDevice.section(";", 1).ascii());*/
142 m_mltConsumer->set("progressive", 1);
143 m_mltConsumer->set("audio_buffer", 1024);
144 m_mltConsumer->set("frequency", 48000);
146 m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
147 //m_mltConsumer->start();
150 //QTimer::singleShot(500, this, SLOT(initSceneList()));
152 // m_mltConsumer->listen("consumer-stopped", this, (mlt_listener) consumer_stopped);
153 // m_mltConsumer->set("buffer", 25);
157 int Render::resetRendererProfile(char * profile)
159 if (!m_mltConsumer) return 0;
160 if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
161 m_mltConsumer->set("refresh", 0);
162 m_mltConsumer->set("profile", profile);
163 kDebug()<<" + + RESET CONSUMER WITH PROFILE: "<<profile;
165 m_mltConsumer->set("fps", m_fps);
166 mlt_properties properties = MLT_CONSUMER_PROPERTIES( m_mltConsumer->get_consumer() );
167 int result = mlt_consumer_profile( properties, profile );
172 void Render::restartConsumer()
174 if (m_winid != -1) createVideoXWindow( m_winid, m_externalwinid);
177 /** Wraps the VEML command of the same name; Seeks the renderer clip to the given time. */
178 void Render::seek(GenTime time)
180 sendSeekCommand(time);
181 //emit positionChanged(time);
185 char *Render::decodedString(QString str)
187 /*QCString fn = QFile::encodeName(str);
188 char *t = new char[fn.length() + 1];
189 strcpy(t, (const char *)fn);*/
191 return qstrdup( str.toLatin1().data() );
195 QPixmap Render::frameThumbnail(Mlt::Frame *frame, int width, int height, bool border)
197 QPixmap pix(width, height);
199 mlt_image_format format = mlt_image_rgb24a;
200 uint8_t *thumb = frame->get_image(format, width, height);
201 QImage image(thumb, width, height, QImage::Format_ARGB32);
203 if (!image.isNull()) {
204 pix = pix.fromImage(image);
206 QPainter painter(&pix);
207 painter.drawRect(0, 0, width - 1, height - 1);
210 else pix.fill(Qt::black);
215 QPixmap Render::extractFrame(int frame_position, int width, int height)
217 QPixmap pix(width, height);
218 if (!m_mltProducer) {
222 Mlt::Producer *mlt_producer = m_mltProducer->cut(frame_position, frame_position + 1);
223 Mlt::Filter m_convert("avcolour_space");
224 m_convert.set("forced", mlt_image_rgb24a);
225 mlt_producer->attach(m_convert);
226 Mlt::Frame *frame = mlt_producer->get_frame();
229 pix = frameThumbnail(frame, width, height);
232 else pix.fill(Qt::black);
237 QPixmap Render::getImageThumbnail(KUrl url, int width, int height)
241 if (url.fileName().startsWith(".all.")) { // check for slideshow
242 QString fileType = url.fileName().right(3);
244 QStringList::Iterator it;
246 QDir dir( url.directory() );
247 more = dir.entryList( QDir::Files );
249 for ( it = more.begin() ; it != more.end() ; ++it ) {
250 if ((*it).endsWith("."+fileType, Qt::CaseInsensitive)) {
251 im.load(url.directory() + "/" + *it);
256 else im.load(url.path());
257 //pixmap = im.scaled(width, height);
262 QPixmap Render::getVideoThumbnail(QString file, int frame_position, int width, int height)
264 QPixmap pix(width, height);
265 char *tmp = decodedString(file);
266 Mlt::Producer m_producer(tmp);
268 if (m_producer.is_blank()) {
273 Mlt::Filter m_convert("avcolour_space");
274 m_convert.set("forced", mlt_image_rgb24a);
275 m_producer.attach(m_convert);
276 m_producer.seek(frame_position);
277 Mlt::Frame * frame = m_producer.get_frame();
279 pix = frameThumbnail(frame, width, height, true);
286 void Render::getImage(KUrl url, int frame_position, QPoint size)
288 char *tmp = decodedString(url.path());
289 Mlt::Producer m_producer(tmp);
291 if (m_producer.is_blank()) {
294 Mlt::Filter m_convert("avcolour_space");
295 m_convert.set("forced", mlt_image_rgb24a);
296 m_producer.attach(m_convert);
297 m_producer.seek(frame_position);
299 Mlt::Frame * frame = m_producer.get_frame();
302 QPixmap pix = frameThumbnail(frame, size.x(), size.y(), true);
304 emit replyGetImage(url, frame_position, pix, size.x(), size.y());
308 /* Create thumbnail for color */
309 /*void Render::getImage(int id, QString color, QPoint size)
311 QPixmap pixmap(size.x() - 2, size.y() - 2);
312 color = color.replace(0, 2, "#");
313 color = color.left(7);
314 pixmap.fill(QColor(color));
315 QPixmap result(size.x(), size.y());
316 result.fill(Qt::black);
317 //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
318 emit replyGetImage(id, result, size.x(), size.y());
322 /* Create thumbnail for image */
323 /*void Render::getImage(KUrl url, QPoint size)
327 if (url.fileName().startsWith(".all.")) { // check for slideshow
328 QString fileType = url.fileName().right(3);
330 QStringList::Iterator it;
332 QDir dir( url.directory() );
333 more = dir.entryList( QDir::Files );
334 for ( it = more.begin() ; it != more.end() ; ++it ) {
335 if ((*it).endsWith("."+fileType, Qt::CaseInsensitive)) {
336 if (!im.load(url.directory() + "/" + *it))
337 kDebug()<<"++ ERROR LOADIN IMAGE: "<<url.directory() + "/" + *it;
342 else im.load(url.path());
344 //pixmap = im.smoothScale(size.x() - 2, size.y() - 2);
345 QPixmap result(size.x(), size.y());
346 result.fill(Qt::black);
347 //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
348 emit replyGetImage(url, 1, result, size.x(), size.y());
352 double Render::consumerRatio() const
354 if (!m_mltConsumer) return 1.0;
355 return (m_mltConsumer->get_double("aspect_ratio_num")/m_mltConsumer->get_double("aspect_ratio_den"));
359 int Render::getLength()
364 // kDebug()<<"////// LENGTH: "<<mlt_producer_get_playtime(m_mltProducer->get_producer());
365 return mlt_producer_get_playtime(m_mltProducer->get_producer());
370 bool Render::isValid(KUrl url)
372 char *tmp = decodedString(url.path());
373 Mlt::Producer producer(tmp);
375 if (producer.is_blank())
381 void Render::getFileProperties(const QDomElement &xml, int clipId)
384 int width = height * 16/9.0; //KdenliveSettings::displayratio();
386 QDomElement westley = doc.createElement("westley");
387 doc.appendChild(westley);
388 westley.appendChild(doc.importNode(xml, true));
389 kDebug()<<"////////////\n"<<doc.toString()<<"////////////////\n";
390 char *tmp = decodedString(doc.toString());
392 Mlt::Producer producer("westley-xml", tmp);
395 if (producer.is_blank()) {
398 int frameNumber = xml.attribute( "frame_thumbnail", 0).toInt();
399 if ( frameNumber != 0 ) producer.seek( frameNumber );
400 mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer.get_producer() );
402 QMap < QString, QString > filePropertyMap;
403 QMap < QString, QString > metadataPropertyMap;
405 KUrl url = xml.attribute("resource", QString::null);
406 filePropertyMap["filename"] = url.path();
407 filePropertyMap["duration"] = QString::number(producer.get_playtime());
409 Mlt::Filter m_convert("avcolour_space");
410 m_convert.set("forced", mlt_image_rgb24a);
411 producer.attach(m_convert);
412 producer.set("profile", "hdv_1080_50i");
413 Mlt::Frame * frame = producer.get_frame();
415 if (frame->is_valid()) {
416 filePropertyMap["fps"] =
417 QString::number(mlt_producer_get_fps( producer.get_producer() ));
418 filePropertyMap["width"] =
419 QString::number(frame->get_int("width"));
420 filePropertyMap["height"] =
421 QString::number(frame->get_int("height"));
422 filePropertyMap["frequency"] =
423 QString::number(frame->get_int("frequency"));
424 filePropertyMap["channels"] =
425 QString::number(frame->get_int("channels"));
427 // Retrieve audio / video codec name
429 // Fetch the video_context
430 AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data( properties, "video_context", NULL );
431 if (context != NULL) {
432 // Get the video_index
433 int index = mlt_properties_get_int( properties, "video_index" );
434 filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
436 context = (AVFormatContext *) mlt_properties_get_data( properties, "audio_context", NULL );
437 if (context != NULL) {
438 // Get the video_index
439 int index = mlt_properties_get_int( properties, "audio_index" );
440 filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
447 mlt_properties metadata = mlt_properties_new( );
448 mlt_properties_pass( metadata, properties, "meta.attr." );
449 int count = mlt_properties_count( metadata );
450 for ( int i = 0; i < count; i ++ )
452 QString name = mlt_properties_get_name( metadata, i );
453 QString value = QString::fromUtf8(mlt_properties_get_value( metadata, i ));
454 if (name.endsWith("markup") && !value.isEmpty())
455 metadataPropertyMap[ name.section(".", 0, -2) ] = value;
458 if (frame->get_int("test_image") == 0) {
459 if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
460 filePropertyMap["type"] = "playlist";
461 metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get( MLT_SERVICE_PROPERTIES( producer.get_service() ), "title"));
463 else if (frame->get_int("test_audio") == 0)
464 filePropertyMap["type"] = "av";
466 filePropertyMap["type"] = "video";
468 // Generate thumbnail for this frame
469 QPixmap pixmap = frameThumbnail(frame, width, height, true);
471 emit replyGetImage(clipId, 0, pixmap, width, height);
473 } else if (frame->get_int("test_audio") == 0) {
474 QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
475 emit replyGetImage(clipId, 0, pixmap, width, height);
476 filePropertyMap["type"] = "audio";
479 emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
480 kDebug()<<"REquested fuile info for: "<<url.path();
484 QDomDocument Render::sceneList() const
489 /** Create the producer from the Westley QDomDocument */
490 void Render::initSceneList()
492 kDebug()<<"-------- INIT SCENE LIST ------_";
494 QDomElement westley = doc.createElement("westley");
495 doc.appendChild(westley);
496 QDomElement prod = doc.createElement("producer");
497 prod.setAttribute("resource", "colour");
498 prod.setAttribute("colour", "red");
499 prod.setAttribute("id", "black");
500 prod.setAttribute("in", "0");
501 prod.setAttribute("out", "0");
503 QDomElement tractor = doc.createElement("tractor");
504 QDomElement multitrack = doc.createElement("multitrack");
506 QDomElement playlist1 = doc.createElement("playlist");
507 playlist1.appendChild(prod);
508 multitrack.appendChild(playlist1);
509 QDomElement playlist2 = doc.createElement("playlist");
510 multitrack.appendChild(playlist2);
511 QDomElement playlist3 = doc.createElement("playlist");
512 multitrack.appendChild(playlist3);
513 QDomElement playlist4 = doc.createElement("playlist");
514 multitrack.appendChild(playlist4);
515 QDomElement playlist5 = doc.createElement("playlist");
516 multitrack.appendChild(playlist5);
517 tractor.appendChild(multitrack);
518 westley.appendChild(tractor);
519 // kDebug()<<doc.toString();
521 QString tmp = QString("<westley><producer resource=\"colour\" colour=\"red\" id=\"red\" /><tractor><multitrack><playlist></playlist><playlist></playlist><playlist /><playlist /><playlist></playlist></multitrack></tractor></westley>");*/
522 setSceneList(doc, 0);
526 /** Create the producer from the Westley QDomDocument */
527 void Render::setSceneList(QDomDocument list, int position)
529 if (m_winid == -1) return;
530 m_generateScenelist = true;
532 kWarning()<<"////// RENDER, SET SCENE LIST";
535 char *tmp = decodedString(list.toString());
537 Mlt::Producer clip("westley-xml", tmp);
540 if (!clip.is_valid()) {
541 kWarning()<<" ++++ WARNING, UNABLE TO CREATE MLT PRODUCER";
542 m_generateScenelist = false;
549 m_mltConsumer->set("refresh", 0);
550 if (!m_mltConsumer->is_stopped()) {
551 //emitConsumerStopped();
552 m_mltConsumer->stop();
557 m_mltProducer->set_speed(0.0);
559 //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
561 delete m_mltProducer;
562 m_mltProducer = NULL;
566 m_mltProducer = new Mlt::Producer(clip); //track.current();
567 m_mltProducer->optimise();
568 if (position != 0) m_mltProducer->seek(position);
570 /*if (KdenliveSettings::osdtimecode()) {
571 // Attach filter for on screen display of timecode
573 QString attr = "attr_check";
574 mlt_filter filter = mlt_factory_filter( "data_feed", (char*) attr.ascii() );
575 mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_fezzik", 1 );
576 mlt_producer_attach( m_mltProducer->get_producer(), filter );
577 mlt_filter_close( filter );
579 m_osdInfo = new Mlt::Filter("data_show");
580 tmp = decodedString(m_osdProfile);
581 m_osdInfo->set("resource", tmp);
583 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
584 mlt_properties_set_int( properties, "meta.attr.timecode", 1);
585 mlt_properties_set( properties, "meta.attr.timecode.markup", "#timecode#");
586 m_osdInfo->set("dynamic", "1");
588 if (m_mltProducer->attach(*m_osdInfo) == 1) kDebug()<<"////// error attaching filter";
590 m_osdInfo->set("dynamic", "0");
593 m_fps = m_mltProducer->get_fps();
594 if (!m_mltConsumer) {
597 emit playListDuration( (int) m_mltProducer->get_playtime());
598 m_connectTimer->start( 500 );
599 m_generateScenelist = false;
603 const double Render::fps() const
608 void Render::connectPlaylist() {
609 kDebug()<<"************** CONNECTING PLAYLIST";
610 m_connectTimer->stop();
611 if (m_mltConsumer->start() == -1) {
612 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."));
613 m_mltConsumer = NULL;
616 m_mltConsumer->connect(*m_mltProducer);
617 m_mltProducer->set_speed(0.0);
622 void Render::refreshDisplay() {
624 if (!m_mltProducer) return;
625 m_mltConsumer->set("refresh", 0);
627 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
628 /*if (KdenliveSettings::osdtimecode()) {
629 mlt_properties_set_int( properties, "meta.attr.timecode", 1);
630 mlt_properties_set( properties, "meta.attr.timecode.markup", "#timecode#");
631 m_osdInfo->set("dynamic", "1");
632 m_mltProducer->attach(*m_osdInfo);
635 m_mltProducer->detach(*m_osdInfo);
636 m_osdInfo->set("dynamic", "0");
641 void Render::setVolume(double volume)
643 if (!m_mltConsumer || !m_mltProducer) return;
645 m_mltConsumer->set("refresh", 0);
646 // Attach filter for on screen display of timecode
647 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
648 mlt_properties_set_double( properties, "meta.volume", volume );
649 mlt_properties_set_int( properties, "meta.attr.osdvolume", 1);
650 mlt_properties_set( properties, "meta.attr.osdvolume.markup", i18n("Volume: ") + QString::number(volume * 100));
652 if (!KdenliveSettings::osdtimecode()) {
653 m_mltProducer->detach(*m_osdInfo);
654 mlt_properties_set_int( properties, "meta.attr.timecode", 0);
655 if (m_mltProducer->attach(*m_osdInfo) == 1) kDebug()<<"////// error attaching filter";
658 osdTimer->setSingleShot(2500 );
661 void Render::slotOsdTimeout()
663 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
664 mlt_properties_set_int(properties, "meta.attr.osdvolume", 0);
665 mlt_properties_set(properties, "meta.attr.osdvolume.markup", NULL);
666 //if (!KdenliveSettings::osdtimecode()) m_mltProducer->detach(*m_osdInfo);
672 if (!m_mltConsumer || m_winid == -1) {
677 if (m_mltConsumer->is_stopped()) {
678 if (m_mltConsumer->start() == -1) {
679 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."));
680 m_mltConsumer = NULL;
693 m_mltConsumer->set("refresh", 0);
694 if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
698 //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
699 m_mltProducer->set_speed(0.0);
700 delete m_mltProducer;
701 m_mltProducer = NULL;
708 kDebug()<<"///////////// RENDER STOP-------";
709 if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
710 m_mltConsumer->set("refresh", 0);
711 // m_mltConsumer->stop();
713 kDebug()<<"///////////// RENDER STOP2-------";
717 m_mltProducer->set_speed(0.0);
718 m_mltProducer->set("out", m_mltProducer->get_length() - 1);
720 kDebug()<<"///////////// RENDER STOP3-------";
723 void Render::stop(const GenTime & startTime)
725 kDebug()<<"///////////// RENDER STOP-------2";
727 m_mltProducer->set_speed(0.0);
728 m_mltProducer->seek((int) startTime.frames(m_fps));
730 m_mltConsumer->purge();
733 void Render::switchPlay()
737 if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0);
739 m_mltProducer->set_speed(0.0);
740 kDebug()<<"// POSITON: "<<m_framePosition;
741 m_mltProducer->seek((int) m_framePosition);
744 /*if (speed == 0.0) {
745 m_mltProducer->seek((int) m_framePosition + 1);
746 m_mltConsumer->purge();
751 void Render::play(double speed)
755 if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1);
756 m_mltProducer->set_speed(speed);
757 /*if (speed == 0.0) {
758 m_mltProducer->seek((int) m_framePosition + 1);
759 m_mltConsumer->purge();
764 void Render::play(double speed, const GenTime & startTime)
766 kDebug()<<"///////////// RENDER PLAY2-------"<<speed;
769 //m_mltProducer->set("out", m_mltProducer->get_length() - 1);
770 //if (speed == 0.0) m_mltConsumer->set("refresh", 0);
771 m_mltProducer->set_speed(speed);
772 m_mltProducer->seek((int) (startTime.frames(m_fps)));
773 //m_mltConsumer->purge();
777 void Render::play(double speed, const GenTime & startTime,
778 const GenTime & stopTime)
780 kDebug()<<"///////////// RENDER PLAY3-------"<<speed;
783 m_mltProducer->set("out", stopTime.frames(m_fps));
784 m_mltProducer->seek((int) (startTime.frames(m_fps)));
785 m_mltConsumer->purge();
786 m_mltProducer->set_speed(speed);
790 void Render::render(const KUrl & url)
793 QDomElement elem = doc.createElement("render");
794 elem.setAttribute("filename", url.path());
795 doc.appendChild(elem);
798 void Render::sendSeekCommand(GenTime time)
802 //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
803 m_mltProducer->seek((int) (time.frames(m_fps)));
807 void Render::seekToFrame(int pos)
811 //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
812 m_mltProducer->seek(pos);
816 void Render::askForRefresh()
818 // Use a Timer so that we don't refresh too much
819 refreshTimer->start( 200 );
822 void Render::refresh()
826 refreshTimer->stop();
828 m_mltConsumer->set("refresh", 1);
832 /** Sets the description of this renderer to desc. */
833 void Render::setDescription(const QString & description)
835 m_description = description;
838 /** Returns the description of this renderer */
839 QString Render::description()
841 return m_description;
845 double Render::playSpeed()
847 if (m_mltProducer) return m_mltProducer->get_speed();
851 const GenTime & Render::seekPosition() const
853 if (m_mltProducer) return GenTime((int) m_mltProducer->position(), m_fps);
854 else return GenTime();
858 const QString & Render::rendererName() const
864 void Render::emitFrameNumber(double position)
866 //kDebug()<<"// POSITON: "<<m_framePosition;
867 if (m_generateScenelist) return;
868 m_framePosition = position;
869 emit rendererPosition((int) position);
870 //if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent( GenTime((int) position, m_fps), m_monitorId));
873 void Render::emitConsumerStopped()
875 // This is used to know when the playing stopped
876 if (m_mltProducer && !m_generateScenelist) {
877 double pos = m_mltProducer->position();
878 emit rendererStopped((int) pos);
879 //if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent(GenTime((int) pos, m_fps), m_monitorId + 100));
880 //new QCustomEvent(10002));
886 void Render::exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime)
888 KMessageBox::sorry(0, i18n("Firewire is not enabled on your system.\n Please install Libiec61883 and recompile Kdenlive"));
892 void Render::exportCurrentFrame(KUrl url, bool notify) {
893 if (!m_mltProducer) {
894 KMessageBox::sorry(qApp->activeWindow(), i18n("There is no clip, cannot extract frame."));
898 int height = 1080;//KdenliveSettings::defaultheight();
899 int width = 1940; //KdenliveSettings::displaywidth();
901 QPixmap pix(width, height);
903 Mlt::Filter m_convert("avcolour_space");
904 m_convert.set("forced", mlt_image_rgb24a);
905 m_mltProducer->attach(m_convert);
906 Mlt::Frame * frame = m_mltProducer->get_frame();
907 m_mltProducer->detach(m_convert);
909 pix = frameThumbnail(frame, width, height);
912 pix.save(url.path(), "PNG");
913 //if (notify) QApplication::postEvent(qApp->activeWindow(), new UrlEvent(url, 10003));
916 /** MLT PLAYLIST DIRECT MANIPULATON **/
919 void Render::mltCheckLength()
921 //kDebug()<<"checking track length: "<<track<<"..........";
922 Mlt::Service service(m_mltProducer->get_service());
923 Mlt::Tractor tractor(service);
925 int trackNb = tractor.count( );
927 double trackDuration;
929 Mlt::Producer trackProducer(tractor.track(0));
930 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
931 duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
932 m_mltProducer->set("out", duration);
933 emit durationChanged();
936 while (trackNb > 1) {
937 Mlt::Producer trackProducer(tractor.track(trackNb - 1));
938 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
939 trackDuration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
941 kDebug()<<" / / /DURATON FOR TRACK "<<trackNb - 1<<" = "<<trackDuration;
942 if (trackDuration > duration) duration = trackDuration;
946 Mlt::Producer blackTrackProducer(tractor.track(0));
947 Mlt::Playlist blackTrackPlaylist(( mlt_playlist ) blackTrackProducer.get_service());
948 double blackDuration = Mlt::Producer(blackTrackPlaylist.get_producer()).get_playtime() - 1;
949 kDebug()<<" / / /DURATON FOR TRACK 0 = "<<blackDuration;
950 if (blackDuration != duration) {
951 blackTrackPlaylist.remove_region( 0, blackDuration );
955 while (dur > 14000) { // <producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" />
956 mltInsertClip(0, GenTime(i * 14000, m_fps), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" /></westley>"));
961 mltInsertClip(0, GenTime(), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"" + QString::number(dur) + "\" /></westley>"));
963 m_mltProducer->set("out", duration);
964 emit durationChanged();
969 void Render::mltInsertClip(int track, GenTime position, QString resource)
971 if (!m_mltProducer) {
972 kDebug()<<"PLAYLISTÂ NOT INITIALISED //////";
975 Mlt::Producer parentProd(m_mltProducer->parent());
976 if (parentProd.get_producer() == NULL) {
977 kDebug()<<"PLAYLISTÂ BROKEN, CANNOT INSERTÂ CLIP //////";
980 Mlt::Service service(parentProd.get_service());
981 Mlt::Tractor tractor(service);
983 Mlt::Producer trackProducer(tractor.track(track));
984 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
985 char *tmp = decodedString(resource);
986 Mlt::Producer clip("westley-xml", tmp);
987 //clip.set_in_and_out(in.frames(m_fps), out.frames(m_fps));
990 trackPlaylist.insert_at(position.frames(m_fps), clip, 1);
991 tractor.multitrack()->refresh();
993 if (track != 0) mltCheckLength();
994 double duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime();
995 kDebug()<<"// + +INSERTING CLIP: "<<resource<<" AT: "<<position.frames(m_fps)<<" on track: "<<track<<", DURATION: "<<duration;
1000 void Render::mltCutClip(int track, GenTime position)
1002 Mlt::Service service(m_mltProducer->parent().get_service());
1003 if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
1004 if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
1005 if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
1006 if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
1008 Mlt::Tractor tractor(service);
1009 Mlt::Producer trackProducer(tractor.track(track));
1010 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1011 trackPlaylist.split_at(position.frames(m_fps));
1012 trackPlaylist.consolidate_blanks(0);
1013 kDebug()<<"/ / / /CUTTING CLIP AT: "<<position.frames(m_fps);
1017 void Render::mltRemoveClip(int track, GenTime position)
1019 Mlt::Service service(m_mltProducer->parent().get_service());
1020 if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
1021 if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
1022 if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
1023 if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
1025 Mlt::Tractor tractor(service);
1026 Mlt::Producer trackProducer(tractor.track(track));
1027 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1028 int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1029 //trackPlaylist.remove(clipIndex);
1030 trackPlaylist.replace_with_blank(clipIndex);
1031 trackPlaylist.consolidate_blanks(0);
1032 if (track != 0) mltCheckLength();
1033 //emit durationChanged();
1036 void Render::mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index)
1038 Mlt::Service service(m_mltProducer->parent().get_service());
1040 Mlt::Tractor tractor(service);
1041 Mlt::Producer trackProducer(tractor.track(track));
1042 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1043 //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1044 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1046 kDebug()<<" / / / CANNOT FIND CLIP TO REMOVE EFFECT";
1049 Mlt::Service clipService(clip->get_service());
1051 if (tag.startsWith("ladspa")) tag = "ladspa";
1055 Mlt::Filter *filter = clipService.filter( ct );
1057 if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) {
1058 clipService.detach(*filter);
1059 kDebug()<<" / / / DLEETED EFFECT: "<<ct;
1062 filter = clipService.filter( ct );
1066 Mlt::Filter *filter = clipService.filter( index );
1067 if (filter && filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) clipService.detach(*filter);
1069 kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
1076 void Render::mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args)
1078 Mlt::Service service(m_mltProducer->parent().get_service());
1080 Mlt::Tractor tractor(service);
1081 Mlt::Producer trackProducer(tractor.track(track));
1082 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1084 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1087 kDebug()<<"********** CANNOT FIND CLIP TO APPLY EFFECT-----------";
1090 Mlt::Service clipService(clip->get_service());
1093 kDebug()<<" / / INSERTING EFFECT: "<<id;
1094 if (tag.startsWith("ladspa")) tag = "ladspa";
1095 char *filterId = decodedString(tag);
1096 Mlt::Filter *filter = new Mlt::Filter(filterId);
1097 filter->set("kdenlive_id", filterId);
1099 QMap<QString, QString>::Iterator it;
1100 QString keyFrameNumber = "#0";
1102 for ( it = args.begin(); it != args.end(); ++it ) {
1103 //kDebug()<<" / / INSERTING EFFECT ARGS: "<<it.key()<<": "<<it.data();
1105 QString currentKeyFrameNumber;
1106 if (it.key().startsWith("#")) {
1107 currentKeyFrameNumber = it.key().section(":", 0, 0);
1108 if (currentKeyFrameNumber != keyFrameNumber) {
1109 // attach filter to the clip
1110 clipService.attach(*filter);
1111 filter = new Mlt::Filter(filterId);
1112 filter->set("kdenlive_id", filterId);
1113 keyFrameNumber = currentKeyFrameNumber;
1115 key = it.key().section(":", 1);
1117 else key = it.key();
1118 char *name = decodedString(key);
1119 char *value = decodedString(it.value());
1120 filter->set(name, value);
1124 // attach filter to the clip
1125 clipService.attach(*filter);
1131 void Render::mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args)
1133 QMap<QString, QString>::Iterator it = args.begin();
1134 if (it.key().startsWith("#") || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") {
1135 // This is a keyframe effect, to edit it, we remove it and re-add it.
1136 mltRemoveEffect(track, position, id, tag, -1);
1137 mltAddEffect(track, position, id, tag, args);
1142 Mlt::Service service(m_mltProducer->parent().get_service());
1144 Mlt::Tractor tractor(service);
1145 Mlt::Producer trackProducer(tractor.track(track));
1146 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1147 //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1148 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1149 Mlt::Service clipService(clip->get_service());
1150 Mlt::Filter *filter = clipService.filter( index );
1153 if (!filter || filter->get("mlt_service") != tag) {
1154 kDebug()<<"WARINIG, FILTER NOT FOUND!!!!!";
1156 filter = clipService.filter( index );
1158 if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) break;
1160 filter = clipService.filter( index );
1164 kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
1168 for ( it = args.begin(); it != args.end(); ++it ) {
1169 kDebug()<<" / / INSERTING EFFECT ARGS: "<<it.key()<<": "<<it.value();
1170 char *name = decodedString(it.key());
1171 char *value = decodedString(it.value());
1172 filter->set(name, value);
1179 void Render::mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out)
1181 Mlt::Service service(m_mltProducer->parent().get_service());
1183 Mlt::Tractor tractor(service);
1184 Mlt::Producer trackProducer(tractor.track(track));
1185 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1186 if (trackPlaylist.is_blank_at(pos.frames(m_fps) + 1))
1187 kDebug()<<"//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
1188 int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps) + 1);
1190 int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
1191 int newDuration = out.frames(m_fps) - 1;
1193 kDebug()<<" ** RESIZING CLIP END:" << clipIndex << " on track:"<< track <<", mid pos: "<<pos.frames(25)<<", in: "<<in.frames(25)<<", out: "<<out.frames(25)<<", PREVIOUS duration: "<<previousDuration;
1194 trackPlaylist.resize_clip(clipIndex, in.frames(m_fps), newDuration);
1195 trackPlaylist.consolidate_blanks(0);
1196 if (previousDuration < newDuration) {
1197 // clip was made longer, trim next blank if there is one.
1198 if (trackPlaylist.is_blank(clipIndex + 1)) {
1199 trackPlaylist.split(clipIndex + 1, newDuration - previousDuration);
1200 trackPlaylist.remove(clipIndex + 1);
1203 else trackPlaylist.insert_blank(clipIndex + 1, previousDuration - newDuration - 1);
1205 trackPlaylist.consolidate_blanks(0);
1206 tractor.multitrack()->refresh();
1208 if (track != 0) mltCheckLength();
1212 void Render::mltChangeTrackState(int track, bool mute, bool blind)
1214 Mlt::Service service(m_mltProducer->parent().get_service());
1216 Mlt::Tractor tractor(service);
1217 Mlt::Producer trackProducer(tractor.track(track));
1218 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1220 if (blind) trackProducer.set("hide", 3);
1221 else trackProducer.set("hide", 2);
1224 trackProducer.set("hide", 1);
1227 trackProducer.set("hide", 0);
1229 tractor.multitrack()->refresh();
1234 void Render::mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out)
1236 Mlt::Service service(m_mltProducer->parent().get_service());
1237 if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
1238 if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
1239 if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
1240 if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
1242 int moveFrame = (moveEnd - moveStart).frames(m_fps);
1244 Mlt::Tractor tractor(service);
1245 Mlt::Producer trackProducer(tractor.track(track));
1246 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1247 if (trackPlaylist.is_blank_at(pos.frames(m_fps) - 1))
1248 kDebug()<<"//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
1249 int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps) - 1);
1250 kDebug()<<" ** RESIZING CLIP START:" << clipIndex << " on track:"<< track <<", mid pos: "<<pos.frames(25)<<", moving: "<<moveFrame<<", in: "<<in.frames(25)<<", out: "<<out.frames(25);
1252 trackPlaylist.resize_clip(clipIndex, in.frames(m_fps), out.frames(m_fps));
1253 if (moveFrame > 0) trackPlaylist.insert_blank(clipIndex, moveFrame - 1);
1255 int midpos = moveStart.frames(m_fps) - 1; //+ (moveFrame / 2)
1256 int blankIndex = trackPlaylist.get_clip_index_at(midpos);
1257 int blankLength = trackPlaylist.clip_length(blankIndex);
1259 kDebug()<<" + resizing blank: "<<blankIndex<<", Mid: "<<midpos<<", Length: "<<blankLength<< ", SIZE DIFF: "<<moveFrame;
1262 if (blankLength + moveFrame == 0) trackPlaylist.remove(blankIndex);
1263 else trackPlaylist.resize_clip(blankIndex, 0, blankLength + moveFrame -1);
1265 trackPlaylist.consolidate_blanks(0);
1267 kDebug()<<"-----------------\n"<<"CLIP 0: "<<trackPlaylist.clip_start(0)<<", LENGT: "<<trackPlaylist.clip_length(0);
1268 kDebug()<<"CLIP 1: "<<trackPlaylist.clip_start(1)<<", LENGT: "<<trackPlaylist.clip_length(1);
1269 kDebug()<<"CLIP 2: "<<trackPlaylist.clip_start(2)<<", LENGT: "<<trackPlaylist.clip_length(2);
1270 kDebug()<<"CLIP 3: "<<trackPlaylist.clip_start(3)<<", LENGT: "<<trackPlaylist.clip_length(3);
1271 kDebug()<<"CLIP 4: "<<trackPlaylist.clip_start(4)<<", LENGT: "<<trackPlaylist.clip_length(4);
1274 void Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd)
1276 mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps));
1280 void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd)
1282 m_mltConsumer->set("refresh", 0);
1283 Mlt::Service service(m_mltProducer->parent().get_service());
1285 Mlt::Tractor tractor(service);
1286 Mlt::Producer trackProducer(tractor.track(startTrack));
1287 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1288 int clipIndex = trackPlaylist.get_clip_index_at(moveStart + 1);
1291 mlt_field field = mlt_tractor_field(tractor.get_tractor());
1293 mlt_multitrack multitrack = mlt_field_multitrack(field); //mlt_tractor_multitrack(tractor.get_tractor());
1294 kDebug()<<" -- CURRENT MULTIOTRACK HAS: "<<mlt_multitrack_count(multitrack)<<" tracks";;
1295 mlt_service multiprod = mlt_multitrack_service( multitrack );
1297 Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
1298 trackPlaylist.consolidate_blanks(0);
1299 mlt_events_block( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
1301 if (endTrack == startTrack) {
1302 if (!trackPlaylist.is_blank_at(moveEnd)) {
1303 kWarning()<<"// ERROR, CLIP COLLISION----------";
1304 int ix = trackPlaylist.get_clip_index_at(moveEnd);
1305 kDebug()<<"BAD CLIP STARTS AT: "<<trackPlaylist.clip_start(ix)<<", LENGT: "<<trackPlaylist.clip_length(ix);
1307 trackPlaylist.insert_at(moveEnd, clipProducer, 1);
1308 trackPlaylist.consolidate_blanks(0);
1311 trackPlaylist.consolidate_blanks(0);
1312 Mlt::Producer destTrackProducer(tractor.track(endTrack));
1313 Mlt::Playlist destTrackPlaylist(( mlt_playlist ) destTrackProducer.get_service());
1314 destTrackPlaylist.consolidate_blanks(1);
1315 destTrackPlaylist.insert_at(moveEnd, clipProducer, 1);
1316 destTrackPlaylist.consolidate_blanks(0);
1320 mlt_events_unblock( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
1323 void Render::mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut)
1325 m_mltConsumer->set("refresh", 0);
1326 mlt_service serv = m_mltProducer->parent().get_service();
1328 mlt_service nextservice = mlt_service_get_producer(serv);
1329 mlt_properties properties = MLT_SERVICE_PROPERTIES( nextservice );
1330 QString mlt_type = mlt_properties_get( properties, "mlt_type" );
1331 QString resource = mlt_properties_get( properties, "mlt_service");
1332 int old_pos = (oldIn.frames(m_fps) + oldOut.frames(m_fps)) / 2;
1334 int new_in = newIn.frames(m_fps);
1335 int new_out = newOut.frames(m_fps) - 1;
1336 while (mlt_type == "transition") {
1337 mlt_transition tr = (mlt_transition) nextservice;
1338 int currentTrack = mlt_transition_get_b_track(tr);
1339 int currentIn = (int) mlt_transition_get_in(tr);
1340 int currentOut = (int) mlt_transition_get_out(tr);
1341 kDebug()<<"// FOUND EXISTING TRANS, IN: "<<currentIn<<", OUT: "<<currentOut<<", TRACK: "<<currentTrack;
1342 //kDebug()<<"// LOOKING FOR IN: "<<old_in<<", OUT: "<<old_out;
1343 kDebug()<<"// OLD IN: "<<oldIn.frames(m_fps)<<" // OLD OUT: "<<oldOut.frames(m_fps)<<", TRACK: "<<startTrack<<", MID POS: "<<old_pos;
1344 if (resource == type && startTrack == currentTrack && currentIn <= old_pos && currentOut >= old_pos) {
1345 mlt_transition_set_in_and_out(tr, new_in, new_out);
1346 if (trackOffset != 0) {
1347 mlt_properties properties = MLT_TRANSITION_PROPERTIES( tr );
1348 mlt_properties_set_int( properties, "a_track", mlt_transition_get_a_track(tr) + trackOffset );
1349 mlt_properties_set_int( properties, "b_track", mlt_transition_get_b_track(tr) + trackOffset );
1353 nextservice = mlt_service_producer(nextservice);
1354 properties = MLT_SERVICE_PROPERTIES( nextservice );
1355 mlt_type = mlt_properties_get( properties, "mlt_type" );
1356 resource = mlt_properties_get( properties, "mlt_service" );
1360 void Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args)
1362 Mlt::Service service(m_mltProducer->parent().get_service());
1364 Mlt::Tractor tractor(service);
1365 Mlt::Field *field = tractor.field();
1367 char *transId = decodedString(tag);
1368 Mlt::Transition *transition = new Mlt::Transition(transId);
1369 transition->set_in_and_out((int) in.frames(m_fps), (int) out.frames(m_fps));
1370 QMap<QString, QString>::Iterator it;
1373 kDebug()<<" ------ ADDING TRANSITION PARAMs: "<<args.count();
1375 for ( it = args.begin(); it != args.end(); ++it ) {
1377 char *name = decodedString(key);
1378 char *value = decodedString(it.value());
1379 transition->set(name, value);
1380 kDebug()<<" ------ ADDING TRANS PARAM: "<<name<<": "<<value;
1381 //filter->set("kdenlive_id", id);
1385 // attach filter to the clip
1386 field->plant_transition(*transition, a_track, b_track);
1392 void Render::mltSavePlaylist()
1394 kWarning()<<"// UPDATING PLAYLIST TO DISK++++++++++++++++";
1395 Mlt::Consumer *fileConsumer = new Mlt::Consumer("westley");
1396 fileConsumer->set("resource", "/home/one/playlist.xml");
1398 Mlt::Service service(m_mltProducer->get_service());
1399 Mlt::Tractor tractor(service);
1401 fileConsumer->connect(service);
1402 fileConsumer->start();
1406 #include "renderer.moc"