From dafaf7597142fc94422fa465120ba2dee34e7c8e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 29 Jul 2008 23:46:59 +0000 Subject: [PATCH] Change clip speed (slowmotion) - not finished yet, saving does not work svn path=/branches/KDE4/; revision=2351 --- src/CMakeLists.txt | 1 + src/abstractclipitem.cpp | 4 ++ src/abstractclipitem.h | 1 + src/changespeedcommand.cpp | 42 ++++++++++++++++++++ src/changespeedcommand.h | 49 +++++++++++++++++++++++ src/clipitem.cpp | 13 ++++++- src/clipitem.h | 3 ++ src/clipproperties.cpp | 10 ++--- src/customtrackview.cpp | 38 ++++++++++++++++++ src/customtrackview.h | 2 + src/initeffects.cpp | 4 +- src/kdenlivedoc.cpp | 4 +- src/kdenliveui.rc | 1 + src/mainwindow.cpp | 11 ++++++ src/mainwindow.h | 1 + src/managecapturesdialog.cpp | 20 +++++----- src/projectlist.cpp | 8 ++-- src/renderer.cpp | 75 +++++++++++++++++++++++++++++++++--- src/renderer.h | 1 + src/resizeclipcommand.cpp | 3 +- src/resizeclipcommand.h | 2 +- 21 files changed, 261 insertions(+), 32 deletions(-) create mode 100644 src/changespeedcommand.cpp create mode 100644 src/changespeedcommand.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c1be6199..ede02c85 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,6 +123,7 @@ set(kdenlive_SRCS editkeyframecommand.cpp clipdurationdialog.cpp managecapturesdialog.cpp + changespeedcommand.cpp ) kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc ) diff --git a/src/abstractclipitem.cpp b/src/abstractclipitem.cpp index 96068254..2fce8d1d 100644 --- a/src/abstractclipitem.cpp +++ b/src/abstractclipitem.cpp @@ -173,6 +173,10 @@ GenTime AbstractClipItem::maxDuration() const { return m_maxDuration; } +void AbstractClipItem::setMaxDuration(const GenTime &max) { + m_maxDuration = max; +} + QPainterPath AbstractClipItem::upperRectPart(QRectF br) { QPainterPath roundRectPathUpper; double roundingY = 20; diff --git a/src/abstractclipitem.h b/src/abstractclipitem.h index 0e0765e9..cd38533a 100644 --- a/src/abstractclipitem.h +++ b/src/abstractclipitem.h @@ -51,6 +51,7 @@ public: virtual double fps() const; virtual GenTime maxDuration() const; virtual void setCropStart(GenTime pos); + virtual void setMaxDuration(const GenTime &max); protected: int m_track; diff --git a/src/changespeedcommand.cpp b/src/changespeedcommand.cpp new file mode 100644 index 00000000..154b96d1 --- /dev/null +++ b/src/changespeedcommand.cpp @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include + +#include "changespeedcommand.h" +#include "customtrackview.h" + +ChangeSpeedCommand::ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, double old_speed, double new_speed, int clipId, bool doIt, QUndoCommand * parent) : QUndoCommand(parent), m_view(view), m_clipInfo(info), m_old_speed(old_speed), m_new_speed(new_speed), m_clipId(clipId), m_doIt(doIt) { + setText(i18n("Adjust clip length")); +} + + +// virtual +void ChangeSpeedCommand::undo() { + m_view->doChangeClipSpeed(m_clipInfo, m_old_speed, m_clipId); +} +// virtual +void ChangeSpeedCommand::redo() { + if (m_doIt) { + m_view->doChangeClipSpeed(m_clipInfo, m_new_speed, m_clipId); + } + m_doIt = true; +} + +#include "changespeedcommand.moc" diff --git a/src/changespeedcommand.h b/src/changespeedcommand.h new file mode 100644 index 00000000..c360716f --- /dev/null +++ b/src/changespeedcommand.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef CHANGESPEEDCOMMAND_H +#define CHANGESPEEDCOMMAND_H + +#include +#include +#include + +#include "gentime.h" +#include "definitions.h" + +class CustomTrackView; + +class ChangeSpeedCommand : public QUndoCommand { +public: + ChangeSpeedCommand(CustomTrackView *view, ItemInfo info, double old_speed, double new_speed, int clipId, bool doIt, QUndoCommand * parent = 0); + virtual void undo(); + virtual void redo(); + +private: + CustomTrackView *m_view; + ItemInfo m_clipInfo; + int m_clipId; + bool m_doIt; + double m_old_speed; + double m_new_speed; +}; + +#endif + diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 0ab0e10e..8235ff55 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -40,7 +40,7 @@ #include "kthumb.h" ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps) - : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_effectsCounter(1), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_thumbsRequested(0), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1) { + : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_effectsCounter(1), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_thumbsRequested(0), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1), m_speed(1.0) { QRectF rect((double) info.startPos.frames(fps) * scale, (double)(info.track * KdenliveSettings::trackheight() + 1), (double)(info.endPos - info.startPos).frames(fps) * scale, (double)(KdenliveSettings::trackheight() - 1)); setRect(rect); @@ -972,6 +972,17 @@ void ClipItem::deleteEffect(QString index) { flashClip(); } +double ClipItem::speed() const { + return m_speed; +} + +void ClipItem::setSpeed(const double speed) { + m_speed = speed; + if (m_speed == 1.0) m_clipName = baseClip()->name(); + else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + "%"; + update(); +} + //virtual void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event) { QString effects = QString(event->mimeData()->data("kdenlive/effectslist")); diff --git a/src/clipitem.h b/src/clipitem.h index f05c866a..dc5b3b75 100644 --- a/src/clipitem.h +++ b/src/clipitem.h @@ -91,6 +91,8 @@ public: QString keyframes(const int index); void setKeyframes(const int ix, const QString keyframes); void setEffectList(const EffectsList effectList); + void setSpeed(const double speed); + double speed() const; protected: //virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event); @@ -128,6 +130,7 @@ private: QTimeLine *m_timeLine; uint m_thumbsRequested; bool m_hover; + double m_speed; EffectsList m_effectList; QList m_transitionsList; diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index 784f0e2e..1111277e 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -100,16 +100,16 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg profilePath += "/lumas/PAL/"; QDir dir(profilePath); - QStringList filter; - filter << "*.pgm"; + QStringList filter; + filter << "*.pgm"; const QStringList result = dir.entryList(filter, QDir::Files); QStringList imagefiles; QStringList imagenamelist; int current; foreach(const QString file, result) { - m_view.luma_file->addItem(KIcon(profilePath + file), file, profilePath + file); - if (!lumaFile.isEmpty() && lumaFile == QString(profilePath + file)) - current = m_view.luma_file->count() - 1; + m_view.luma_file->addItem(KIcon(profilePath + file), file, profilePath + file); + if (!lumaFile.isEmpty() && lumaFile == QString(profilePath + file)) + current = m_view.luma_file->count() - 1; } if (!lumaFile.isEmpty()) { diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index cff74840..1fe7b944 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -46,6 +46,7 @@ #include "addtransitioncommand.h" #include "edittransitioncommand.h" #include "editkeyframecommand.h" +#include "changespeedcommand.h" #include "addmarkercommand.h" #include "razorclipcommand.h" #include "kdenlivesettings.h" @@ -1279,6 +1280,43 @@ void CustomTrackView::deleteSelectedClips() { m_commandStack->push(deleteSelected); } +void CustomTrackView::changeClipSpeed() { + QList itemList = scene()->selectedItems(); + if (itemList.count() == 0) { + emit displayMessage(i18n("Select clip to change speed"), ErrorMessage); + return; + } + QUndoCommand *changeSelected = new QUndoCommand(); + changeSelected->setText("Edit clip speed"); + for (int i = 0; i < itemList.count(); i++) { + if (itemList.at(i)->type() == AVWIDGET) { + ClipItem *item = static_cast (itemList.at(i)); + ItemInfo info = item->info(); + int percent = QInputDialog::getInteger(this, i18n("Edit Clip Speed"), i18n("New speed (percents)"), 100, 1, 300); + double speed = (double) percent / 100.0; + new ChangeSpeedCommand(this, info, item->speed(), speed, item->clipProducer(), true, changeSelected); + } + } + m_commandStack->push(changeSelected); +} + +void CustomTrackView::doChangeClipSpeed(ItemInfo info, double speed, int id) { + DocClipBase *baseclip = m_document->clipManager()->getClipById(id); + ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()) + 1, info.track); + info.track = m_tracksList.count() - item->track(); + int newLength = m_document->renderer()->mltChangeClipSpeed(info, speed, baseclip->producer()); + GenTime maxDuration(newLength, m_document->fps()); + item->setMaxDuration(maxDuration); + item->setSpeed(speed); + if (maxDuration < item->duration()) { + info = item->info(); + ItemInfo endInfo = info; + endInfo.endPos = info.startPos + maxDuration; + ResizeClipCommand *command = new ResizeClipCommand(this, info, endInfo, true); + m_commandStack->push(command); + } +} + void CustomTrackView::cutSelectedClips() { QList itemList = scene()->selectedItems(); GenTime currentPos = GenTime(m_cursorPos, m_document->fps()); diff --git a/src/customtrackview.h b/src/customtrackview.h index ebb95d3c..9f75435a 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -92,6 +92,8 @@ public: void clearSearchStrings(); void clipStart(); void clipEnd(); + void changeClipSpeed(); + void doChangeClipSpeed(ItemInfo info, double speed, int id); public slots: void setCursorPos(int pos, bool seek = true); diff --git a/src/initeffects.cpp b/src/initeffects.cpp index 030a2472..d4cb8810 100644 --- a/src/initeffects.cpp +++ b/src/initeffects.cpp @@ -118,8 +118,8 @@ Mlt::Repository *initEffects::parseEffectFiles() { QDir directory; for (more = direc.begin() ; more != direc.end() ; ++more) { directory = QDir(*more); - QStringList filter; - filter << "*.xml"; + QStringList filter; + filter << "*.xml"; fileList = directory.entryList(filter, QDir::Files); for (it = fileList.begin() ; it != fileList.end() ; ++it) { itemName = KUrl(*more + *it).path(); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index e08946c7..fdc5745e 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -53,7 +53,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoPro QDomElement infoXml = infoXmlNode.toElement(); QString profilePath = infoXml.attribute("profile"); m_startPos = infoXml.attribute("position").toInt(); - m_zoom = infoXml.attribute("zoom").toInt(); + m_zoom = infoXml.attribute("zoom", "4").toInt(); if (!profilePath.isEmpty()) setProfilePath(profilePath); double version = infoXml.attribute("version").toDouble(); if (version < 0.7) convertDocument(version); @@ -256,6 +256,8 @@ void KdenliveDoc::convertDocument(double version) { QDomNode multitrack = m_document.elementsByTagName("multitrack").at(0); QDomNodeList playlists = m_document.elementsByTagName("playlist"); + m_startPos = kdenlivedoc.toElement().attribute("timeline_position").toInt(); + QDomNode props = m_document.elementsByTagName("properties").at(0).toElement(); QString profile = props.toElement().attribute("videoprofile"); if (profile == "dv_wide") profile = "dv_pal_wide"; diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index 8da6a110..221798d2 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -26,6 +26,7 @@ Timeline + Markers diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4c642a7e..e199bf45 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -244,6 +244,7 @@ MainWindow::MainWindow(QWidget *parent) m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste))); m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip")); + m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed")); m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip")); m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy))); m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects")); @@ -627,6 +628,10 @@ void MainWindow::setupActions() { actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip); connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip())); + KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this); + actionCollection()->addAction("change_clip_speed", editTimelineClipSpeed); + connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed())); + KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this); cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R); actionCollection()->addAction("cut_timeline_clip", cutTimelineClip); @@ -1170,6 +1175,12 @@ void MainWindow::slotDeleteTimelineClip() { } } +void MainWindow::slotChangeClipSpeed() { + if (m_activeTimeline) { + m_activeTimeline->projectView()->changeClipSpeed(); + } +} + void MainWindow::slotAddClipMarker() { if (m_activeTimeline) { m_activeTimeline->projectView()->slotAddClipMarker(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 0ab4b46d..b4dc7477 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -231,6 +231,7 @@ private slots: void slotPaste(); void slotPasteEffects(); void slotReloadEffects(); + void slotChangeClipSpeed(); }; diff --git a/src/managecapturesdialog.cpp b/src/managecapturesdialog.cpp index 8651abfc..9c963d17 100644 --- a/src/managecapturesdialog.cpp +++ b/src/managecapturesdialog.cpp @@ -68,16 +68,16 @@ void ManageCapturesDialog::slotCheckItemIcon() { int ct = 0; int count = m_view.treeWidget->topLevelItemCount(); while (ct < count) { - QTreeWidgetItem *item = m_view.treeWidget->topLevelItem(ct); - //QTreeWidgetItem *item = m_view.treeWidget->currentItem(); - if (item->icon(0).isNull()) { - QPixmap p = KThumb::getImage(KUrl(item->data(0, Qt::UserRole).toString()), 0, 70, 50); - item->setIcon(0, QIcon(p)); - m_view.treeWidget->resizeColumnToContents(0); - repaint(); - //QTimer::singleShot(400, this, SLOT(slotCheckItemIcon())); - } - ct++; + QTreeWidgetItem *item = m_view.treeWidget->topLevelItem(ct); + //QTreeWidgetItem *item = m_view.treeWidget->currentItem(); + if (item->icon(0).isNull()) { + QPixmap p = KThumb::getImage(KUrl(item->data(0, Qt::UserRole).toString()), 0, 70, 50); + item->setIcon(0, QIcon(p)); + m_view.treeWidget->resizeColumnToContents(0); + repaint(); + //QTimer::singleShot(400, this, SLOT(slotCheckItemIcon())); + } + ct++; } m_view.treeWidget->setEnabled(true); } diff --git a/src/projectlist.cpp b/src/projectlist.cpp index e9327b44..b8f9c76d 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -325,8 +325,8 @@ void ProjectList::slotAddClip(QUrl givenUrl, QString group) { } } foreach(const KUrl file, list) { - if (KIO::NetAccess::exists(file, KIO::NetAccess::SourceSide, NULL)) - m_doc->slotAddClipFile(file, group, groupId); + if (KIO::NetAccess::exists(file, KIO::NetAccess::SourceSide, NULL)) + m_doc->slotAddClipFile(file, group, groupId); } } @@ -334,8 +334,8 @@ void ProjectList::slotRemoveInvalidClip(int id) { ProjectItem *item = getItemById(id); if (item) { QString path = item->referencedClip()->fileURL().path(); - if (!path.isEmpty()) KMessageBox::sorry(this, i18n("Clip %1
is invalid, will be removed from project.", path)); - + if (!path.isEmpty()) KMessageBox::sorry(this, i18n("Clip %1
is invalid, will be removed from project.", path)); + } QList ids; ids << id; diff --git a/src/renderer.cpp b/src/renderer.cpp index 4f8f5234..19ec0e18 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -91,7 +91,7 @@ Render::Render(const QString & rendererName, int winid, int extid, QWidget *pare m_mltProducer = producer; if (m_blackClip) delete m_blackClip; m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black"); - m_blackClip->set("id", "black"); + m_blackClip->set("id", "black"); m_mltConsumer->connect(*m_mltProducer); m_mltProducer->set_speed(0.0); @@ -248,11 +248,11 @@ QPixmap Render::getImageThumbnail(KUrl url, int width, int height) { QStringList::Iterator it; QDir dir(url.directory()); - QStringList filter; - filter << "*." + fileType; - filter << "*." + fileType.toUpper(); + QStringList filter; + filter << "*." + fileType; + filter << "*." + fileType.toUpper(); more = dir.entryList(filter, QDir::Files); - im.load(url.directory() + "/" + more.at(0)); + im.load(url.directory() + "/" + more.at(0)); } else im.load(url.path()); //pixmap = im.scaled(width, height); return pixmap; @@ -475,7 +475,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) { if (producer->is_blank()) { kDebug() << " / / / / / / / /ERRROR / / / / // CANNOT LOAD PRODUCER: "; - emit removeInvalidClip(clipId); + emit removeInvalidClip(clipId); return; } producer->set("id", clipId); @@ -1268,6 +1268,69 @@ void Render::mltRemoveClip(int track, GenTime position) { m_isBlocked = false; } +int Render::mltChangeClipSpeed(ItemInfo info, double speed, Mlt::Producer *prod) { + m_isBlocked = true; + int newLength = 0; + Mlt::Service service(m_mltProducer->parent().get_service()); + if (service.type() != tractor_type) kWarning() << "// TRACTOR PROBLEM"; + + Mlt::Tractor tractor(service); + Mlt::Producer trackProducer(tractor.track(info.track)); + Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); + int clipIndex = trackPlaylist.get_clip_index_at((int) info.startPos.frames(m_fps)); + Mlt::Producer clip(trackPlaylist.get_clip(clipIndex)); + QString serv = clip.parent().get("mlt_service"); + QString id = clip.parent().get("id"); + kDebug() << "CLIP SERVICE: " << clip.parent().get("mlt_service"); + if (serv == "avformat" && speed != 1.0) { + mlt_service_lock(service.get_service()); + QString url = clip.parent().get("resource"); + url.append(":" + QString::number(speed)); + char *tmp = decodedString(url); + Mlt::Producer *slow = new Mlt::Producer(*m_mltProfile, "framebuffer", tmp); + delete[] tmp; + tmp = decodedString(id); + slow->set("id", tmp); + delete[] tmp; + slow->set_in_and_out(info.cropStart.frames(m_fps), (info.endPos - info.startPos).frames(m_fps)); + newLength = slow->get_length(); + trackPlaylist.replace_with_blank(clipIndex); + trackPlaylist.consolidate_blanks(0); + trackPlaylist.insert_at((int) info.startPos.frames(m_fps), *slow, 1); + mlt_service_unlock(service.get_service()); + kDebug() << "AVFORMAT CLIP!!!:"; + } else if (speed == 1.0) { + mlt_service_lock(service.get_service()); + Mlt::Producer *cut = prod->cut(info.cropStart.frames(m_fps), (info.endPos - info.startPos).frames(m_fps) - 1); + trackPlaylist.replace_with_blank(clipIndex); + newLength = cut->get_length(); + trackPlaylist.consolidate_blanks(0); + trackPlaylist.insert_at((int) info.startPos.frames(m_fps), *cut, 1); + mlt_service_unlock(service.get_service()); + } else if (serv == "framebuffer") { + mlt_service_lock(service.get_service()); + QString url = clip.parent().get("resource"); + url = url.section(":", 0, -1); + url.append(":" + QString::number(speed)); + char *tmp = decodedString(url); + Mlt::Producer *slow = new Mlt::Producer(*m_mltProfile, "framebuffer", tmp); + delete[] tmp; + tmp = decodedString(id); + slow->set("id", tmp); + delete[] tmp; + slow->set_in_and_out(info.cropStart.frames(m_fps), (info.endPos - info.startPos).frames(m_fps)); + newLength = slow->get_length(); + trackPlaylist.replace_with_blank(clipIndex); + trackPlaylist.consolidate_blanks(0); + trackPlaylist.insert_at((int) info.startPos.frames(m_fps), *slow, 1); + mlt_service_unlock(service.get_service()); + kDebug() << "AVFORMAT CLIP!!!:"; + } + + m_isBlocked = false; + return newLength; +} + bool Render::mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh) { Mlt::Service service(m_mltProducer->parent().get_service()); diff --git a/src/renderer.h b/src/renderer.h index 187b050a..e9311ebf 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -170,6 +170,7 @@ Q_OBJECT public: void mltMoveTransparency(int startTime, int endTime, int startTrack, int endTrack, int id); void mltDeleteTransparency(int pos, int track, int id); void mltResizeTransparency(int oldStart, int newStart, int newEnd, int track, int id); + int mltChangeClipSpeed(ItemInfo info, double speed, Mlt::Producer *prod); private: // Private attributes & methods /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */ diff --git a/src/resizeclipcommand.cpp b/src/resizeclipcommand.cpp index 721544dc..75e09d0c 100644 --- a/src/resizeclipcommand.cpp +++ b/src/resizeclipcommand.cpp @@ -22,8 +22,7 @@ #include "resizeclipcommand.h" #include "customtrackview.h" -ResizeClipCommand::ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt) - : m_view(view), m_startPos(start), m_endPos(end), m_doIt(doIt) { +ResizeClipCommand::ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, QUndoCommand * parent) : QUndoCommand(parent), m_view(view), m_startPos(start), m_endPos(end), m_doIt(doIt) { setText(i18n("Resize clip")); } diff --git a/src/resizeclipcommand.h b/src/resizeclipcommand.h index 1b527b46..8aafadc2 100644 --- a/src/resizeclipcommand.h +++ b/src/resizeclipcommand.h @@ -33,7 +33,7 @@ class CustomTrackView; class ResizeClipCommand : public QUndoCommand { public: - ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt); + ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, QUndoCommand * parent = 0); virtual void undo(); virtual void redo(); -- 2.39.2