1 /***************************************************************************
2 * DocClipBase.cpp - description *
3 * ------------------- *
4 * begin : Fri Apr 12 2002 *
5 * Copyright (C) 2002 by Jason Wood (jasonwood@blueyonder.co.uk) *
6 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
22 ***************************************************************************/
27 #include "docclipbase.h"
28 #include "kdenlivesettings.h"
30 #include "clipmanager.h"
32 #include <KIO/NetAccess>
35 #include <QCryptographicHash>
37 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id) :
41 m_baseTrackProducers(),
42 m_audioTrackProducers(),
43 m_videoOnlyProducer(NULL),
48 m_audioThumbCreated(false),
50 m_placeHolder(xml.hasAttribute("placeholder")),
53 int type = xml.attribute("type").toInt();
54 m_clipType = (CLIPTYPE) type;
55 if (m_placeHolder) xml.removeAttribute("placeholder");
56 QDomNamedNodeMap attributes = xml.attributes();
57 for (int i = 0; i < attributes.count(); i++) {
58 m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue());
61 KUrl url = KUrl(xml.attribute("resource"));
62 if (!m_properties.contains("file_hash") && !url.isEmpty()) getFileHash(url.path());
64 if (xml.hasAttribute("duration")) {
65 setDuration(GenTime(xml.attribute("duration").toInt(), KdenliveSettings::project_fps()));
67 int out = xml.attribute("out").toInt();
68 int in = xml.attribute("in").toInt();
69 setDuration(GenTime(out - in, KdenliveSettings::project_fps()));
72 if (!m_properties.contains("name")) m_properties.insert("name", url.fileName());
74 //if (!url.isEmpty() && QFile::exists(url.path()))
76 m_thumbProd = new KThumb(clipManager, url, m_id, m_properties.value("file_hash"));
77 if (m_clipType == AV || m_clipType == AUDIO) slotCreateAudioTimer();
79 //kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType;
82 /*DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
83 DocClipBase::operator=(clip);
85 m_clipType = clip.clipType();
87 m_duration = clip.duration();
88 m_audioThumbCreated = clip.audioThumbCreated();
89 m_properties = clip.properties();
93 DocClipBase::~DocClipBase()
95 kDebug() << "CLIP " << m_id << " DELETED******************************";
101 /*kDebug() <<" * * *CNT "<<m_baseTrackProducers.count();
102 if (m_baseTrackProducers.count() > 0) kDebug()<<"YOYO: "<<m_baseTrackProducers.at(0)->get_out()<<", CUT: "<<m_baseTrackProducers.at(0)->is_cut();*/
103 qDeleteAll(m_baseTrackProducers);
104 m_baseTrackProducers.clear();
105 qDeleteAll(m_audioTrackProducers);
106 m_audioTrackProducers.clear();
107 delete m_videoOnlyProducer;
108 m_videoOnlyProducer = NULL;
111 void DocClipBase::setZone(QPoint zone)
113 m_properties.insert("zone_in", QString::number(zone.x()));
114 m_properties.insert("zone_out", QString::number(zone.y()));
117 QPoint DocClipBase::zone() const
120 zone.setX(m_properties.value("zone_in").toInt());
121 zone.setY(m_properties.value("zone_out", "50").toInt());
125 void DocClipBase::slotCreateAudioTimer()
127 connect(m_thumbProd, SIGNAL(audioThumbReady(QMap <int, QMap <int, QByteArray> >)), this , SLOT(updateAudioThumbnail(QMap <int, QMap <int, QByteArray> >)));
128 connect(this, SIGNAL(getAudioThumbs()), this , SLOT(slotGetAudioThumbs()));
129 m_audioTimer = new QTimer(this);
130 connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
133 void DocClipBase::askForAudioThumbs()
135 if (m_thumbProd) m_thumbProd->askForAudioThumbs(getId());
138 void DocClipBase::slotClearAudioCache()
140 if (m_thumbProd) m_thumbProd->stopAudioThumbs();
141 if (m_audioTimer != NULL) m_audioTimer->stop();
142 m_audioFrameCache.clear();
143 m_audioThumbCreated = false;
146 /*void DocClipBase::getClipMainThumb() {
147 if (m_thumbProd) m_thumbProd->getMainThumb(m_properties.value("thumbnail").toInt());
150 KThumb *DocClipBase::thumbProducer()
155 bool DocClipBase::audioThumbCreated() const
157 return m_audioThumbCreated;
160 const QString DocClipBase::name() const
163 return m_properties.value("name");
166 const QString &DocClipBase::getId() const
171 void DocClipBase::setId(const QString &newId)
176 const CLIPTYPE & DocClipBase::clipType() const
181 void DocClipBase::setClipType(CLIPTYPE type)
185 m_properties.insert("type", QString::number((int) type));
186 if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO))
187 slotCreateAudioTimer();
190 KUrl DocClipBase::fileURL() const
192 QString res = m_properties.value("resource");
193 if (m_clipType != COLOR && !res.isEmpty()) return KUrl(res);
197 void DocClipBase::setClipThumbFrame(const uint &ix)
199 m_properties.insert("thumbnail", QString::number((int) ix));
202 uint DocClipBase::getClipThumbFrame() const
204 return (uint) m_properties.value("thumbnail").toInt();
207 const QString DocClipBase::description() const
209 return m_properties.value("description");
212 bool DocClipBase::isTransparent() const
214 return (m_properties.value("transparency") == "1");
217 const QString DocClipBase::getProperty(const QString prop) const
219 return m_properties.value(prop);
222 void DocClipBase::setDuration(GenTime dur)
225 m_properties.insert("duration", QString::number((int) dur.frames(KdenliveSettings::project_fps())));
228 const GenTime &DocClipBase::duration() const
233 const GenTime DocClipBase::maxDuration() const
235 if (m_clipType == COLOR || m_clipType == IMAGE || m_clipType == TEXT || (m_clipType == SLIDESHOW && m_properties.value("loop") == "1")) {
236 /*const GenTime dur(15000, KdenliveSettings::project_fps());
243 bool DocClipBase::hasFileSize() const
250 QDomElement DocClipBase::toXML() const
253 QDomElement clip = doc.createElement("producer");
255 QMapIterator<QString, QString> i(m_properties);
256 while (i.hasNext()) {
258 if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value());
260 doc.appendChild(clip);
261 //kDebug()<<"/// CLIP XML: "<<doc.toString();
262 return doc.documentElement();
266 void DocClipBase::setAudioThumbCreated(bool isDone)
268 m_audioThumbCreated = isDone;
272 void DocClipBase::setThumbnail(const QPixmap & pixmap)
274 m_thumbnail = pixmap;
277 const QPixmap & DocClipBase::thumbnail() const
282 void DocClipBase::updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data)
284 //kDebug() << "CLIPBASE RECIEDVEDÂ AUDIOÂ DATA*********************************************";
285 m_audioFrameCache = data;
286 m_audioThumbCreated = true;
290 QList < GenTime > DocClipBase::snapMarkers() const
292 QList < GenTime > markers;
294 for (int count = 0; count < m_snapMarkers.count(); ++count) {
295 markers.append(m_snapMarkers[count].time());
301 QList < CommentedTime > DocClipBase::commentedSnapMarkers() const
303 return m_snapMarkers;
306 void DocClipBase::setSnapMarkers(QList < CommentedTime > markers)
308 m_snapMarkers = markers;
311 void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
313 QList < CommentedTime >::Iterator it = m_snapMarkers.begin();
314 for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
315 if ((*it).time() >= time)
319 if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
320 (*it).setComment(comment);
321 //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
323 CommentedTime t(time, comment);
324 m_snapMarkers.insert(it, t);
329 void DocClipBase::editSnapMarker(const GenTime & time, QString comment)
331 QList < CommentedTime >::Iterator it;
332 for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
333 if ((*it).time() == time)
336 if (it != m_snapMarkers.end()) {
337 (*it).setComment(comment);
339 kError() << "trying to edit Snap Marker that does not already exists";
343 QString DocClipBase::deleteSnapMarker(const GenTime & time)
345 QString result = i18n("Marker");
346 QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
348 while (itt != m_snapMarkers.end()) {
349 if ((*itt).time() == time)
354 if ((itt != m_snapMarkers.end()) && ((*itt).time() == time)) {
355 result = (*itt).comment();
356 m_snapMarkers.erase(itt);
362 GenTime DocClipBase::hasSnapMarkers(const GenTime & time)
364 QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
366 while (itt != m_snapMarkers.end()) {
367 if ((*itt).time() == time)
375 GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime)
378 for (it = 0; it < m_snapMarkers.count(); it++) {
379 if (m_snapMarkers[it].time() >= currTime)
382 if (it == 0) return GenTime();
383 else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime)
384 return m_snapMarkers[it].time();
385 else return m_snapMarkers[it-1].time();
388 GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime)
391 for (it = 0; it < m_snapMarkers.count(); it++) {
392 if (m_snapMarkers[it].time() > currTime)
395 if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time();
399 QString DocClipBase::markerComment(GenTime t)
401 QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
403 while (itt != m_snapMarkers.end()) {
404 if ((*itt).time() == t)
405 return (*itt).comment();
411 void DocClipBase::deleteProducers()
413 qDeleteAll(m_baseTrackProducers);
414 m_baseTrackProducers.clear();
415 if (m_thumbProd) m_thumbProd->clearProducer();
416 qDeleteAll(m_audioTrackProducers);
417 m_audioTrackProducers.clear();
418 delete m_videoOnlyProducer;
419 m_videoOnlyProducer = NULL;
422 void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
424 if (producer == NULL) return;
426 // Clear all previous producers
429 QString id = producer->get("id");
430 if (id.contains('_')) {
431 // this is a subtrack producer, insert it at correct place
432 id = id.section('_', 1);
433 if (id.endsWith("audio")) {
434 int pos = id.section('_', 0, 0).toInt();
435 if (pos >= m_audioTrackProducers.count()) {
436 while (m_audioTrackProducers.count() - 1 < pos) {
437 m_audioTrackProducers.append(NULL);
440 if (m_audioTrackProducers.at(pos) == NULL) m_audioTrackProducers[pos] = producer;
443 if (id.endsWith("video")) {
444 m_videoOnlyProducer = producer;
447 int pos = id.toInt();
448 if (pos >= m_baseTrackProducers.count()) {
449 while (m_baseTrackProducers.count() - 1 < pos) {
450 m_baseTrackProducers.append(NULL);
453 if (m_baseTrackProducers.at(pos) == NULL) m_baseTrackProducers[pos] = producer;
455 if (m_baseTrackProducers.isEmpty()) m_baseTrackProducers.append(producer);
456 else if (m_baseTrackProducers.at(0) == NULL) m_baseTrackProducers[0] = producer;
458 //m_clipProducer = producer;
459 //m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
460 if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer);
463 Mlt::Producer *DocClipBase::audioProducer(int track)
465 if (m_audioTrackProducers.count() <= track) {
466 while (m_audioTrackProducers.count() - 1 < track) {
467 m_audioTrackProducers.append(NULL);
470 if (m_audioTrackProducers.at(track) == NULL) {
471 Mlt::Producer *base = producer();
472 m_audioTrackProducers[track] = new Mlt::Producer(*(base->profile()), base->get("resource"));
473 if (m_properties.contains("force_aspect_ratio")) m_audioTrackProducers.at(track)->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
474 if (m_properties.contains("threads")) m_audioTrackProducers.at(track)->set("threads", m_properties.value("threads").toInt());
475 m_audioTrackProducers.at(track)->set("video_index", -1);
476 if (m_properties.contains("audio_index")) m_audioTrackProducers.at(track)->set("audio_index", m_properties.value("audio_index").toInt());
477 char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track) + "_audio").toUtf8().data());
478 m_audioTrackProducers.at(track)->set("id", tmp);
481 return m_audioTrackProducers.at(track);
484 Mlt::Producer *DocClipBase::videoProducer()
486 if (m_videoOnlyProducer == NULL) {
488 for (i = 0; i < m_baseTrackProducers.count(); i++)
489 if (m_baseTrackProducers.at(i) != NULL) break;
490 if (i >= m_baseTrackProducers.count()) return NULL;
491 m_videoOnlyProducer = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
492 if (m_properties.contains("force_aspect_ratio")) m_videoOnlyProducer->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
493 if (m_properties.contains("threads")) m_videoOnlyProducer->set("threads", m_properties.value("threads").toInt());
494 m_videoOnlyProducer->set("audio_index", -1);
495 if (m_properties.contains("video_index")) m_videoOnlyProducer->set("video_index", m_properties.value("video_index").toInt());
496 char *tmp = (char *) qstrdup(QString(getId() + "_video").toUtf8().data());
497 m_videoOnlyProducer->set("id", tmp);
500 return m_videoOnlyProducer;
503 Mlt::Producer *DocClipBase::producer(int track)
505 /*for (int i = 0; i < m_baseTrackProducers.count(); i++) {
506 if (m_baseTrackProducers.at(i)) kDebug() << "// PROD: " << i << ", ID: " << m_baseTrackProducers.at(i)->get("id");
508 if (track == -1 || (m_clipType != AUDIO && m_clipType != AV)) {
509 if (m_baseTrackProducers.count() == 0) return NULL;
510 for (int i = 0; i < m_baseTrackProducers.count(); i++) {
511 if (m_baseTrackProducers.at(i) != NULL)
512 return m_baseTrackProducers.at(i);
516 if (track >= m_baseTrackProducers.count()) {
517 while (m_baseTrackProducers.count() - 1 < track) {
518 m_baseTrackProducers.append(NULL);
521 if (m_baseTrackProducers.at(track) == NULL) {
523 for (i = 0; i < m_baseTrackProducers.count(); i++)
524 if (m_baseTrackProducers.at(i) != NULL) break;
526 if (i >= m_baseTrackProducers.count()) return NULL;
528 if (KIO::NetAccess::exists(KUrl(m_baseTrackProducers.at(i)->get("resource")), KIO::NetAccess::SourceSide, 0))
529 m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
530 else { // special case for placeholder clips
531 m_baseTrackProducers[track] = NULL;
535 if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
536 if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
537 if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
538 if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt());
539 char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track)).toUtf8().data());
540 m_baseTrackProducers[track]->set("id", tmp);
542 if (KdenliveSettings::dropbframes() && m_baseTrackProducers.at(i)->get("skip_loop_filter") && strcmp(m_baseTrackProducers.at(i)->get("skip_loop_filter"), "all") == 0) {
543 m_baseTrackProducers[track]->set("skip_loop_filter", "all");
544 m_baseTrackProducers[track]->set("skip_frame", "bidir");
547 return m_baseTrackProducers.at(track);
550 void DocClipBase::setProducerProperty(const char *name, int data)
552 for (int i = 0; i < m_baseTrackProducers.count(); i++) {
553 if (m_baseTrackProducers.at(i) != NULL)
554 m_baseTrackProducers[i]->set(name, data);
558 void DocClipBase::setProducerProperty(const char *name, double data)
560 for (int i = 0; i < m_baseTrackProducers.count(); i++) {
561 if (m_baseTrackProducers.at(i) != NULL)
562 m_baseTrackProducers[i]->set(name, data);
566 void DocClipBase::setProducerProperty(const char *name, const char *data)
568 for (int i = 0; i < m_baseTrackProducers.count(); i++) {
569 if (m_baseTrackProducers.at(i) != NULL)
570 m_baseTrackProducers[i]->set(name, data);
574 const char *DocClipBase::producerProperty(const char *name) const
576 for (int i = 0; i < m_baseTrackProducers.count(); i++) {
577 if (m_baseTrackProducers.at(i) != NULL) {
578 return m_baseTrackProducers.at(i)->get(name);
585 void DocClipBase::slotRefreshProducer()
587 if (m_baseTrackProducers.count() == 0) return;
588 kDebug() << "//////////// REFRESH CLIP !!!!!!!!!!!!!!!!";
589 if (m_clipType == SLIDESHOW) {
590 /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
591 Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
593 delete m_clipProducer;
594 m_clipProducer = new Mlt::Producer(producer.get_producer());
595 if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
596 setProducerProperty("ttl", getProperty("ttl").toInt());
597 //m_clipProducer->set("id", getProperty("id"));
598 if (getProperty("fade") == "1") {
599 // we want a fade filter effect
600 kDebug() << "//////////// FADE WANTED";
601 Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
603 Mlt::Filter *filter = clipService.filter(ct);
605 if (strcmp(filter->get("mlt_service"), "luma") == 0) {
609 filter = clipService.filter(ct);
612 if (filter && strcmp(filter->get("mlt_service"), "luma") == 0) {
613 filter->set("period", getProperty("ttl").toInt() - 1);
614 filter->set("luma.out", getProperty("luma_duration").toInt());
615 QString resource = getProperty("luma_file");
616 char *tmp = (char *) qstrdup(resource.toUtf8().data());
617 filter->set("luma.resource", tmp);
619 if (!getProperty("softness").isEmpty()) {
620 int soft = getProperty("softness").toInt();
621 filter->set("luma.softness", (double) soft / 100.0);
624 // filter does not exist, create it...
625 Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
626 filter->set("period", getProperty("ttl").toInt() - 1);
627 filter->set("luma.out", getProperty("luma_duration").toInt());
628 QString resource = getProperty("luma_file");
629 char *tmp = (char *) qstrdup(resource.toUtf8().data());
630 filter->set("luma.resource", tmp);
632 if (!getProperty("softness").isEmpty()) {
633 int soft = getProperty("softness").toInt();
634 filter->set("luma.softness", (double) soft / 100.0);
636 clipService.attach(*filter);
639 kDebug() << "//////////// FADE NOT WANTED!!!";
640 Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
642 Mlt::Filter *filter = clipService.filter(0);
644 if (strcmp(filter->get("mlt_service"), "luma") == 0) {
645 clipService.detach(*filter);
647 filter = clipService.filter(ct);
653 void DocClipBase::setProperties(QMap <QString, QString> properties)
655 // changing clip type is not allowed
656 properties.remove("type");
657 QMapIterator<QString, QString> i(properties);
658 bool refreshProducer = false;
660 keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
661 while (i.hasNext()) {
663 setProperty(i.key(), i.value());
664 if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
666 if (refreshProducer) slotRefreshProducer();
669 void DocClipBase::setMetadata(QMap <QString, QString> properties)
671 m_metadata = properties;
674 QMap <QString, QString> DocClipBase::metadata() const
679 void DocClipBase::clearProperty(const QString &key)
681 m_properties.remove(key);
684 void DocClipBase::getFileHash(const QString url)
686 if (m_clipType == SLIDESHOW) return;
688 if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
691 //kDebug() << "SETTING HASH of" << value;
692 m_properties.insert("file_size", QString::number(file.size()));
694 * 1 MB = 1 second per 450 files (or faster)
695 * 10 MB = 9 seconds per 450 files (or faster)
697 if (file.size() > 1000000*2) {
698 fileData = file.read(1000000);
699 if (file.seek(file.size() - 1000000))
700 fileData.append(file.readAll());
702 fileData = file.readAll();
704 fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
705 m_properties.insert("file_hash", QString(fileHash.toHex()));
709 QString DocClipBase::getClipHash() const
712 if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex();
713 else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex();
714 else hash = m_properties.value("file_hash");
719 QString DocClipBase::getHash(const QString &path)
722 if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
726 * 1 MB = 1 second per 450 files (or faster)
727 * 10 MB = 9 seconds per 450 files (or faster)
729 if (file.size() > 1000000*2) {
730 fileData = file.read(1000000);
731 if (file.seek(file.size() - 1000000))
732 fileData.append(file.readAll());
734 fileData = file.readAll();
736 return QCryptographicHash::hash(fileData, QCryptographicHash::Md5).toHex();
741 void DocClipBase::refreshThumbUrl()
743 if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));
746 void DocClipBase::setProperty(const QString &key, const QString &value)
748 m_properties.insert(key, value);
749 if (key == "resource") {
751 if (m_thumbProd) m_thumbProd->updateClipUrl(KUrl(value), m_properties.value("file_hash"));
752 } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
753 //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
754 else if (key == "colour") {
755 char *tmp = (char *) qstrdup(value.toUtf8().data());
756 setProducerProperty("colour", tmp);
758 } else if (key == "templatetext") {
759 char *tmp = (char *) qstrdup(value.toUtf8().data());
760 setProducerProperty("templatetext", tmp);
762 setProducerProperty("force_reload", 1);
763 } else if (key == "xmldata") {
764 char *tmp = (char *) qstrdup(value.toUtf8().data());
765 setProducerProperty("xmldata", tmp);
767 setProducerProperty("force_reload", 1);
768 } else if (key == "force_aspect_ratio") {
769 if (value.isEmpty()) {
770 m_properties.remove("force_aspect_ratio");
771 setProducerProperty("force_aspect_ratio", 0);
772 } else setProducerProperty("force_aspect_ratio", value.toDouble());
773 } else if (key == "threads") {
774 if (value.isEmpty()) {
775 m_properties.remove("threads");
776 setProducerProperty("threads", 1);
777 } else setProducerProperty("threads", value.toInt());
778 } else if (key == "video_index") {
779 if (value.isEmpty()) {
780 m_properties.remove("video_index");
781 setProducerProperty("video_index", m_properties.value("default_video").toInt());
782 } else setProducerProperty("video_index", value.toInt());
783 } else if (key == "audio_index") {
784 if (value.isEmpty()) {
785 m_properties.remove("audio_index");
786 setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
787 } else setProducerProperty("audio_index", value.toInt());
791 QMap <QString, QString> DocClipBase::properties() const
796 bool DocClipBase::slotGetAudioThumbs()
798 if (m_thumbProd == NULL) return false;
799 if (!KdenliveSettings::audiothumbnails()) {
800 if (m_audioTimer != NULL) m_audioTimer->stop();
803 if (m_audioThumbCreated) {
804 if (m_audioTimer != NULL) m_audioTimer->stop();
807 if (m_audioTimer != NULL)
808 m_audioTimer->start(1500);
809 double lengthInFrames = duration().frames(KdenliveSettings::project_fps());
810 m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20);
814 bool DocClipBase::isPlaceHolder() const
816 return m_placeHolder;