]> git.sesse.net Git - kdenlive/blob - src/docclipbase.cpp
Fix problem on effect deletion, might help in:
[kdenlive] / src / docclipbase.cpp
1 /**************************1*************************************************
2                           DocClipBase.cpp  -  description
3                              -------------------
4     begin                : Fri Apr 12 2002
5     copyright            : (C) 2002 by Jason Wood
6     email                : jasonwood@blueyonder.co.uk
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include <QCryptographicHash>
19
20 #include <KDebug>
21
22 #include "kdenlivesettings.h"
23 #include "docclipbase.h"
24 #include "kthumb.h"
25 #include "clipmanager.h"
26
27 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id):
28         m_id(id), m_description(QString()), m_refcount(0), m_audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL), m_properties(QMap <QString, QString> ()), audioFrameChache(QMap<int, QMap<int, QByteArray> > ()), m_baseTrackProducers(QList <Mlt::Producer *>()), m_snapMarkers(QList < CommentedTime > ())  {
29     int type = xml.attribute("type").toInt();
30     m_clipType = (CLIPTYPE) type;
31     m_name = xml.attribute("name");
32
33     QDomNamedNodeMap attributes = xml.attributes();
34     for (unsigned int i = 0; i < attributes.count(); i++) {
35         m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue());
36     }
37
38     KUrl url = KUrl(xml.attribute("resource"));
39     if (!m_properties.contains("file_hash") && !url.isEmpty()) getFileHash(url.path());
40     int out = xml.attribute("out").toInt();
41     if (out != 0) {
42         setDuration(GenTime(out, KdenliveSettings::project_fps()));
43     } else {
44         out = xml.attribute("duration").toInt();
45         if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
46     }
47     if (m_name.isEmpty()) m_name = url.fileName();
48
49     //if (!url.isEmpty() && QFile::exists(url.path()))
50     {
51         m_thumbProd = new KThumb(clipManager, url, m_id, m_properties.value("file_hash"));
52         if (m_clipType == AV || m_clipType == AUDIO) slotCreateAudioTimer();
53     }
54     //kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType;
55 }
56
57 /*DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
58     DocClipBase::operator=(clip);
59     m_id = clip.getId();
60     m_clipType = clip.clipType();
61     m_name = clip.name();
62     m_duration = clip.duration();
63     m_audioThumbCreated = clip.audioThumbCreated();
64     m_properties = clip.properties();
65     return *this;
66 }*/
67
68 DocClipBase::~DocClipBase() {
69     if (m_thumbProd) {
70         delete m_thumbProd;
71     }
72     if (m_audioTimer) {
73         m_audioTimer->stop();
74         delete m_audioTimer;
75     }
76     qDeleteAll(m_baseTrackProducers);
77     m_baseTrackProducers.clear();
78 }
79
80 void DocClipBase::slotCreateAudioTimer() {
81     connect(m_thumbProd, SIGNAL(audioThumbReady(QMap <int, QMap <int, QByteArray> >)), this , SLOT(updateAudioThumbnail(QMap <int, QMap <int, QByteArray> >)));
82     connect(this, SIGNAL(getAudioThumbs()), this , SLOT(slotGetAudioThumbs()));
83     m_audioTimer = new QTimer(this);
84     connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
85 }
86
87 void DocClipBase::askForAudioThumbs() {
88     if (m_thumbProd) m_thumbProd->askForAudioThumbs(getId());
89 }
90
91 void DocClipBase::slotClearAudioCache() {
92     if (m_thumbProd) m_thumbProd->stopAudioThumbs();
93     if (m_audioTimer != NULL) m_audioTimer->stop();
94     audioFrameChache.clear();
95     m_audioThumbCreated = false;
96 }
97
98 /*void DocClipBase::getClipMainThumb() {
99     if (m_thumbProd) m_thumbProd->getMainThumb(m_properties.value("thumbnail").toInt());
100 }*/
101
102 KThumb *DocClipBase::thumbProducer() {
103     return m_thumbProd;
104 }
105
106 bool DocClipBase::audioThumbCreated() const {
107     return m_audioThumbCreated;
108 }
109
110 void DocClipBase::setName(const QString name) {
111     m_name = name;
112 }
113
114 const QString & DocClipBase::name() const {
115
116     return m_name;
117 }
118
119 const QString &DocClipBase::getId() const {
120     return m_id;
121 }
122
123 void DocClipBase::setId(const QString &newId) {
124     m_id = newId;
125 }
126
127 const CLIPTYPE & DocClipBase::clipType() const {
128     return m_clipType;
129 }
130
131 void DocClipBase::setClipType(CLIPTYPE type) {
132     m_clipType = type;
133
134     m_properties.insert("type", QString::number((int) type));
135     if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO))
136         slotCreateAudioTimer();
137 }
138
139 KUrl DocClipBase::fileURL() const {
140     QString res = m_properties.value("resource");
141     if (m_clipType != COLOR && !res.isEmpty()) return KUrl(res);
142     return KUrl();
143 }
144
145 void DocClipBase::setClipThumbFrame(const uint &ix) {
146     m_properties.insert("thumbnail", QString::number((int) ix));
147 }
148
149 uint DocClipBase::getClipThumbFrame() const {
150     return (uint) m_properties.value("thumbnail").toInt();
151 }
152
153 const QString DocClipBase::description() const {
154     return m_properties.value("description");
155 }
156
157 bool DocClipBase::isTransparent() const {
158     return (m_properties.value("transparency") == "1");
159 }
160
161 const QString DocClipBase::getProperty(const QString prop) const {
162     return m_properties.value(prop);
163 }
164
165 void DocClipBase::setDuration(GenTime dur) {
166     m_duration = dur;
167     m_properties.insert("duration", QString::number((int) dur.frames(KdenliveSettings::project_fps())));
168 }
169
170 const GenTime &DocClipBase::duration() const {
171     return m_duration;
172 }
173
174 const GenTime &DocClipBase::maxDuration() const {
175     if (m_clipType == COLOR || m_clipType == IMAGE || m_clipType == TEXT || (m_clipType == SLIDESHOW &&  m_properties.value("loop") == "1")) {
176         const GenTime dur(15000, KdenliveSettings::project_fps());
177         return dur;
178     }
179     return m_duration;
180 }
181
182 bool DocClipBase::hasFileSize() const {
183     return true;
184 }
185
186
187 // virtual
188 QDomElement DocClipBase::toXML() const {
189     QDomDocument doc;
190
191     QDomElement clip = doc.createElement("producer");
192
193     QMapIterator<QString, QString> i(m_properties);
194     while (i.hasNext()) {
195         i.next();
196         if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value());
197     }
198     //doc.appendChild(clip);
199     //kDebug()<<"/// CLIP XML: "<<doc.toString();
200     return clip;
201 }
202
203 DocClipBase *DocClipBase::
204 createClip(KdenliveDoc *doc, const QDomElement & element) {
205     DocClipBase *clip = 0;
206     QString description;
207     QDomNode node = element;
208     node.normalize();
209     if (element.tagName() != "kdenliveclip") {
210         kWarning() <<
211         "DocClipBase::createClip() element has unknown tagName : " << element.tagName();
212         return 0;
213     }
214
215     QDomNode n = element.firstChild();
216
217     while (!n.isNull()) {
218         QDomElement e = n.toElement();
219         if (!e.isNull()) {
220             QString tagName = e.tagName();
221             if (e.tagName() == "avfile") {
222                 // clip = DocClipAVFile::createClip(e);
223             } else if (e.tagName() == "DocTrackBaseList") {
224                 // clip = DocClipProject::createClip(doc, e);
225             }
226         } else {
227             QDomText text = n.toText();
228             if (!text.isNull()) {
229                 description = text.nodeValue();
230             }
231         }
232
233         n = n.nextSibling();
234     }
235     if (clip == 0) {
236         kWarning() << "DocClipBase::createClip() unable to create clip";
237     } else {
238         // setup DocClipBase specifics of the clip.
239         QMap <QString, QString> props;
240         props.insert("description", description);
241         clip->setProperties(props);
242         clip->setAudioThumbCreated(false);
243     }
244     return clip;
245 }
246
247 void DocClipBase::setAudioThumbCreated(bool isDone) {
248     m_audioThumbCreated = isDone;
249 }
250
251
252 void DocClipBase::setThumbnail(const QPixmap & pixmap) {
253     m_thumbnail = pixmap;
254 }
255
256 const QPixmap & DocClipBase::thumbnail() const {
257     return m_thumbnail;
258 }
259
260 void DocClipBase::updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data) {
261     //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
262     audioFrameChache = data;
263     m_audioThumbCreated = true;
264     emit gotAudioData();
265 }
266
267 QList < GenTime > DocClipBase::snapMarkers() const {
268     QList < GenTime > markers;
269
270     for (uint count = 0; count < m_snapMarkers.count(); ++count) {
271         markers.append(m_snapMarkers[count].time());
272     }
273
274     return markers;
275 }
276
277 QList < CommentedTime > DocClipBase::commentedSnapMarkers() const {
278     return m_snapMarkers;
279 }
280
281 void DocClipBase::setSnapMarkers(QList < CommentedTime > markers) {
282     m_snapMarkers = markers;
283 }
284
285 void DocClipBase::addSnapMarker(const GenTime & time, QString comment) {
286     QList < CommentedTime >::Iterator it = m_snapMarkers.begin();
287     for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
288         if ((*it).time() >= time)
289             break;
290     }
291
292     if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
293         (*it).setComment(comment);
294         //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
295     } else {
296         CommentedTime t(time, comment);
297         m_snapMarkers.insert(it, t);
298     }
299
300 }
301
302 void DocClipBase::editSnapMarker(const GenTime & time, QString comment) {
303     QList < CommentedTime >::Iterator it;
304     for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) {
305         if ((*it).time() == time)
306             break;
307     }
308     if (it != m_snapMarkers.end()) {
309         (*it).setComment(comment);
310     } else {
311         kError() << "trying to edit Snap Marker that does not already exists";
312     }
313 }
314
315 QString DocClipBase::deleteSnapMarker(const GenTime & time) {
316     QString result = i18n("Marker");
317     QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
318
319     while (itt != m_snapMarkers.end()) {
320         if ((*itt).time() == time)
321             break;
322         ++itt;
323     }
324
325     if ((itt != m_snapMarkers.end()) && ((*itt).time() == time)) {
326         result = (*itt).comment();
327         m_snapMarkers.erase(itt);
328     }
329     return result;
330 }
331
332
333 GenTime DocClipBase::hasSnapMarkers(const GenTime & time) {
334     QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
335
336     while (itt != m_snapMarkers.end()) {
337         if ((*itt).time() == time)
338             return time;
339         ++itt;
340     }
341
342     return GenTime(0.0);
343 }
344
345 GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime) {
346     int it;
347     for (it = 0; it < m_snapMarkers.count(); it++) {
348         if (m_snapMarkers[it].time() >= currTime)
349             break;
350     }
351     if (it == 0) return GenTime();
352     else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime)
353         return m_snapMarkers[it].time();
354     else return m_snapMarkers[it-1].time();
355 }
356
357 GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime) {
358     int it;
359     for (it = 0; it < m_snapMarkers.count(); it++) {
360         if (m_snapMarkers[it].time() > currTime)
361             break;
362     }
363     if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time();
364     return duration();
365 }
366
367 QString DocClipBase::markerComment(GenTime t) {
368     QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
369
370     while (itt != m_snapMarkers.end()) {
371         if ((*itt).time() == t)
372             return (*itt).comment();
373         ++itt;
374     }
375     return QString::null;
376 }
377
378 void DocClipBase::deleteProducers() {
379     qDeleteAll(m_baseTrackProducers);
380     m_baseTrackProducers.clear();
381     if (m_thumbProd) m_thumbProd->clearProducer();
382 }
383
384 void DocClipBase::setProducer(Mlt::Producer *producer) {
385     if (producer == NULL) return;
386     QString id = producer->get("id");
387     if (id.contains('_')) {
388         // this is a subtrack producer, insert it at correct place
389         int pos = id.section('_', 1, 1).toInt();
390         if (pos >= m_baseTrackProducers.count()) {
391             while (m_baseTrackProducers.count() - 1 < pos) {
392                 m_baseTrackProducers.append(NULL);
393             }
394         }
395         if (m_baseTrackProducers.at(pos) == NULL) m_baseTrackProducers[pos] = producer;
396     } else {
397         if (m_baseTrackProducers.isEmpty()) m_baseTrackProducers.append(producer);
398         else if (m_baseTrackProducers.at(0) == NULL) m_baseTrackProducers[0] = producer;
399     }
400     //m_clipProducer = producer;
401     //m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
402     if (m_thumbProd && !m_thumbProd->hasProducer()) m_thumbProd->setProducer(producer);
403 }
404
405 Mlt::Producer *DocClipBase::producer(int track) {
406     /*for (int i = 0; i < m_baseTrackProducers.count(); i++) {
407         if (m_baseTrackProducers.at(i)) kDebug() << "// PROD: " << i << ", ID: " << m_baseTrackProducers.at(i)->get("id");
408     }*/
409     if (track == -1 || (m_clipType != AUDIO && m_clipType != AV)) {
410         if (m_baseTrackProducers.count() == 0) return NULL;
411         int i;
412         for (int i = 0; i < m_baseTrackProducers.count(); i++)
413             if (m_baseTrackProducers.at(i) != NULL) return m_baseTrackProducers.at(i);
414         return NULL;
415     }
416     if (track >= m_baseTrackProducers.count()) {
417         while (m_baseTrackProducers.count() - 1 < track) {
418             m_baseTrackProducers.append(NULL);
419         }
420     }
421     if (m_baseTrackProducers.at(track) == NULL) {
422         int i;
423         for (i = 0; i < m_baseTrackProducers.count(); i++)
424             if (m_baseTrackProducers.at(i) != NULL) break;
425         if (i >= m_baseTrackProducers.count()) return NULL;
426         m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
427         if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
428         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
429         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
430         if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt());
431         char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track)).toUtf8().data());
432         m_baseTrackProducers[track]->set("id", tmp);
433         delete[] tmp;
434         if (KdenliveSettings::dropbframes() && m_baseTrackProducers.at(i)->get("skip_loop_filter") && strcmp(m_baseTrackProducers.at(i)->get("skip_loop_filter"), "all") == 0) {
435             m_baseTrackProducers[track]->set("skip_loop_filter", "all");
436             m_baseTrackProducers[track]->set("skip_frame", "bidir");
437         }
438     }
439     return m_baseTrackProducers.at(track);
440 }
441
442 void DocClipBase::setProducerProperty(const char *name, int data) {
443     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
444         if (m_baseTrackProducers.at(i) != NULL)
445             m_baseTrackProducers[i]->set(name, data);
446     }
447 }
448
449 void DocClipBase::setProducerProperty(const char *name, const char *data) {
450     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
451         if (m_baseTrackProducers.at(i) != NULL)
452             m_baseTrackProducers[i]->set(name, data);
453     }
454 }
455
456 const char *DocClipBase::producerProperty(const char *name) const {
457     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
458         if (m_baseTrackProducers.at(i) != NULL) {
459             return m_baseTrackProducers.at(i)->get(name);
460         }
461     }
462     return NULL;
463 }
464
465
466 void DocClipBase::slotRefreshProducer() {
467     if (m_baseTrackProducers.count() == 0) return;
468     kDebug() << "////////////   REFRESH CLIP !!!!!!!!!!!!!!!!";
469     if (m_clipType == SLIDESHOW) {
470         /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
471                Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
472                delete[] tmp;
473         delete m_clipProducer;
474         m_clipProducer = new Mlt::Producer(producer.get_producer());
475         if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
476         setProducerProperty("ttl", getProperty("ttl").toInt());
477         //m_clipProducer->set("id", getProperty("id"));
478         if (getProperty("fade") == "1") {
479             // we want a fade filter effect
480             kDebug() << "////////////   FADE WANTED";
481             Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
482             int ct = 0;
483             Mlt::Filter *filter = clipService.filter(ct);
484             while (filter) {
485                 if (filter->get("mlt_service") == "luma") {
486                     break;
487                 }
488                 ct++;
489                 filter = clipService.filter(ct);
490             }
491
492             if (filter && filter->get("mlt_service") == "luma") {
493                 filter->set("period", getProperty("ttl").toInt() - 1);
494                 filter->set("luma.out", getProperty("luma_duration").toInt());
495                 QString resource = getProperty("luma_file");
496                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
497                 filter->set("luma.resource", tmp);
498                 delete[] tmp;
499                 if (getProperty("softness") != QString()) {
500                     int soft = getProperty("softness").toInt();
501                     filter->set("luma.softness", (double) soft / 100.0);
502                 }
503             } else {
504                 // filter does not exist, create it...
505                 Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
506                 filter->set("period", getProperty("ttl").toInt() - 1);
507                 filter->set("luma.out", getProperty("luma_duration").toInt());
508                 QString resource = getProperty("luma_file");
509                 char *tmp = (char *) qstrdup(resource.toUtf8().data());
510                 filter->set("luma.resource", tmp);
511                 delete[] tmp;
512                 if (getProperty("softness") != QString()) {
513                     int soft = getProperty("softness").toInt();
514                     filter->set("luma.softness", (double) soft / 100.0);
515                 }
516                 clipService.attach(*filter);
517             }
518         } else {
519             kDebug() << "////////////   FADE NOT WANTED!!!";
520             Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
521             int ct = 0;
522             Mlt::Filter *filter = clipService.filter(0);
523             while (filter) {
524                 if (filter->get("mlt_service") == "luma") {
525                     clipService.detach(*filter);
526                 } else ct++;
527                 filter = clipService.filter(ct);
528             }
529         }
530     }
531 }
532
533 void DocClipBase::setProperties(QMap <QString, QString> properties) {
534     // changing clip type is not allowed
535     properties.remove("type");
536     QMapIterator<QString, QString> i(properties);
537     bool refreshProducer = false;
538     QStringList keys;
539     keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
540     while (i.hasNext()) {
541         i.next();
542         setProperty(i.key(), i.value());
543         if (m_clipType == SLIDESHOW && keys.contains(i.key())) refreshProducer = true;
544     }
545     if (refreshProducer) slotRefreshProducer();
546 }
547
548 void DocClipBase::setMetadata(QMap <QString, QString> properties) {
549     m_metadata = properties;
550 }
551
552 QMap <QString, QString> DocClipBase::metadata() const {
553     return m_metadata;
554 }
555
556 void DocClipBase::clearProperty(const QString &key) {
557     m_properties.remove(key);
558 }
559
560 void DocClipBase::getFileHash(const QString &url) {
561     if (m_clipType == SLIDESHOW) return;
562     QFile file(url);
563     if (file.open(QIODevice::ReadOnly)) { // write size and hash only if resource points to a file
564         QByteArray fileData;
565         QByteArray fileHash;
566         //kDebug() << "SETTING HASH of" << value;
567         m_properties.insert("file_size", QString::number(file.size()));
568         /*
569                * 1 MB = 1 second per 450 files (or faster)
570                * 10 MB = 9 seconds per 450 files (or faster)
571                */
572         if (file.size() > 1000000*2) {
573             fileData = file.read(1000000);
574             if (file.seek(file.size() - 1000000))
575                 fileData.append(file.readAll());
576         } else
577             fileData = file.readAll();
578         file.close();
579         fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
580         m_properties.insert("file_hash", QString(fileHash.toHex()));
581         //kDebug() << file.fileName() << file.size() << fileHash.toHex();
582     }
583 }
584
585 QString DocClipBase::getClipHash() const {
586     QString hash;
587     if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex();
588     else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex();
589     else hash = m_properties.value("file_hash");
590     return hash;
591 }
592
593 void DocClipBase::refreshThumbUrl() {
594     if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));
595 }
596
597 void DocClipBase::setProperty(const QString &key, const QString &value) {
598     m_properties.insert(key, value);
599     if (key == "resource") {
600         getFileHash(value);
601         if (m_thumbProd) m_thumbProd->updateClipUrl(KUrl(value), m_properties.value("file_hash"));
602     } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
603     //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
604     else if (key == "colour") {
605         char *tmp = (char *) qstrdup(value.toUtf8().data());
606         setProducerProperty("colour", tmp);
607         delete[] tmp;
608     } else if (key == "xmldata") {
609         setProducerProperty("force_reload", 1);
610     } else if (key == "force_aspect_ratio") {
611         if (value.isEmpty()) {
612             m_properties.remove("force_aspect_ratio");
613             setProducerProperty("force_aspect_ratio", 0);
614         } else setProducerProperty("force_aspect_ratio", value.toDouble());
615     } else if (key == "threads") {
616         if (value.isEmpty()) {
617             m_properties.remove("threads");
618             setProducerProperty("threads", 1);
619         } else setProducerProperty("threads", value.toInt());
620     } else if (key == "video_index") {
621         if (value.isEmpty()) {
622             m_properties.remove("video_index");
623             setProducerProperty("video_index", m_properties.value("default_video").toInt());
624         } else setProducerProperty("video_index", value.toInt());
625     } else if (key == "audio_index") {
626         if (value.isEmpty()) {
627             m_properties.remove("audio_index");
628             setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
629         } else setProducerProperty("audio_index", value.toInt());
630     }
631 }
632
633 QMap <QString, QString> DocClipBase::properties() const {
634     return m_properties;
635 }
636
637 bool DocClipBase::slotGetAudioThumbs() {
638     if (m_thumbProd == NULL) return false;
639     if (!KdenliveSettings::audiothumbnails()) {
640         if (m_audioTimer != NULL) m_audioTimer->stop();
641         return false;
642     }
643     if (m_audioThumbCreated) {
644         if (m_audioTimer != NULL) m_audioTimer->stop();
645         return false;
646     }
647     if (m_audioTimer != NULL)
648         m_audioTimer->start(1500);
649     double lengthInFrames = duration().frames(KdenliveSettings::project_fps());
650     m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20);
651     return true;
652 }
653
654
655