Commit ba9beda2 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

VLMC can now render a project file from command line interface.

parent f3a034bf
......@@ -120,7 +120,8 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_D
#Add GUI stuff if required
IF (NOT WITH_GUI)
LIST (APPEND VLMC_SRCS Main/main.cpp )
LIST (APPEND VLMC_SRCS Main/main.cpp Renderer/ConsoleRenderer.cpp )
LIST (APPEND VLMC_HDRS Renderer/ConsoleRenderer.h)
QT4_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC})
QT4_WRAP_CPP(VLMC_MOC_SRCS ${VLMC_HDRS})
ADD_EXECUTABLE(vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_RCC_SRCS})
......
......@@ -37,6 +37,7 @@
#include "VlmcDebug.h"
#include "MainWorkflow.h"
#include "export/RendererSettings.h"
#include "WorkflowFileRenderer.h"
#include "WorkflowRenderer.h"
#include "ClipRenderer.h"
......@@ -439,8 +440,22 @@ void MainWindow::on_actionRender_triggered()
if ( m_fileRenderer )
delete m_fileRenderer;
m_fileRenderer = new WorkflowFileRenderer();
//Setup dialog box for querying render parameters.
RendererSettings *settings = new RendererSettings;
if ( settings->exec() == QDialog::Rejected )
{
delete settings;
return ;
}
QString outputFileName = settings->outputFileName();
quint32 width = settings->width();
quint32 height = settings->height();
double fps = settings->fps();
quint32 vbitrate = settings->videoBitrate();
quint32 abitrate = settings->audioBitrate();
delete settings;
m_fileRenderer->initializeRenderer();
m_fileRenderer->run();
m_fileRenderer->run( outputFileName, width, height, fps, vbitrate, abitrate );
}
}
......
......@@ -21,10 +21,14 @@
*****************************************************************************/
#include "config.h"
#include "ConsoleRenderer.h"
#include "ProjectManager.h"
#include "WorkflowFileRenderer.h"
#include <QCoreApplication>
#include <QtDebug>
#include <QMetaType>
#include <QVariant>
/**
* VLMC Entry point
......@@ -42,12 +46,20 @@ VLMCmain( int argc, char **argv )
app.setOrganizationDomain( "vlmc.org" );
app.setApplicationVersion( PROJECT_VERSION );
if ( argc < 2 )
qRegisterMetaType<MainWorkflow::TrackType>( "MainWorkflow::TrackType" );
qRegisterMetaType<MainWorkflow::FrameChangedReason>( "MainWorkflow::FrameChangedReason" );
qRegisterMetaType<QVariant>( "QVariant" );
if ( argc < 3 )
{
qCritical() << "You must provide a project file to render.";
qCritical() << "Usage: ./vlmc project.vlmc output_file";
return 1;
}
ProjectManager::getInstance()->loadProject( argv[1] );
ProjectManager *pm = ProjectManager::getInstance();
ConsoleRenderer renderer;
QCoreApplication::connect( pm, SIGNAL( projectLoaded() ), &renderer, SLOT( startRender() ) );
pm->loadProject( argv[1] );
return app.exec();
}
......@@ -114,8 +114,9 @@ void ProjectManager::loadTimeline()
QDomElement root = m_domDocument->documentElement();
MainWorkflow::getInstance()->loadProject( root );
emit projectUpdated( projectName(), true );
SettingsManager::getInstance()->load( root );
emit projectUpdated( projectName(), true );
emit projectLoaded();
delete m_domDocument;
}
......
......@@ -104,6 +104,7 @@ signals:
*/
void projectSaved();
void projectClosed();
void projectLoaded();
};
#endif // PROJECTMANAGER_H
/*****************************************************************************
* ConsoleRenderer.h: Handle the "server" mode rendering
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.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 "ConsoleRenderer.h"
#include "WorkflowFileRenderer.h"
#include "SettingsManager.h"
#include <QCoreApplication>
#include <QStringList>
ConsoleRenderer::ConsoleRenderer(QObject *parent) :
QObject(parent)
{
m_renderer = new WorkflowFileRenderer;
m_renderer->initializeRenderer();
m_outputFileName = qApp->arguments()[2];
m_width = VLMC_PROJECT_GET_UINT( "video/VideoProjectWidth" );
m_height = VLMC_PROJECT_GET_UINT( "video/VideoProjectHeight" );
m_fps = VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" );
m_vbitrate = 4000;
m_abitrate = 256;
}
void
ConsoleRenderer::startRender()
{
m_renderer->run( m_outputFileName, m_width, m_height, m_fps, m_vbitrate, m_abitrate );
}
/*****************************************************************************
* ConsoleRenderer.h: Handle the "server" mode rendering
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.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 CONSOLERENDERER_H
#define CONSOLERENDERER_H
class WorkflowFileRenderer;
#include <QObject>
#include <QString>
class ConsoleRenderer : public QObject
{
Q_OBJECT
public:
explicit ConsoleRenderer( QObject *parent = 0 );
public slots:
void startRender();
private:
WorkflowFileRenderer *m_renderer;
QString m_outputFileName;
quint32 m_width;
quint32 m_height;
double m_fps;
quint32 m_vbitrate;
quint32 m_abitrate;
};
#endif // CONSOLERENDERER_H
......@@ -26,9 +26,6 @@
#include "VLCMedia.h"
#include "LightVideoFrame.h"
#include "VLCMediaPlayer.h"
#ifdef WITH_GUI
# include "export/RendererSettings.h"
#endif
#include <QTime>
......@@ -45,34 +42,15 @@ WorkflowFileRenderer::~WorkflowFileRenderer()
}
#endif
void WorkflowFileRenderer::run()
void WorkflowFileRenderer::run( const QString& outputFileName, quint32 width,
quint32 height, double fps, quint32 vbitrate,
quint32 abitrate )
{
// char buffer[256];
m_outputFileName = outputFileName;
m_mainWorkflow->setCurrentFrame( 0, MainWorkflow::Renderer );
#ifdef WITH_GUI
//Setup dialog box for querying render parameters.
RendererSettings *settings = new RendererSettings;
if ( settings->exec() == QDialog::Rejected )
{
delete settings;
return ;
}
m_outputFileName = settings->outputFileName();
quint32 width = settings->width();
quint32 height = settings->height();
double fps = settings->fps();
quint32 vbitrate = settings->videoBitrate();
quint32 abitrate = settings->audioBitrate();
delete settings;
#else
quint32 width = VLMC_PROJECT_GET_UINT( "video/VideoProjectWidth" );
quint32 height = VLMC_PROJECT_GET_UINT( "video/VideoProjectHeight" );
double fps = VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" );
quint32 vbitrate = 4000;
quint32 abitrate = 400;
#endif
setupRenderer( width, height, fps );
#ifdef WITH_GUI
setupDialog( width, height );
......@@ -155,6 +133,16 @@ WorkflowFileRenderer::__frameChanged( qint64 frame, MainWorkflow::FrameChangedRe
{
#ifdef WITH_GUI
m_dialog->setProgressBarValue( frame * 100 / m_mainWorkflow->getLengthFrame() );
#else
static int percent = 0;
int newPercent;
newPercent = frame * 100 / m_mainWorkflow->getLengthFrame();
if ( newPercent != percent )
{
percent = newPercent;
qDebug() << percent << "%";
}
#endif
}
......@@ -173,13 +161,13 @@ WorkflowFileRenderer::getUnlockCallback()
quint32
WorkflowFileRenderer::width() const
{
return VLMC_GET_UINT( "video/VideoProjectWidth" );
return VLMC_PROJECT_GET_UINT( "video/VideoProjectWidth" );
}
quint32
WorkflowFileRenderer::height() const
{
return VLMC_GET_UINT( "video/VideoProjectHeight" );
return VLMC_PROJECT_GET_UINT( "video/VideoProjectHeight" );
}
#ifdef WITH_GUI
......
......@@ -35,7 +35,6 @@
class WorkflowFileRenderer : public WorkflowRenderer
{
Q_OBJECT
Q_DISABLE_COPY( WorkflowFileRenderer )
public:
#ifdef WITH_GUI
......@@ -43,15 +42,18 @@ public:
virtual ~WorkflowFileRenderer();
#endif
static int lock( void* datas, qint64 *dts, qint64 *pts, quint32 *flags,
size_t *bufferSize, void **buffer );
static void unlock( void* datas, size_t size, void* buff );
void run(const QString& outputFileName, quint32 width,
quint32 height, double fps, quint32 vbitrate,
quint32 abitrate);
void run();
virtual float getFps() const;
static int lock( void* datas, qint64 *dts, qint64 *pts,
quint32 *flags, size_t *bufferSize, void **buffer );
static void unlock( void* datas, size_t size, void* buff );
virtual float getFps() const;
private:
void setupDialog( quint32 width, quint32 height );
void setupDialog( quint32 width, quint32 height );
private:
QString m_outputFileName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment