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;
204 uint8_t *thumb = frame->get_image(format, width, height);
205 QImage image(thumb, width, height, QImage::Format_ARGB32);
207 if (!image.isNull()) {
208 pix = pix.fromImage(image);
210 QPainter painter(&pix);
211 painter.drawRect(0, 0, width - 1, height - 1);
213 /*if (!border) pix = pix.fromImage(image);
214 //bitBlt(&pix, 0, 0, &image, 0, 0, width, height);
217 bitBlt(&pix, 1, 1, &image, 0, 0, width, height);
220 else pix.fill(Qt::black);
225 QPixmap Render::extractFrame(int frame_position, int width, int height)
227 QPixmap pix(width, height);
228 if (!m_mltProducer) {
232 Mlt::Producer *mlt_producer = m_mltProducer->cut(frame_position, frame_position + 1);
233 Mlt::Filter m_convert("avcolour_space");
234 m_convert.set("forced", mlt_image_rgb24a);
235 mlt_producer->attach(m_convert);
236 Mlt::Frame *frame = mlt_producer->get_frame();
239 pix = frameThumbnail(frame, width, height);
242 else pix.fill(Qt::black);
247 QPixmap Render::getImageThumbnail(KUrl url, int width, int height)
251 if (url.fileName().startsWith(".all.")) { // check for slideshow
252 QString fileType = url.fileName().right(3);
254 QStringList::Iterator it;
256 QDir dir( url.directory() );
257 more = dir.entryList( QDir::Files );
259 for ( it = more.begin() ; it != more.end() ; ++it ) {
260 if ((*it).endsWith("."+fileType, Qt::CaseInsensitive)) {
261 im.load(url.directory() + "/" + *it);
266 else im.load(url.path());
267 //pixmap = im.scaled(width, height);
272 QPixmap Render::getVideoThumbnail(QString file, int frame_position, int width, int height)
274 QPixmap pix(width, height);
275 char *tmp = decodedString(file);
276 Mlt::Producer m_producer(tmp);
278 if (m_producer.is_blank()) {
283 Mlt::Filter m_convert("avcolour_space");
284 m_convert.set("forced", mlt_image_rgb24a);
285 m_producer.attach(m_convert);
286 m_producer.seek(frame_position);
287 Mlt::Frame * frame = m_producer.get_frame();
289 pix = frameThumbnail(frame, width, height, true);
296 void Render::getImage(KUrl url, int frame_position, QPoint size)
298 char *tmp = decodedString(url.path());
299 Mlt::Producer m_producer(tmp);
301 if (m_producer.is_blank()) {
304 Mlt::Filter m_convert("avcolour_space");
305 m_convert.set("forced", mlt_image_rgb24a);
306 m_producer.attach(m_convert);
307 m_producer.seek(frame_position);
309 Mlt::Frame * frame = m_producer.get_frame();
312 QPixmap pix = frameThumbnail(frame, size.x(), size.y(), true);
314 emit replyGetImage(url, frame_position, pix, size.x(), size.y());
318 /* Create thumbnail for color */
319 void Render::getImage(int id, QString color, QPoint size)
321 QPixmap pixmap(size.x() - 2, size.y() - 2);
322 color = color.replace(0, 2, "#");
323 color = color.left(7);
324 pixmap.fill(QColor(color));
325 QPixmap result(size.x(), size.y());
326 result.fill(Qt::black);
327 //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
328 emit replyGetImage(id, result, size.x(), size.y());
332 /* Create thumbnail for image */
333 void Render::getImage(KUrl url, QPoint size)
337 if (url.fileName().startsWith(".all.")) { // check for slideshow
338 QString fileType = url.fileName().right(3);
340 QStringList::Iterator it;
342 QDir dir( url.directory() );
343 more = dir.entryList( QDir::Files );
344 for ( it = more.begin() ; it != more.end() ; ++it ) {
345 if ((*it).endsWith("."+fileType, Qt::CaseInsensitive)) {
346 if (!im.load(url.directory() + "/" + *it))
347 kDebug()<<"++ ERROR LOADIN IMAGE: "<<url.directory() + "/" + *it;
352 else im.load(url.path());
354 //pixmap = im.smoothScale(size.x() - 2, size.y() - 2);
355 QPixmap result(size.x(), size.y());
356 result.fill(Qt::black);
357 //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
358 emit replyGetImage(url, 1, result, size.x(), size.y());
362 double Render::consumerRatio() const
364 if (!m_mltConsumer) return 1.0;
365 return (m_mltConsumer->get_double("aspect_ratio_num")/m_mltConsumer->get_double("aspect_ratio_den"));
369 int Render::getLength()
374 // kDebug()<<"////// LENGTH: "<<mlt_producer_get_playtime(m_mltProducer->get_producer());
375 return mlt_producer_get_playtime(m_mltProducer->get_producer());
380 bool Render::isValid(KUrl url)
382 char *tmp = decodedString(url.path());
383 Mlt::Producer producer(tmp);
385 if (producer.is_blank())
392 void Render::getFileProperties(const KUrl &url, uint framenb)
395 int width = height * 16/9.0; //KdenliveSettings::displayratio();
396 char *tmp = decodedString(url.path());
397 Mlt::Producer producer(tmp);
399 if (producer.is_blank()) {
402 producer.seek( framenb );
403 mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer.get_producer() );
405 QMap < QString, QString > filePropertyMap;
406 QMap < QString, QString > metadataPropertyMap;
408 filePropertyMap["filename"] = url.path();
409 filePropertyMap["duration"] = QString::number(producer.get_playtime());
411 Mlt::Filter m_convert("avcolour_space");
412 m_convert.set("forced", mlt_image_rgb24a);
413 producer.attach(m_convert);
415 Mlt::Frame * frame = producer.get_frame();
417 if (frame->is_valid()) {
418 filePropertyMap["fps"] =
419 QString::number(mlt_producer_get_fps( producer.get_producer() ));
420 filePropertyMap["width"] =
421 QString::number(frame->get_int("width"));
422 filePropertyMap["height"] =
423 QString::number(frame->get_int("height"));
424 filePropertyMap["frequency"] =
425 QString::number(frame->get_int("frequency"));
426 filePropertyMap["channels"] =
427 QString::number(frame->get_int("channels"));
429 // Retrieve audio / video codec name
431 // Fetch the video_context
432 AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data( properties, "video_context", NULL );
433 if (context != NULL) {
434 // Get the video_index
435 int index = mlt_properties_get_int( properties, "video_index" );
436 filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
438 context = (AVFormatContext *) mlt_properties_get_data( properties, "audio_context", NULL );
439 if (context != NULL) {
440 // Get the video_index
441 int index = mlt_properties_get_int( properties, "audio_index" );
442 filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
449 mlt_properties metadata = mlt_properties_new( );
450 mlt_properties_pass( metadata, properties, "meta.attr." );
451 int count = mlt_properties_count( metadata );
452 for ( int i = 0; i < count; i ++ )
454 QString name = mlt_properties_get_name( metadata, i );
455 QString value = QString::fromUtf8(mlt_properties_get_value( metadata, i ));
456 if (name.endsWith("markup") && !value.isEmpty())
457 metadataPropertyMap[ name.section(".", 0, -2) ] = value;
460 if (frame->get_int("test_image") == 0) {
461 if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
462 filePropertyMap["type"] = "playlist";
463 metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get( MLT_SERVICE_PROPERTIES( producer.get_service() ), "title"));
465 else if (frame->get_int("test_audio") == 0)
466 filePropertyMap["type"] = "av";
468 filePropertyMap["type"] = "video";
470 // Generate thumbnail for this frame
471 QPixmap pixmap = frameThumbnail(frame, width, height, true);
473 emit replyGetImage(url, 0, pixmap, width, height);
475 } else if (frame->get_int("test_audio") == 0) {
476 QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
477 emit replyGetImage(url, 0, pixmap, width, height);
478 filePropertyMap["type"] = "audio";
481 emit replyGetFileProperties(filePropertyMap, metadataPropertyMap);
482 kDebug()<<"REquested fuile info for: "<<url.path();
486 QDomDocument Render::sceneList() const
491 /** Create the producer from the Westley QDomDocument */
492 void Render::initSceneList()
494 kDebug()<<"-------- INIT SCENE LIST ------_";
496 QDomElement westley = doc.createElement("westley");
497 doc.appendChild(westley);
498 QDomElement prod = doc.createElement("producer");
499 prod.setAttribute("resource", "colour");
500 prod.setAttribute("colour", "red");
501 prod.setAttribute("id", "black");
502 prod.setAttribute("in", "0");
503 prod.setAttribute("out", "0");
505 QDomElement tractor = doc.createElement("tractor");
506 QDomElement multitrack = doc.createElement("multitrack");
508 QDomElement playlist1 = doc.createElement("playlist");
509 playlist1.appendChild(prod);
510 multitrack.appendChild(playlist1);
511 QDomElement playlist2 = doc.createElement("playlist");
512 multitrack.appendChild(playlist2);
513 QDomElement playlist3 = doc.createElement("playlist");
514 multitrack.appendChild(playlist3);
515 QDomElement playlist4 = doc.createElement("playlist");
516 multitrack.appendChild(playlist4);
517 QDomElement playlist5 = doc.createElement("playlist");
518 multitrack.appendChild(playlist5);
519 tractor.appendChild(multitrack);
520 westley.appendChild(tractor);
521 // kDebug()<<doc.toString();
523 QString tmp = QString("<westley><producer resource=\"colour\" colour=\"red\" id=\"red\" /><tractor><multitrack><playlist></playlist><playlist></playlist><playlist /><playlist /><playlist></playlist></multitrack></tractor></westley>");*/
524 setSceneList(doc, 0);
528 /** Create the producer from the Westley QDomDocument */
529 void Render::setSceneList(QDomDocument list, int position)
531 if (m_winid == -1) return;
532 m_generateScenelist = true;
534 kWarning()<<"////// RENDER, SET SCENE LIST";
537 char *tmp = decodedString(list.toString());
539 Mlt::Producer clip("westley-xml", tmp);
542 if (!clip.is_valid()) {
543 kWarning()<<" ++++ WARNING, UNABLE TO CREATE MLT PRODUCER";
544 m_generateScenelist = false;
551 m_mltConsumer->set("refresh", 0);
552 if (!m_mltConsumer->is_stopped()) {
553 //emitConsumerStopped();
554 m_mltConsumer->stop();
559 m_mltProducer->set_speed(0.0);
561 //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
563 delete m_mltProducer;
564 m_mltProducer = NULL;
568 m_mltProducer = new Mlt::Producer(clip); //track.current();
569 m_mltProducer->optimise();
570 if (position != 0) m_mltProducer->seek(position);
572 /*if (KdenliveSettings::osdtimecode()) {
573 // Attach filter for on screen display of timecode
575 QString attr = "attr_check";
576 mlt_filter filter = mlt_factory_filter( "data_feed", (char*) attr.ascii() );
577 mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_fezzik", 1 );
578 mlt_producer_attach( m_mltProducer->get_producer(), filter );
579 mlt_filter_close( filter );
581 m_osdInfo = new Mlt::Filter("data_show");
582 tmp = decodedString(m_osdProfile);
583 m_osdInfo->set("resource", tmp);
585 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
586 mlt_properties_set_int( properties, "meta.attr.timecode", 1);
587 mlt_properties_set( properties, "meta.attr.timecode.markup", "#timecode#");
588 m_osdInfo->set("dynamic", "1");
590 if (m_mltProducer->attach(*m_osdInfo) == 1) kDebug()<<"////// error attaching filter";
592 m_osdInfo->set("dynamic", "0");
595 m_fps = m_mltProducer->get_fps();
596 if (!m_mltConsumer) {
599 emit playListDuration( (int) m_mltProducer->get_playtime());
600 m_connectTimer->start( 500 );
601 m_generateScenelist = false;
605 const double Render::fps() const
610 void Render::connectPlaylist() {
611 kDebug()<<"************** CONNECTING PLAYLIST";
612 m_connectTimer->stop();
613 if (m_mltConsumer->start() == -1) {
614 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."));
615 m_mltConsumer = NULL;
618 m_mltConsumer->connect(*m_mltProducer);
619 m_mltProducer->set_speed(0.0);
624 void Render::refreshDisplay() {
626 if (!m_mltProducer) return;
627 m_mltConsumer->set("refresh", 0);
629 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
630 /*if (KdenliveSettings::osdtimecode()) {
631 mlt_properties_set_int( properties, "meta.attr.timecode", 1);
632 mlt_properties_set( properties, "meta.attr.timecode.markup", "#timecode#");
633 m_osdInfo->set("dynamic", "1");
634 m_mltProducer->attach(*m_osdInfo);
637 m_mltProducer->detach(*m_osdInfo);
638 m_osdInfo->set("dynamic", "0");
643 void Render::setVolume(double volume)
645 if (!m_mltConsumer || !m_mltProducer) return;
647 m_mltConsumer->set("refresh", 0);
648 // Attach filter for on screen display of timecode
649 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
650 mlt_properties_set_double( properties, "meta.volume", volume );
651 mlt_properties_set_int( properties, "meta.attr.osdvolume", 1);
652 mlt_properties_set( properties, "meta.attr.osdvolume.markup", i18n("Volume: ") + QString::number(volume * 100));
654 if (!KdenliveSettings::osdtimecode()) {
655 m_mltProducer->detach(*m_osdInfo);
656 mlt_properties_set_int( properties, "meta.attr.timecode", 0);
657 if (m_mltProducer->attach(*m_osdInfo) == 1) kDebug()<<"////// error attaching filter";
660 osdTimer->setSingleShot(2500 );
663 void Render::slotOsdTimeout()
665 mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
666 mlt_properties_set_int(properties, "meta.attr.osdvolume", 0);
667 mlt_properties_set(properties, "meta.attr.osdvolume.markup", NULL);
668 //if (!KdenliveSettings::osdtimecode()) m_mltProducer->detach(*m_osdInfo);
674 if (!m_mltConsumer || m_winid == -1) {
679 if (m_mltConsumer->is_stopped()) {
680 if (m_mltConsumer->start() == -1) {
681 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."));
682 m_mltConsumer = NULL;
695 m_mltConsumer->set("refresh", 0);
696 if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
700 //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
701 m_mltProducer->set_speed(0.0);
702 delete m_mltProducer;
703 m_mltProducer = NULL;
710 kDebug()<<"///////////// RENDER STOP-------";
711 if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
712 m_mltConsumer->set("refresh", 0);
713 // m_mltConsumer->stop();
715 kDebug()<<"///////////// RENDER STOP2-------";
719 m_mltProducer->set_speed(0.0);
720 m_mltProducer->set("out", m_mltProducer->get_length() - 1);
722 kDebug()<<"///////////// RENDER STOP3-------";
725 void Render::stop(const GenTime & startTime)
727 kDebug()<<"///////////// RENDER STOP-------2";
729 m_mltProducer->set_speed(0.0);
730 m_mltProducer->seek((int) startTime.frames(m_fps));
732 m_mltConsumer->purge();
735 void Render::switchPlay()
739 if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0);
741 m_mltProducer->set_speed(0.0);
742 kDebug()<<"// POSITON: "<<m_framePosition;
743 m_mltProducer->seek((int) m_framePosition);
746 /*if (speed == 0.0) {
747 m_mltProducer->seek((int) m_framePosition + 1);
748 m_mltConsumer->purge();
753 void Render::play(double speed)
757 if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1);
758 m_mltProducer->set_speed(speed);
759 /*if (speed == 0.0) {
760 m_mltProducer->seek((int) m_framePosition + 1);
761 m_mltConsumer->purge();
766 void Render::play(double speed, const GenTime & startTime)
768 kDebug()<<"///////////// RENDER PLAY2-------"<<speed;
771 //m_mltProducer->set("out", m_mltProducer->get_length() - 1);
772 //if (speed == 0.0) m_mltConsumer->set("refresh", 0);
773 m_mltProducer->set_speed(speed);
774 m_mltProducer->seek((int) (startTime.frames(m_fps)));
775 //m_mltConsumer->purge();
779 void Render::play(double speed, const GenTime & startTime,
780 const GenTime & stopTime)
782 kDebug()<<"///////////// RENDER PLAY3-------"<<speed;
785 m_mltProducer->set("out", stopTime.frames(m_fps));
786 m_mltProducer->seek((int) (startTime.frames(m_fps)));
787 m_mltConsumer->purge();
788 m_mltProducer->set_speed(speed);
792 void Render::render(const KUrl & url)
795 QDomElement elem = doc.createElement("render");
796 elem.setAttribute("filename", url.path());
797 doc.appendChild(elem);
800 void Render::sendSeekCommand(GenTime time)
804 //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
805 m_mltProducer->seek((int) (time.frames(m_fps)));
809 void Render::seekToFrame(int pos)
813 //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
814 m_mltProducer->seek(pos);
818 void Render::askForRefresh()
820 // Use a Timer so that we don't refresh too much
821 refreshTimer->start( 200 );
824 void Render::refresh()
828 refreshTimer->stop();
830 m_mltConsumer->set("refresh", 1);
834 /** Sets the description of this renderer to desc. */
835 void Render::setDescription(const QString & description)
837 m_description = description;
840 /** Returns the description of this renderer */
841 QString Render::description()
843 return m_description;
847 double Render::playSpeed()
849 if (m_mltProducer) return m_mltProducer->get_speed();
853 const GenTime & Render::seekPosition() const
855 if (m_mltProducer) return GenTime((int) m_mltProducer->position(), m_fps);
856 else return GenTime();
860 const QString & Render::rendererName() const
866 void Render::emitFrameNumber(double position)
868 //kDebug()<<"// POSITON: "<<m_framePosition;
869 if (m_generateScenelist) return;
870 m_framePosition = position;
871 emit rendererPosition((int) position);
872 //if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent( GenTime((int) position, m_fps), m_monitorId));
875 void Render::emitConsumerStopped()
877 // This is used to know when the playing stopped
878 if (m_mltProducer && !m_generateScenelist) {
879 double pos = m_mltProducer->position();
880 emit rendererStopped((int) pos);
881 //if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent(GenTime((int) pos, m_fps), m_monitorId + 100));
882 //new QCustomEvent(10002));
888 void Render::exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime)
890 KMessageBox::sorry(0, i18n("Firewire is not enabled on your system.\n Please install Libiec61883 and recompile Kdenlive"));
894 void Render::exportCurrentFrame(KUrl url, bool notify) {
895 if (!m_mltProducer) {
896 KMessageBox::sorry(qApp->activeWindow(), i18n("There is no clip, cannot extract frame."));
900 int height = 1080;//KdenliveSettings::defaultheight();
901 int width = 1940; //KdenliveSettings::displaywidth();
903 QPixmap pix(width, height);
905 Mlt::Filter m_convert("avcolour_space");
906 m_convert.set("forced", mlt_image_rgb24a);
907 m_mltProducer->attach(m_convert);
908 Mlt::Frame * frame = m_mltProducer->get_frame();
909 m_mltProducer->detach(m_convert);
911 pix = frameThumbnail(frame, width, height);
914 pix.save(url.path(), "PNG");
915 //if (notify) QApplication::postEvent(qApp->activeWindow(), new UrlEvent(url, 10003));
918 /** MLT PLAYLIST DIRECT MANIPULATON **/
921 void Render::mltCheckLength()
923 //kDebug()<<"checking track length: "<<track<<"..........";
924 Mlt::Service service(m_mltProducer->get_service());
925 Mlt::Tractor tractor(service);
927 int trackNb = tractor.count( );
929 double trackDuration;
931 Mlt::Producer trackProducer(tractor.track(0));
932 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
933 duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
934 m_mltProducer->set("out", duration);
935 emit durationChanged();
938 while (trackNb > 1) {
939 Mlt::Producer trackProducer(tractor.track(trackNb - 1));
940 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
941 trackDuration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime() - 1;
943 kDebug()<<" / / /DURATON FOR TRACK "<<trackNb - 1<<" = "<<trackDuration;
944 if (trackDuration > duration) duration = trackDuration;
948 Mlt::Producer blackTrackProducer(tractor.track(0));
949 Mlt::Playlist blackTrackPlaylist(( mlt_playlist ) blackTrackProducer.get_service());
950 double blackDuration = Mlt::Producer(blackTrackPlaylist.get_producer()).get_playtime() - 1;
951 kDebug()<<" / / /DURATON FOR TRACK 0 = "<<blackDuration;
952 if (blackDuration != duration) {
953 blackTrackPlaylist.remove_region( 0, blackDuration );
957 while (dur > 14000) { // <producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" />
958 mltInsertClip(0, GenTime(i * 14000, m_fps), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"13999\" /></westley>"));
963 mltInsertClip(0, GenTime(), QString("<westley><producer mlt_service=\"colour\" colour=\"black\" in=\"0\" out=\"" + QString::number(dur) + "\" /></westley>"));
965 m_mltProducer->set("out", duration);
966 emit durationChanged();
971 void Render::mltInsertClip(int track, GenTime position, QString resource)
973 if (!m_mltProducer) {
974 kDebug()<<"PLAYLISTÂ NOT INITIALISED //////";
977 Mlt::Producer parentProd(m_mltProducer->parent());
978 if (parentProd.get_producer() == NULL) {
979 kDebug()<<"PLAYLISTÂ BROKEN, CANNOT INSERTÂ CLIP //////";
982 Mlt::Service service(parentProd.get_service());
983 Mlt::Tractor tractor(service);
985 Mlt::Producer trackProducer(tractor.track(track));
986 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
987 char *tmp = decodedString(resource);
988 Mlt::Producer clip("westley-xml", tmp);
989 //clip.set_in_and_out(in.frames(m_fps), out.frames(m_fps));
992 trackPlaylist.insert_at(position.frames(m_fps), clip, 1);
993 tractor.multitrack()->refresh();
995 if (track != 0) mltCheckLength();
996 double duration = Mlt::Producer(trackPlaylist.get_producer()).get_playtime();
997 kDebug()<<"// + +INSERTING CLIP: "<<resource<<" AT: "<<position.frames(m_fps)<<" on track: "<<track<<", DURATION: "<<duration;
1002 void Render::mltCutClip(int track, GenTime position)
1004 Mlt::Service service(m_mltProducer->parent().get_service());
1005 if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
1006 if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
1007 if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
1008 if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
1010 Mlt::Tractor tractor(service);
1011 Mlt::Producer trackProducer(tractor.track(track));
1012 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1013 trackPlaylist.split_at(position.frames(m_fps));
1014 trackPlaylist.consolidate_blanks(0);
1015 kDebug()<<"/ / / /CUTTING CLIP AT: "<<position.frames(m_fps);
1019 void Render::mltRemoveClip(int track, GenTime position)
1021 Mlt::Service service(m_mltProducer->parent().get_service());
1022 if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
1023 if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
1024 if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
1025 if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
1027 Mlt::Tractor tractor(service);
1028 Mlt::Producer trackProducer(tractor.track(track));
1029 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1030 int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1031 //trackPlaylist.remove(clipIndex);
1032 trackPlaylist.replace_with_blank(clipIndex);
1033 trackPlaylist.consolidate_blanks(0);
1034 if (track != 0) mltCheckLength();
1035 //emit durationChanged();
1038 void Render::mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index)
1040 Mlt::Service service(m_mltProducer->parent().get_service());
1042 Mlt::Tractor tractor(service);
1043 Mlt::Producer trackProducer(tractor.track(track));
1044 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1045 //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1046 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1048 kDebug()<<" / / / CANNOT FIND CLIP TO REMOVE EFFECT";
1051 Mlt::Service clipService(clip->get_service());
1053 if (tag.startsWith("ladspa")) tag = "ladspa";
1057 Mlt::Filter *filter = clipService.filter( ct );
1059 if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) {
1060 clipService.detach(*filter);
1061 kDebug()<<" / / / DLEETED EFFECT: "<<ct;
1064 filter = clipService.filter( ct );
1068 Mlt::Filter *filter = clipService.filter( index );
1069 if (filter && filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) clipService.detach(*filter);
1071 kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
1078 void Render::mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args)
1080 Mlt::Service service(m_mltProducer->parent().get_service());
1082 Mlt::Tractor tractor(service);
1083 Mlt::Producer trackProducer(tractor.track(track));
1084 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1086 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1089 kDebug()<<"********** CANNOT FIND CLIP TO APPLY EFFECT-----------";
1092 Mlt::Service clipService(clip->get_service());
1095 kDebug()<<" / / INSERTING EFFECT: "<<id;
1096 if (tag.startsWith("ladspa")) tag = "ladspa";
1097 char *filterId = decodedString(tag);
1098 Mlt::Filter *filter = new Mlt::Filter(filterId);
1099 filter->set("kdenlive_id", filterId);
1101 QMap<QString, QString>::Iterator it;
1102 QString keyFrameNumber = "#0";
1104 for ( it = args.begin(); it != args.end(); ++it ) {
1105 //kDebug()<<" / / INSERTING EFFECT ARGS: "<<it.key()<<": "<<it.data();
1107 QString currentKeyFrameNumber;
1108 if (it.key().startsWith("#")) {
1109 currentKeyFrameNumber = it.key().section(":", 0, 0);
1110 if (currentKeyFrameNumber != keyFrameNumber) {
1111 // attach filter to the clip
1112 clipService.attach(*filter);
1113 filter = new Mlt::Filter(filterId);
1114 filter->set("kdenlive_id", filterId);
1115 keyFrameNumber = currentKeyFrameNumber;
1117 key = it.key().section(":", 1);
1119 else key = it.key();
1120 char *name = decodedString(key);
1121 char *value = decodedString(it.value());
1122 filter->set(name, value);
1126 // attach filter to the clip
1127 clipService.attach(*filter);
1133 void Render::mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args)
1135 QMap<QString, QString>::Iterator it = args.begin();
1136 if (it.key().startsWith("#") || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") {
1137 // This is a keyframe effect, to edit it, we remove it and re-add it.
1138 mltRemoveEffect(track, position, id, tag, -1);
1139 mltAddEffect(track, position, id, tag, args);
1144 Mlt::Service service(m_mltProducer->parent().get_service());
1146 Mlt::Tractor tractor(service);
1147 Mlt::Producer trackProducer(tractor.track(track));
1148 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1149 //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
1150 Mlt::Producer *clip = trackPlaylist.get_clip_at(position.frames(m_fps));
1151 Mlt::Service clipService(clip->get_service());
1152 Mlt::Filter *filter = clipService.filter( index );
1155 if (!filter || filter->get("mlt_service") != tag) {
1156 kDebug()<<"WARINIG, FILTER NOT FOUND!!!!!";
1158 filter = clipService.filter( index );
1160 if (filter->get("mlt_service") == tag && filter->get("kdenlive_id") == id) break;
1162 filter = clipService.filter( index );
1166 kDebug()<<"WARINIG, FILTER "<<id<<" NOT FOUND!!!!!";
1170 for ( it = args.begin(); it != args.end(); ++it ) {
1171 kDebug()<<" / / INSERTING EFFECT ARGS: "<<it.key()<<": "<<it.value();
1172 char *name = decodedString(it.key());
1173 char *value = decodedString(it.value());
1174 filter->set(name, value);
1181 void Render::mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out)
1183 Mlt::Service service(m_mltProducer->parent().get_service());
1185 Mlt::Tractor tractor(service);
1186 Mlt::Producer trackProducer(tractor.track(track));
1187 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1188 if (trackPlaylist.is_blank_at(pos.frames(m_fps) + 1))
1189 kDebug()<<"//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
1190 int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps) + 1);
1192 int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
1193 int newDuration = out.frames(m_fps) - 1;
1195 kDebug()<<" ** RESIZING CLIP END:" << clipIndex << " on track:"<< track <<", mid pos: "<<pos.frames(25)<<", in: "<<in.frames(25)<<", out: "<<out.frames(25)<<", PREVIOUS duration: "<<previousDuration;
1196 trackPlaylist.resize_clip(clipIndex, in.frames(m_fps), newDuration);
1197 trackPlaylist.consolidate_blanks(0);
1198 if (previousDuration < newDuration) {
1199 // clip was made longer, trim next blank if there is one.
1200 if (trackPlaylist.is_blank(clipIndex + 1)) {
1201 trackPlaylist.split(clipIndex + 1, newDuration - previousDuration);
1202 trackPlaylist.remove(clipIndex + 1);
1205 else trackPlaylist.insert_blank(clipIndex + 1, previousDuration - newDuration - 1);
1207 trackPlaylist.consolidate_blanks(0);
1208 tractor.multitrack()->refresh();
1210 if (track != 0) mltCheckLength();
1214 void Render::mltChangeTrackState(int track, bool mute, bool blind)
1216 Mlt::Service service(m_mltProducer->parent().get_service());
1218 Mlt::Tractor tractor(service);
1219 Mlt::Producer trackProducer(tractor.track(track));
1220 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1222 if (blind) trackProducer.set("hide", 3);
1223 else trackProducer.set("hide", 2);
1226 trackProducer.set("hide", 1);
1229 trackProducer.set("hide", 0);
1231 tractor.multitrack()->refresh();
1236 void Render::mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out)
1238 Mlt::Service service(m_mltProducer->parent().get_service());
1239 if (service.type() == playlist_type) kDebug()<<"// PLAYLIST TYPE";
1240 if (service.type() == tractor_type) kDebug()<<"// TRACOT TYPE";
1241 if (service.type() == multitrack_type) kDebug()<<"// MULTITRACK TYPE";
1242 if (service.type() == producer_type) kDebug()<<"// PROD TYPE";
1244 int moveFrame = (moveEnd - moveStart).frames(m_fps);
1246 Mlt::Tractor tractor(service);
1247 Mlt::Producer trackProducer(tractor.track(track));
1248 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1249 if (trackPlaylist.is_blank_at(pos.frames(m_fps) - 1))
1250 kDebug()<<"//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
1251 int clipIndex = trackPlaylist.get_clip_index_at(pos.frames(m_fps) - 1);
1252 kDebug()<<" ** RESIZING CLIP START:" << clipIndex << " on track:"<< track <<", mid pos: "<<pos.frames(25)<<", moving: "<<moveFrame<<", in: "<<in.frames(25)<<", out: "<<out.frames(25);
1254 trackPlaylist.resize_clip(clipIndex, in.frames(m_fps), out.frames(m_fps));
1255 if (moveFrame > 0) trackPlaylist.insert_blank(clipIndex, moveFrame - 1);
1257 int midpos = moveStart.frames(m_fps) - 1; //+ (moveFrame / 2)
1258 int blankIndex = trackPlaylist.get_clip_index_at(midpos);
1259 int blankLength = trackPlaylist.clip_length(blankIndex);
1261 kDebug()<<" + resizing blank: "<<blankIndex<<", Mid: "<<midpos<<", Length: "<<blankLength<< ", SIZE DIFF: "<<moveFrame;
1264 if (blankLength + moveFrame == 0) trackPlaylist.remove(blankIndex);
1265 else trackPlaylist.resize_clip(blankIndex, 0, blankLength + moveFrame -1);
1267 trackPlaylist.consolidate_blanks(0);
1269 kDebug()<<"-----------------\n"<<"CLIP 0: "<<trackPlaylist.clip_start(0)<<", LENGT: "<<trackPlaylist.clip_length(0);
1270 kDebug()<<"CLIP 1: "<<trackPlaylist.clip_start(1)<<", LENGT: "<<trackPlaylist.clip_length(1);
1271 kDebug()<<"CLIP 2: "<<trackPlaylist.clip_start(2)<<", LENGT: "<<trackPlaylist.clip_length(2);
1272 kDebug()<<"CLIP 3: "<<trackPlaylist.clip_start(3)<<", LENGT: "<<trackPlaylist.clip_length(3);
1273 kDebug()<<"CLIP 4: "<<trackPlaylist.clip_start(4)<<", LENGT: "<<trackPlaylist.clip_length(4);
1276 void Render::mltMoveClip(int startTrack, int endTrack, GenTime moveStart, GenTime moveEnd)
1278 mltMoveClip(startTrack, endTrack, (int) moveStart.frames(m_fps), (int) moveEnd.frames(m_fps));
1282 void Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd)
1284 m_mltConsumer->set("refresh", 0);
1285 Mlt::Service service(m_mltProducer->parent().get_service());
1287 Mlt::Tractor tractor(service);
1288 Mlt::Producer trackProducer(tractor.track(startTrack));
1289 Mlt::Playlist trackPlaylist(( mlt_playlist ) trackProducer.get_service());
1290 int clipIndex = trackPlaylist.get_clip_index_at(moveStart + 1);
1293 mlt_field field = mlt_tractor_field(tractor.get_tractor());
1295 mlt_multitrack multitrack = mlt_field_multitrack(field); //mlt_tractor_multitrack(tractor.get_tractor());
1296 kDebug()<<" -- CURRENT MULTIOTRACK HAS: "<<mlt_multitrack_count(multitrack)<<" tracks";;
1297 mlt_service multiprod = mlt_multitrack_service( multitrack );
1299 Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
1300 trackPlaylist.consolidate_blanks(0);
1301 mlt_events_block( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
1303 if (endTrack == startTrack) {
1304 if (!trackPlaylist.is_blank_at(moveEnd)) {
1305 kWarning()<<"// ERROR, CLIP COLLISION----------";
1306 int ix = trackPlaylist.get_clip_index_at(moveEnd);
1307 kDebug()<<"BAD CLIP STARTS AT: "<<trackPlaylist.clip_start(ix)<<", LENGT: "<<trackPlaylist.clip_length(ix);
1309 trackPlaylist.insert_at(moveEnd, clipProducer, 1);
1310 trackPlaylist.consolidate_blanks(0);
1313 trackPlaylist.consolidate_blanks(0);
1314 Mlt::Producer destTrackProducer(tractor.track(endTrack));
1315 Mlt::Playlist destTrackPlaylist(( mlt_playlist ) destTrackProducer.get_service());
1316 destTrackPlaylist.consolidate_blanks(1);
1317 destTrackPlaylist.insert_at(moveEnd, clipProducer, 1);
1318 destTrackPlaylist.consolidate_blanks(0);
1322 mlt_events_unblock( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
1325 void Render::mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut)
1327 m_mltConsumer->set("refresh", 0);
1328 mlt_service serv = m_mltProducer->parent().get_service();
1330 mlt_service nextservice = mlt_service_get_producer(serv);
1331 mlt_properties properties = MLT_SERVICE_PROPERTIES( nextservice );
1332 QString mlt_type = mlt_properties_get( properties, "mlt_type" );
1333 QString resource = mlt_properties_get( properties, "mlt_service");
1334 int old_pos = (oldIn.frames(m_fps) + oldOut.frames(m_fps)) / 2;
1336 int new_in = newIn.frames(m_fps);
1337 int new_out = newOut.frames(m_fps) - 1;
1338 while (mlt_type == "transition") {
1339 mlt_transition tr = (mlt_transition) nextservice;
1340 int currentTrack = mlt_transition_get_b_track(tr);
1341 int currentIn = (int) mlt_transition_get_in(tr);
1342 int currentOut = (int) mlt_transition_get_out(tr);
1343 kDebug()<<"// FOUND EXISTING TRANS, IN: "<<currentIn<<", OUT: "<<currentOut<<", TRACK: "<<currentTrack;
1344 //kDebug()<<"// LOOKING FOR IN: "<<old_in<<", OUT: "<<old_out;
1345 kDebug()<<"// OLD IN: "<<oldIn.frames(m_fps)<<" // OLD OUT: "<<oldOut.frames(m_fps)<<", TRACK: "<<startTrack<<", MID POS: "<<old_pos;
1346 if (resource == type && startTrack == currentTrack && currentIn <= old_pos && currentOut >= old_pos) {
1347 mlt_transition_set_in_and_out(tr, new_in, new_out);
1348 if (trackOffset != 0) {
1349 mlt_properties properties = MLT_TRANSITION_PROPERTIES( tr );
1350 mlt_properties_set_int( properties, "a_track", mlt_transition_get_a_track(tr) + trackOffset );
1351 mlt_properties_set_int( properties, "b_track", mlt_transition_get_b_track(tr) + trackOffset );
1355 nextservice = mlt_service_producer(nextservice);
1356 properties = MLT_SERVICE_PROPERTIES( nextservice );
1357 mlt_type = mlt_properties_get( properties, "mlt_type" );
1358 resource = mlt_properties_get( properties, "mlt_service" );
1362 void Render::mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args)
1364 Mlt::Service service(m_mltProducer->parent().get_service());
1366 Mlt::Tractor tractor(service);
1367 Mlt::Field *field = tractor.field();
1369 char *transId = decodedString(tag);
1370 Mlt::Transition *transition = new Mlt::Transition(transId);
1371 transition->set_in_and_out((int) in.frames(m_fps), (int) out.frames(m_fps));
1372 QMap<QString, QString>::Iterator it;
1375 kDebug()<<" ------ ADDING TRANSITION PARAMs: "<<args.count();
1377 for ( it = args.begin(); it != args.end(); ++it ) {
1379 char *name = decodedString(key);
1380 char *value = decodedString(it.value());
1381 transition->set(name, value);
1382 kDebug()<<" ------ ADDING TRANS PARAM: "<<name<<": "<<value;
1383 //filter->set("kdenlive_id", id);
1387 // attach filter to the clip
1388 field->plant_transition(*transition, a_track, b_track);
1394 void Render::mltSavePlaylist()
1396 kWarning()<<"// UPDATING PLAYLIST TO DISK++++++++++++++++";
1397 Mlt::Consumer *fileConsumer = new Mlt::Consumer("westley");
1398 fileConsumer->set("resource", "/home/one/playlist.xml");
1400 Mlt::Service service(m_mltProducer->get_service());
1401 Mlt::Tractor tractor(service);
1403 fileConsumer->connect(service);
1404 fileConsumer->start();
1408 #include "renderer.moc"