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