ItemInfo newPos;
newPos.startPos = cutTime;
newPos.endPos = info.endPos;
+ newPos.cropStart = item->cropStart() + (cutTime - info.startPos);
newPos.track = info.track;
item->resizeEnd(cutPos, m_scale);
- ClipItem *dup = new ClipItem(item->baseClip(), newPos, item->cropStart() + (cutTime - info.startPos), m_scale, m_document->fps());
+ ClipItem *dup = new ClipItem(item->baseClip(), newPos, m_scale, m_document->fps());
scene()->addItem(dup);
m_document->renderer()->mltCutClip(m_tracksList.count() - info.track, cutTime);
item->baseClip()->addReference();
info.endPos = info.startPos + clip->duration();
info.track = (int)(pos.y() / m_tracksHeight);
//kDebug()<<"------------ ADDING CLIP ITEM----: "<<info.startPos.frames(25)<<", "<<info.endPos.frames(25)<<", "<<info.track;
- m_dropItem = new ClipItem(clip, info, GenTime(), m_scale, m_document->fps());
+ m_dropItem = new ClipItem(clip, info, m_scale, m_document->fps());
scene()->addItem(m_dropItem);
}
m_dropItem->baseClip()->addReference();
m_document->updateClip(m_dropItem->baseClip()->getId());
// kDebug()<<"IIIIIIIIIIIIIIIIIIIIIIII TRAX CNT: "<<m_tracksList.count()<<", DROP: "<<m_dropItem->track();
- m_document->renderer()->mltInsertClip(m_tracksList.count() - m_dropItem->track(), m_dropItem->startPos(), m_dropItem->xml());
+ m_document->renderer()->mltInsertClip(m_tracksList.count() - m_dropItem->track(), m_dropItem->startPos(), m_dropItem->cropStart(), m_dropItem->xml());
m_document->setModified(true);
} else QGraphicsView::dropEvent(event);
m_dropItem = NULL;
if (item->type() == AVWIDGET) {
ClipItem *clip = static_cast <ClipItem*>(item);
new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), item->info(), false, false, moveClips);
- m_document->renderer()->mltInsertClip(m_tracksList.count() - item->track(), item->startPos(), clip->xml());
+ m_document->renderer()->mltInsertClip(m_tracksList.count() - item->track(), item->startPos(), item->cropStart(), clip->xml());
} else {
Transition *tr = static_cast <Transition*>(item);
ItemInfo transitionInfo = tr->info();
deleteSelected->setText("Delete selected items");
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
- ClipItem *item = (ClipItem *) itemList.at(i);
+ ClipItem *item = static_cast <ClipItem *> (itemList.at(i));
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), true, true, deleteSelected);
} else if (itemList.at(i)->type() == TRANSITIONWIDGET) {
- Transition *item = (Transition *) itemList.at(i);
+ Transition *item = static_cast <Transition *> (itemList.at(i));
ItemInfo info;
info.startPos = item->startPos();
info.endPos = item->endPos();
info.track = item->track();
- new AddTransitionCommand(this, info, item->transitionEndTrack(), QDomElement(), true, true, deleteSelected);
+ new AddTransitionCommand(this, info, item->transitionEndTrack(), item->toXML(), true, true, deleteSelected);
}
}
m_commandStack->push(deleteSelected);
void CustomTrackView::addClip(QDomElement xml, int clipId, ItemInfo info) {
DocClipBase *baseclip = m_document->clipManager()->getClipById(clipId);
- int crop = xml.attribute("in").toInt();
- ClipItem *item = new ClipItem(baseclip, info, GenTime(crop, m_document->fps()), m_scale, m_document->fps());
+ ClipItem *item = new ClipItem(baseclip, info, m_scale, m_document->fps());
scene()->addItem(item);
baseclip->addReference();
m_document->updateClip(baseclip->getId());
- m_document->renderer()->mltInsertClip(m_tracksList.count() - info.track, info.startPos, xml);
+ m_document->renderer()->mltInsertClip(m_tracksList.count() - info.track, info.startPos, info.cropStart, xml);
m_document->renderer()->doRefresh();
}
clip = static_cast <ClipItem *>(list.at(i));
if (clip->clipProducer() == clipId) {
clip->refreshClip();
- m_document->renderer()->mltUpdateClip(m_tracksList.count() - clip->track(), clip->startPos(), clip->xml());
+ m_document->renderer()->mltUpdateClip(m_tracksList.count() - clip->track(), clip->startPos(), clip->cropStart(), clip->xml());
}
}
}
ItemInfo info;
info.startPos = clip->startPos() + offset;
info.endPos = clip->endPos() + offset;
+ info.cropStart = clip->cropStart();
info.track = clip->track() + trackOffset;
if (canBePastedTo(info, AVWIDGET)) {
new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), info, true, false, pasteClips);
copyright : (C) Marco Gittler
email : g.marco@freenet.de
copyright : (C) 2006 Jean-Baptiste Mardelle
- email : jb@ader.ch
+ email : jb@kdenlive.org
***************************************************************************/
refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
- m_connectTimer = new QTimer(this);
- connect(m_connectTimer, SIGNAL(timeout()), this, SLOT(connectPlaylist()));
-
if (rendererName == "project") m_monitorId = 10000;
else m_monitorId = 10001;
osdTimer = new QTimer(this);
void Render::closeMlt() {
- delete m_connectTimer;
delete osdTimer;
delete refreshTimer;
if (m_mltConsumer)
int Render::resetProfile(QString profile) {
+
+
if (!m_mltConsumer) return 0;
if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
- m_mltConsumer->set("refresh", 0);
m_mltConsumer->purge();
delete m_mltConsumer;
+
m_mltConsumer = NULL;
QString scene = sceneList();
if (m_mltProducer) delete m_mltProducer;
m_mltConsumer->set("audio_buffer", 1024);
m_mltConsumer->set("frequency", 48000);
+ kDebug() << "//RESET WITHSCENE: " << scene;
+ setSceneList(scene);
+
tmp = decodedString(scene);
Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", tmp);
delete[] tmp;
m_mltProducer = producer;
- m_mltConsumer->connect(*m_mltProducer);
- m_mltProducer->set_speed(0.0);
+ m_mltProducer->set_speed(0);
+ connectPlaylist();
//delete m_mltProfile;
// mlt_properties properties = MLT_CONSUMER_PROPERTIES(m_mltConsumer->get_consumer());
QMap < QString, QString > filePropertyMap;
QMap < QString, QString > metadataPropertyMap;
- QDomDocument doc;
- QDomElement westley = doc.createElement("westley");
- QDomElement play = doc.createElement("playlist");
- doc.appendChild(westley);
- westley.appendChild(play);
- play.appendChild(doc.importNode(xml, true));
- char *tmp = decodedString(doc.toString());
- Mlt::Producer producer(*m_mltProfile, "westley-xml", tmp);
- delete[] tmp;
+ KUrl url = KUrl(xml.attribute("resource", QString::null));
+
+ Mlt::Producer *producer;
- if (producer.is_blank()) {
- kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: " << doc.toString();
+ if (url.isEmpty()) {
+ QDomDocument doc;
+ QDomElement westley = doc.createElement("westley");
+ QDomElement play = doc.createElement("playlist");
+ doc.appendChild(westley);
+ westley.appendChild(play);
+ play.appendChild(doc.importNode(xml, true));
+ char *tmp = decodedString(doc.toString());
+ producer = new Mlt::Producer(*m_mltProfile, "westley-xml", tmp);
+ delete[] tmp;
+ } else {
+ char *tmp = decodedString(url.path());
+ producer = new Mlt::Producer(*m_mltProfile, tmp);
+ delete[] tmp;
+ }
+
+ if (producer->is_blank()) {
+ kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: ";
return;
}
int frameNumber = xml.attribute("thumbnail", "0").toInt();
- if (frameNumber != 0) producer.seek(frameNumber);
- mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer.get_producer());
+ if (frameNumber != 0) producer->seek(frameNumber);
+ mlt_properties properties = MLT_PRODUCER_PROPERTIES(producer->get_producer());
- KUrl url = xml.attribute("resource", QString::null);
filePropertyMap["filename"] = url.path();
- filePropertyMap["duration"] = QString::number(producer.get_playtime());
+ filePropertyMap["duration"] = QString::number(producer->get_playtime());
//kDebug() << "/////// PRODUCER: " << url.path() << " IS: " << producer.get_playtime();
- Mlt::Frame * frame = producer.get_frame();
- filePropertyMap["fps"] = producer.get("source_fps");
+ Mlt::Frame * frame = producer->get_frame();
+ filePropertyMap["fps"] = producer->get("source_fps");
if (frame && frame->is_valid()) {
filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + "x" + QString::number(frame->get_int("height"));
if (frame->get_int("test_image") == 0) {
if (url.path().endsWith(".westley") || url.path().endsWith(".kdenlive")) {
filePropertyMap["type"] = "playlist";
- metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get(MLT_SERVICE_PROPERTIES(producer.get_service()), "title"));
+ metadataPropertyMap["comment"] = QString::fromUtf8(mlt_properties_get(MLT_SERVICE_PROPERTIES(producer->get_service()), "title"));
} else if (frame->get_int("test_audio") == 0)
filePropertyMap["type"] = "av";
else
// Fetch the video_context
#if 1
+
AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data(properties, "video_context", NULL);
if (context != NULL) {
// Get the video_index
int index = mlt_properties_get_int(properties, "video_index");
+
#if ENABLE_FFMPEG_CODEC_DESCRIPTION
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name) {
filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->long_name;
} else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!";
context = (AVFormatContext *) mlt_properties_get_data(properties, "audio_context", NULL);
if (context != NULL) {
- // Get the video_index
+ // Get the audio_index
int index = mlt_properties_get_int(properties, "audio_index");
#if ENABLE_FFMPEG_CODEC_DESCRIPTION
emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
kDebug() << "REquested fuile info for: " << url.path();
if (frame) delete frame;
+ if (producer) delete producer;
}
/** Create the producer from the Westley QDomDocument */
if (m_mltConsumer) {
m_mltConsumer->stop();
- m_mltConsumer->set("refresh", 0);
+ //m_mltConsumer->set("refresh", 0);
} else return;
+
if (m_mltProducer) {
- m_mltProducer->set_speed(0.0);
+ m_mltProducer->set_speed(0);
//if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
delete m_mltProducer;
m_fps = m_mltProducer->get_fps();
kDebug() << "// NEW SCENE LIST DURATION SET TO: " << m_mltProducer->get_playtime();
- emit durationChanged(m_mltProducer->get_playtime());
- //m_connectTimer->start( 1000 );
connectPlaylist();
if (position != 0) {
m_mltProducer->seek(position);
void Render::connectPlaylist() {
if (!m_mltConsumer) return;
- m_connectTimer->stop();
- m_mltConsumer->set("refresh", "0");
+ //m_mltConsumer->set("refresh", "0");
m_mltConsumer->connect(*m_mltProducer);
- m_mltProducer->set_speed(0.0);
+ m_mltProducer->set_speed(0);
m_mltConsumer->start();
- refresh();
+ emit durationChanged(m_mltProducer->get_playtime());
+ //refresh();
/*
if (m_mltConsumer->start() == -1) {
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."));
void Render::refreshDisplay() {
if (!m_mltProducer) return;
- m_mltConsumer->set("refresh", 0);
+ //m_mltConsumer->set("refresh", 0);
mlt_properties properties = MLT_PRODUCER_PROPERTIES(m_mltProducer->get_producer());
/*if (KdenliveSettings::osdtimecode()) {
}
void Render::clear() {
+ kDebug() << " ********* RENDER CLEAR";
if (m_mltConsumer) {
- m_mltConsumer->set("refresh", 0);
+ //m_mltConsumer->set("refresh", 0);
if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
}
void Render::stop() {
if (m_mltConsumer && !m_mltConsumer->is_stopped()) {
kDebug() << "///////////// RENDER STOPPED: " << m_name;
- m_mltConsumer->set("refresh", 0);
+ //m_mltConsumer->set("refresh", 0);
m_mltConsumer->stop();
}
kDebug() << "///////////// RENDER STOP2-------";
}
void Render::stop(const GenTime & startTime) {
+
kDebug() << "///////////// RENDER STOP-------2";
if (m_mltProducer) {
m_mltProducer->set_speed(0.0);
void Render::switchPlay() {
if (!m_mltProducer)
return;
- if (m_mltProducer->get_speed() == 0.0) m_mltProducer->set_speed(1.0);
- else {
- m_isBlocked = true;
+ if (m_mltProducer->get_speed() == 0.0) {
+ m_isBlocked = false;
+ m_mltProducer->set_speed(1.0);
+ m_mltConsumer->set("refresh", 1);
+ kDebug() << " ********* RENDER PLAY: " << m_mltProducer->get_speed();
+ } else {
+ //m_isBlocked = true;
+ m_mltConsumer->set("refresh", 0);
m_mltProducer->set_speed(0.0);
- //m_mltConsumer->set("refresh", 0);
+ m_isBlocked = true;
m_mltProducer->seek((int) m_framePosition);
- m_isBlocked = false;
+ //kDebug()<<" ********* RENDER PAUSE: "<<m_mltProducer->get_speed();
+ //m_mltConsumer->set("refresh", 0);
+ /*mlt_position position = mlt_producer_position( m_mltProducer->get_producer() );
+ m_mltProducer->set_speed(0);
+ m_mltProducer->seek( position );
+ //m_mltProducer->seek((int) m_framePosition);
+ m_isBlocked = false;*/
}
/*if (speed == 0.0) {
m_mltProducer->seek((int) m_framePosition + 1);
m_mltConsumer->purge();
}*/
- refresh();
+ //refresh();
}
void Render::play(double speed) {
+ kDebug() << " ********* REDNER PLAY";
if (!m_mltProducer)
return;
// if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1);
void Render::sendSeekCommand(GenTime time) {
+ //kDebug()<<" ********* RENDER SEND SEEK";
if (!m_mltProducer)
return;
//kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
m_mltProducer->seek((int)(time.frames(m_fps)));
+ m_mltConsumer->set("refresh", 1);
refresh();
}
void Render::seekToFrame(int pos) {
+ //kDebug()<<" ********* RENDER SEEK TO POS";
if (!m_mltProducer)
return;
//kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
void Render::doRefresh() {
// Use a Timer so that we don't refresh too much
- refresh();
+ m_mltConsumer->set("refresh", 1);
}
void Render::refresh() {
black.setAttribute("in", "0");
black.setAttribute("out", "13999");
while (dur > 14000) {
- mltInsertClip(0, GenTime(i * 14000, m_fps), black);
+ mltInsertClip(0, GenTime(i * 14000, m_fps), GenTime(), black);
dur = dur - 14000;
i++;
}
if (dur > 0) {
black.setAttribute("out", QString::number(dur));
- mltInsertClip(0, GenTime(i * 14000, m_fps), black);
+ mltInsertClip(0, GenTime(i * 14000, m_fps), GenTime(), black);
}
m_mltProducer->set("out", duration);
emit durationChanged((int)duration);
}
}
-void Render::mltInsertClip(int track, GenTime position, QDomElement element) {
+void Render::mltInsertClip(int track, GenTime position, GenTime crop, QDomElement element) {
if (!m_mltProducer) {
kDebug() << "PLAYLIST NOT INITIALISED //////";
return;
QString resource = doc.toString();
char *tmp = decodedString(resource);
Mlt::Producer clip(*m_mltProfile, "westley-xml", tmp);
+ clip.set("in", crop.frames(m_fps));
//clip.set_in_and_out(in.frames(m_fps), out.frames(m_fps));
delete[] tmp;
trackPlaylist.insert_at((int) position.frames(m_fps), clip, 1);
m_isBlocked = false;
}
-void Render::mltUpdateClip(int track, GenTime position, QDomElement element) {
+void Render::mltUpdateClip(int track, GenTime position, GenTime crop, QDomElement element) {
// TODO: optimize
mltRemoveClip(track, position);
- mltInsertClip(track, position, element);
+ mltInsertClip(track, position, crop, element);
}
Mlt::Tractor tractor(service);
Mlt::Field *field = tractor.field();
- m_mltConsumer->set("refresh", 0);
+ //m_mltConsumer->set("refresh", 0);
mlt_service serv = m_mltProducer->parent().get_service();
mlt_service nextservice = mlt_service_get_producer(serv);