#include "docclipbase.h"
DocClipBase::DocClipBase(QDomElement xml, uint id):
-m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL)
+m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL)
{
int type = xml.attribute("type").toInt();
m_clipType = (CLIPTYPE) type;
kDebug() << "type is video" << (m_clipType==AV) << " " << m_clipType;
if (m_clipType == AV || m_clipType==AUDIO ||m_clipType==UNKNOWN){
+ m_audioTimer = new QTimer( this );
+ connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
emit getAudioThumbs();
}
}
void DocClipBase::slotGetAudioThumbs(){
kDebug() << "getting audio data";
- double lengthInFrames=duration().frames(/*framesPerSecond()*/25);
- m_thumbProd->getAudioThumbs(fileURL(), 1, 0, lengthInFrames, 20);
+ if (audioThumbCreated){
+ if (m_audioTimer!=NULL)
+ m_audioTimer->stop();
+ }else{
+ if (m_audioTimer!=NULL)
+ m_audioTimer->start(5);
+ double lengthInFrames=duration().frames(/*framesPerSecond()*/25);
+ m_thumbProd->getAudioThumbs(fileURL(), 1, 0, 10 /*must be number of frames*/, 20);
+
+ }
}
void MyThread::run()
{
+
if (!f.open( QIODevice::WriteOnly )) {
kDebug()<<"++++++++ ERROR WRITING TO FILE: "<<f.fileName()<<endl;
kDebug()<<"++++++++ DISABLING AUDIO THUMBS"<<endl;
*/
int last_val = 0;
int val = 0;
+ kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid();
for (int z=(int) m_frame;z<(int) (m_frame+m_frameLength) && m_producer.is_valid();z++){
+ kDebug() << "starting audithumb for frame " << z;
+
if (stop_me) break;
val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0);
if (last_val!=val & val > 1){
m_array[i] = qAbs((*( m_pcm + c + i * m_samples / m_array.size() ))>>8);
}
f.write(m_array);
+
}
} else{
f.write(QByteArray(m_arrayWidth,'\x00'));
if ((thumbProducer.isRunning () && thumbProducer.isWorking()) || channel == 0) {
return;
}
-
+
QMap <int, QMap <int, QByteArray> > storeIn;
//FIXME: Hardcoded!!!
int m_frequency = 48000;
int m_channels = channel;
- /*TODO
+
+ m_thumbFile="/tmp/testfile";
+ /*FIXME WHY crash here ??????
if (m_url != url) {
m_url = url;
QCryptographicHash context(QCryptographicHash::Sha1);
m_thumbFile = KdenliveSettings::currenttmpfolder() + context.result().toHex() + ".thumb";
}*/
- return;
+
QFile f(m_thumbFile);
if (f.open( QIODevice::ReadOnly )) {
QByteArray channelarray = f.readAll();
// Retrieve audio / video codec name
// Fetch the video_context
+#if 0 //until the reason for the chrashs is found
AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data( properties, "video_context", NULL );
if (context != NULL) {
// Get the video_index
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name )
filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
}
-
+#endif
// metadata