Commit d206a395 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Fix VLC's Sout configuration

parent b284fcb9
......@@ -27,6 +27,7 @@
#include "Workflow/Types.h"
#include <QMutexLocker>
#include <QStringBuilder>
AudioClipWorkflow::AudioClipWorkflow( ClipHelper *ch ) :
ClipWorkflow( ch ),
......@@ -112,25 +113,29 @@ AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode, qint64 )
return buff;
}
void
AudioClipWorkflow::initVlcOutput()
QString
AudioClipWorkflow::createSoutChain() const
{
preallocate();
m_vlcMedia->addOption( ":no-sout-video" );
m_vlcMedia->addOption( ":no-video" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
m_vlcMedia->setAudioDataCtx( this );
m_vlcMedia->setAudioLockCallback( reinterpret_cast<void*>( getLockCallback() ) );
m_vlcMedia->setAudioUnlockCallback( reinterpret_cast<void*>( getUnlockCallback() ) );
m_vlcMedia->addOption( ":sout-transcode-acodec=f32l" );
m_vlcMedia->addOption( ":sout-transcode-samplerate=48000" );
m_vlcMedia->addOption( ":sout-transcode-channels=2" );
m_vlcMedia->addOption( ":no-sout-transcode-hurry-up" );
m_vlcMedia->addOption( ":sout-transcode-audio-sync");
QString chain = ":sout=#transcode{acodec=f32l,"
"samplerate=48000,channels=2,no-hurry-up}:smem{";
if ( m_fullSpeedRender == false )
m_vlcMedia->addOption( ":sout-smem-time-sync" );
chain += "time-sync";
else
m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
chain += "no-time-sync";
chain += ",audio-data=" % QString::number( reinterpret_cast<intptr_t>( this ) )
% ",audio-prerender-callback="
% QString::number( reinterpret_cast<intptr_t>( getLockCallback() ) )
% ",audio-postrender-callback="
% QString::number( reinterpret_cast<intptr_t>( getUnlockCallback() ) )
% '}';
return chain;
}
void AudioClipWorkflow::initializeVlcOutput()
{
preallocate();
m_vlcMedia->addOption(":no-sout-video");
m_vlcMedia->addOption(":no-video");
}
Workflow::AudioSample*
......
......@@ -51,7 +51,8 @@ class AudioClipWorkflow : public ClipWorkflow
virtual void releasePrealocated();
private:
void initVlcOutput();
virtual QString createSoutChain() const;
virtual void initializeVlcOutput();
Workflow::AudioSample* createBuffer( size_t size );
void insertPastBlock( Workflow::AudioSample* as );
static void lock( AudioClipWorkflow* clipWorkflow,
......
......@@ -62,12 +62,14 @@ ClipWorkflow::initialize()
setState( ClipWorkflow::Initializing );
m_vlcMedia = new LibVLCpp::Media( m_clipHelper->clip()->getMedia()->mrl() );
initializeVlcOutput();
m_vlcMedia->addOption( createSoutChain() );
m_mediaPlayer = MemoryPool<LibVLCpp::MediaPlayer>::getInstance()->get();
m_mediaPlayer->setMedia( m_vlcMedia );
m_currentPts = -1;
m_previousPts = -1;
m_pauseDuration = -1;
initVlcOutput();
m_mediaPlayer = MemoryPool<LibVLCpp::MediaPlayer>::getInstance()->get();
m_mediaPlayer->setMedia( m_vlcMedia );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( loadingComplete() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ), Qt::DirectConnection );
......
......@@ -111,7 +111,18 @@ class ClipWorkflow : public EffectUser
*/
virtual Workflow::OutputBuffer *getOutput( ClipWorkflow::GetMode mode, qint64 currentFrame ) = 0;
void postGetOutput();
virtual void initVlcOutput() = 0;
/*
* Will return a toolchain with the smem configured out
*/
virtual QString createSoutChain() const = 0;
/**
* @brief Initialize base variables for the VLC media representing this clip.
*
* This may also perform some addditional initializations, and
* therefore should be called before createSoutChain()
* A valid m_vlcMedia instance is required to exist prior call to this method.
*/
virtual void initializeVlcOutput() = 0;
void initialize();
/**
......
......@@ -30,6 +30,7 @@
#include "Workflow/Types.h"
#include <QReadWriteLock>
#include <QStringBuilder>
#include <QtDebug>
ImageClipWorkflow::ImageClipWorkflow( ClipHelper *ch ) :
......@@ -49,36 +50,43 @@ ImageClipWorkflow::~ImageClipWorkflow()
delete m_effectFrame;
}
void
ImageClipWorkflow::initVlcOutput()
QString
ImageClipWorkflow::createSoutChain() const
{
char buffer[32];
QString chain = ":sout=#transcode{vcodec=RV32,width=";
chain += QString::number( MainWorkflow::getInstance()->getWidth() )
% ",height="
% QString::number( MainWorkflow::getInstance()->getHeight() )
% ",fps="
% QString::number((float)Clip::DefaultFPS)
% "}:smem{";
if ( m_fullSpeedRender == false )
chain += "time-sync";
else
chain += "no-time-sync";
chain += ",video-data=" % QString::number( reinterpret_cast<intptr_t>( this ) )
% ",video-prerender-callback="
% QString::number( reinterpret_cast<intptr_t>( getLockCallback() ) )
% ",video-postrender-callback="
% QString::number( reinterpret_cast<intptr_t>( getUnlockCallback() ) )
% '}';
return chain;
}
m_vlcMedia->addOption( ":no-audio" );
m_vlcMedia->addOption( ":no-sout-audio" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
m_vlcMedia->setVideoDataCtx( this );
m_vlcMedia->setVideoLockCallback( reinterpret_cast<void*>( getLockCallback() ) );
m_vlcMedia->setVideoUnlockCallback( reinterpret_cast<void*>( getUnlockCallback() ) );
m_vlcMedia->addOption( ":sout-transcode-vcodec=RV32" );
m_vlcMedia->addOption( ":sout-smem-time-sync" );
m_width = MainWorkflow::getInstance()->getWidth();
sprintf( buffer, ":sout-transcode-width=%i", m_width );
m_vlcMedia->addOption( buffer );
m_height = MainWorkflow::getInstance()->getHeight();
sprintf( buffer, ":sout-transcode-height=%i", m_height );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-fps=%f", (float)Clip::DefaultFPS );
m_vlcMedia->addOption( buffer );
void ImageClipWorkflow::initializeVlcOutput()
{
char buffer[32];
m_vlcMedia->addOption(":no-audio");
m_vlcMedia->addOption(":no-sout-audio");
sprintf( buffer, ":fake-duration=%d", 1000 );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":fake-fps=%f", m_clipHelper->clip()->getMedia()->fps() );
m_vlcMedia->addOption( buffer );
m_isRendering = true;
m_effectFrame->resize( MainWorkflow::getInstance()->getWidth(),
MainWorkflow::getInstance()->getHeight() );
m_isRendering = true;
}
void*
......
......@@ -41,7 +41,8 @@ class ImageClipWorkflow : public ClipWorkflow
*/
virtual void setTime( qint64 ){}
protected:
virtual void initVlcOutput();
virtual QString createSoutChain() const;
virtual void initializeVlcOutput();
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
virtual void flushComputedBuffers();
......
......@@ -31,6 +31,7 @@
#include "Workflow/Types.h"
#include <QReadWriteLock>
#include <QStringBuilder>
#include <QtDebug>
VideoClipWorkflow::VideoClipWorkflow( ClipHelper *ch ) :
......@@ -73,31 +74,35 @@ VideoClipWorkflow::preallocate()
}
void
VideoClipWorkflow::initVlcOutput()
VideoClipWorkflow::initializeVlcOutput()
{
char buffer[32];
preallocate();
m_vlcMedia->addOption( ":no-audio" );
m_vlcMedia->addOption( ":no-sout-audio" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
m_vlcMedia->setVideoDataCtx( this );
m_vlcMedia->setVideoLockCallback( reinterpret_cast<void*>( getLockCallback() ) );
m_vlcMedia->setVideoUnlockCallback( reinterpret_cast<void*>( getUnlockCallback() ) );
m_vlcMedia->addOption( ":sout-transcode-vcodec=RV32" );
if ( m_fullSpeedRender == false )
m_vlcMedia->addOption( ":sout-smem-time-sync" );
else
m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
m_vlcMedia->addOption(":no-audio");
m_vlcMedia->addOption(":no-sout-audio");
initFilters();
}
sprintf( buffer, ":sout-transcode-width=%i", m_width );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-height=%i", m_height );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-fps=%f", VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) );
m_vlcMedia->addOption( buffer );
QString
VideoClipWorkflow::createSoutChain() const
{
QString chain = ":sout=#transcode{vcodec=RV32,fps=";
initFilters();
chain += QString::number( VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) )
% ",width=" % QString::number( m_width ) % ",height="
% QString::number( m_height )
% "}:smem{";
if ( m_fullSpeedRender == false )
chain += "time-sync";
else
chain += "no-time-sync";
chain += ",video-data=" % QString::number( reinterpret_cast<intptr_t>( this ) )
% ",video-prerender-callback="
% QString::number( reinterpret_cast<intptr_t>( getLockCallback() ) )
% ",video-postrender-callback="
% QString::number( reinterpret_cast<intptr_t>( getUnlockCallback() ) )
% '}';
return chain;
}
void*
......
......@@ -44,12 +44,16 @@ class VideoClipWorkflow : public ClipWorkflow
static const quint32 nbBuffers = 3 * 30; //3 seconds with an average fps of 30
protected:
virtual void initVlcOutput();
virtual void initializeVlcOutput();
virtual QString createSoutChain() const;
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
virtual void flushComputedBuffers();
/**
* \brief Pre-allocate some image buffers.
*
* This also computes m_width and m_height variables.
* This HAS to be called before createSoutChain()
*/
void preallocate();
virtual void releasePrealocated();
......
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