[vlmc-devel] WorkflowRenderer: Have a feature to render the project to files.

Yikai Lu git at videolan.org
Wed Apr 6 14:39:50 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Apr  6 20:59:02 2016 +0900| [71524671d765d82ca187f497dec808082c33b2f6] | committer: Hugo Beauzée-Luyssen

WorkflowRenderer: Have a feature to render the project to files.

Which kills usage of WorkflowFilRenderer

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> https://code.videolan.org/videolan/vlmc/commit/71524671d765d82ca187f497dec808082c33b2f6
---

 src/Renderer/WorkflowRenderer.cpp | 48 ++++++++++++++++++++++++++++++++-------
 src/Renderer/WorkflowRenderer.h   | 13 +++++++++++
 2 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index f50838a..b8d7ed3 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -151,6 +151,17 @@ WorkflowRenderer::lockVideo( void* data, int64_t *pts, size_t *bufferSize, const
     else
         *buffer = ret->buffer();
     *bufferSize = ret->size();
+
+#ifdef WITH_GUI
+    auto self = handler->self;
+    if ( self->m_time.isValid() == false ||
+         self->m_time.elapsed() >= 1000 )
+    {
+        emit self->imageUpdated( (quint8*)( *buffer ) );
+        self->m_time.restart();
+    }
+#endif
+
     vlmcDebug() << __func__ << "Rendered frame. pts:" << m_pts;
     return 0;
 }
@@ -202,6 +213,34 @@ WorkflowRenderer::unlock( void *data, const char*, size_t, void* )
 }
 
 void
+WorkflowRenderer::start()
+{
+    m_isRendering = true;
+    m_paused = false;
+    m_stopping = false;
+    m_pts = 0;
+    m_audioPts = 0;
+    m_mainWorkflow->startRender( m_width, m_height );
+    m_sourceRenderer->start();
+}
+
+void
+WorkflowRenderer::startRenderToFile( const QString& outputFileName, quint32 width, quint32 height,
+                                     double fps, const QString& ar,
+                                     quint32 vbitrate, quint32 abitrate )
+{
+    initFilters();
+    setupRenderer( width, height, fps, ar );
+    m_sourceRenderer->setOutputFile( qPrintable( outputFileName ) );
+    m_sourceRenderer->setOutputAudioBitrate( abitrate );
+    m_sourceRenderer->setOutputVideoBitrate( vbitrate );
+    connect( m_mainWorkflow, &MainWorkflow::mainWorkflowEndReached, this, &WorkflowRenderer::renderComplete );
+    connect( m_mainWorkflow, &MainWorkflow::mainWorkflowEndReached, this, &WorkflowRenderer::stop );
+    m_mainWorkflow->setFullSpeedRender( true );
+    start();
+}
+
+void
 WorkflowRenderer::startPreview()
 {
     if ( m_mainWorkflow->getLengthFrame() <= 0 )
@@ -215,15 +254,8 @@ WorkflowRenderer::startPreview()
 
     initFilters();
     setupRenderer( m_width, m_height, m_outputFps, m_aspectRatio );
-
     m_mainWorkflow->setFullSpeedRender( false );
-    m_mainWorkflow->startRender( m_width, m_height );
-    m_isRendering = true;
-    m_paused = false;
-    m_stopping = false;
-    m_pts = 0;
-    m_audioPts = 0;
-    m_sourceRenderer->start();
+    start();
 }
 
 void
diff --git a/src/Renderer/WorkflowRenderer.h b/src/Renderer/WorkflowRenderer.h
index 89aace6..d38f359 100644
--- a/src/Renderer/WorkflowRenderer.h
+++ b/src/Renderer/WorkflowRenderer.h
@@ -29,6 +29,7 @@
 #include "Workflow/MainWorkflow.h"
 
 #include <QObject>
+#include <QTime>
 
 namespace Backend
 {
@@ -132,7 +133,12 @@ class   WorkflowRenderer : public GenericRenderer, public ILoadSave
          */
         virtual float       getFps() const;
 
+        void                startRenderToFile( const QString& outputFileName, quint32 width, quint32 height,
+                                               double fps, const QString& ar,
+                                               quint32 vbitrate, quint32 abitrate );
+
     private:
+        void                start();
         /**
          *  \brief          This is a subpart of the togglePlayPause( bool ) method
          *
@@ -249,6 +255,9 @@ class   WorkflowRenderer : public GenericRenderer, public ILoadSave
         static const quint8     VideoCookie = '0';
         static const quint8     AudioCookie = '1';
 
+        // For Preview
+        QTime                       m_time;
+
     public slots:
         /**
          *  \brief          The current frame just changed because of the timeline cursor
@@ -271,6 +280,10 @@ class   WorkflowRenderer : public GenericRenderer, public ILoadSave
          *  If the length comes to a 0 value again, the permanent playback will be stoped.
          */
         void                mainWorkflowLenghtChanged( qint64 newLength );
+
+    signals:
+        void                        imageUpdated( const uchar* image );
+        void                        renderComplete();
 };
 
 #endif // WORKFLOWRENDERER_H



More information about the Vlmc-devel mailing list