[vlmc-devel] Media: Add a method to create a subclip
Hugo Beauzée-Luyssen
git at videolan.org
Fri Aug 19 02:41:41 CEST 2016
vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Aug 19 00:47:38 2016 +0200| [4d917eac9324da83c05cfb3d0ad452a179e5727c] | committer: Hugo Beauzée-Luyssen
Media: Add a method to create a subclip
And use it from the PreviewWidget
> https://code.videolan.org/videolan/vlmc/commit/4d917eac9324da83c05cfb3d0ad452a179e5727c
---
src/Gui/preview/PreviewWidget.cpp | 4 +++-
src/Media/Media.cpp | 6 ++++++
src/Media/Media.h | 7 +++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/Gui/preview/PreviewWidget.cpp b/src/Gui/preview/PreviewWidget.cpp
index 7557933..c4dfb55 100644
--- a/src/Gui/preview/PreviewWidget.cpp
+++ b/src/Gui/preview/PreviewWidget.cpp
@@ -28,6 +28,7 @@
#include <memory>
#include "Media/Clip.h"
+#include "Media/Media.h"
#include "Renderer/ClipRenderer.h"
#include "Backend/MLT/MLTOutput.h"
#include "PreviewWidget.h"
@@ -240,6 +241,7 @@ PreviewWidget::createNewClipFromMarkers()
Clip* clip = clipRenderer->getClip();
if ( clip == nullptr )
return ;
+ auto media = clip->media();
qint64 beg = m_ui->rulerWidget->getMarker( PreviewRuler::Start );
qint64 end = m_ui->rulerWidget->getMarker( PreviewRuler::Stop );
@@ -250,7 +252,7 @@ PreviewWidget::createNewClipFromMarkers()
return ;
beg = beg < 0 ? 0 : beg;
- Clip* part = new Clip( clip, beg, end );
+ Clip* part = media->cut( beg, end );
//Adding the newly created clip to the media
if ( clip->addSubclip( part ) == false )
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index da8231d..e2e0990 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -116,6 +116,12 @@ Media::id() const
return m_mlMedia->id();
}
+Clip*
+Media::cut(qint64 begin, qint64 end)
+{
+ return new Clip( m_baseClip, begin, end );
+}
+
QVariant
Media::toVariant() const
{
diff --git a/src/Media/Media.h b/src/Media/Media.h
index d204fb7..0f72140 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -91,6 +91,13 @@ public:
Clip* baseClip() { return m_baseClip; }
const Clip* baseClip() const { return m_baseClip; }
+ /**
+ * @brief cut Creates a clip to represent a cut of a media
+ * @param begin The first frame of the cut
+ * @param end The last frame of the cut
+ * @return A new Clip, representing the media from [begin] to [end]
+ */
+ Clip* cut( qint64 begin, qint64 end );
QVariant toVariant() const;
More information about the Vlmc-devel
mailing list