Skip to content

Transcoder: complete API #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions app/genericProcessor/genericProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include <sstream>
#include <cstdlib>

static const size_t dummyWidth = 1920;
static const size_t dummyHeight = 1080;
static const std::string dummyPixelFormat = "yuv420p";
static const std::string dummyVideoCodec = "mpeg2video";
static const std::string dummyAudioCodec = "pcm_s16le";

// bool verbose = false;
bool verbose = true;

Expand Down Expand Up @@ -47,9 +53,27 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
std::cout << ( transcodeProfile.length() ? transcodeProfile : "rewrap" );
std::cout << std::endl;
}

transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile );


// dummy stream, need a CodedDesc (audio or video)
if( ! filename.length() )
{
// video
avtranscoder::VideoFrameDesc imageDesc;
imageDesc.setWidth( dummyWidth );
imageDesc.setHeight( dummyHeight );
imageDesc.setDar( dummyWidth, dummyHeight );
avtranscoder::Pixel inputPixel( dummyPixelFormat );
imageDesc.setPixel( inputPixel );

avtranscoder::VideoDesc inputVideoDesc( dummyVideoCodec );
inputVideoDesc.setImageParameters( imageDesc );

transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile, inputVideoDesc );
}
else
{
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile );
}
}
}
}
Expand Down Expand Up @@ -85,6 +109,7 @@ int main( int argc, char** argv )

avtranscoder::Transcoder transcoder( outputFile );
transcoder.setVerbose( verbose );
transcoder.setProcessMethod( avtranscoder::eProcessMethodShortest );

if( verbose )
std::cout << "parse config file" << std::endl;
Expand Down
53 changes: 53 additions & 0 deletions src/AvTranscoder/Transcoder/Transcoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ namespace avtranscoder

Transcoder::Transcoder( OutputFile& outputFile )
: _outputFile( outputFile )
, _inputFiles()
, _inputStreams()
, _streamTranscoders()
, _dummyAudio()
, _dummyVideo()
, _profile( true )
, _finalisedStreams( 0 )
, _eProcessMethod ( eProcessMethodLongest )
Expand Down Expand Up @@ -47,6 +52,27 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
add( filename, streamIndex, transcodeProfile );
}

void Transcoder::add( const std::string& filename, const size_t streamIndex, const std::string& profileName, CodedDesc& essenceDesc )
{
if( profileName.length() == 0 ) // no profile, only re-wrap stream
{
if( _verbose )
std::cout << "add re-wrap stream" << std::endl;

if( filename.length() == 0 )
{
std::cerr << "can't add a dummy stream with no profileName indicated" << std::endl;
return;
}

addRewrapStream( filename, streamIndex );
return;
}

Profile::ProfileDesc& transcodeProfile = _profile.getProfile( profileName );
add( filename, streamIndex, transcodeProfile, essenceDesc );
}

void Transcoder::add( const std::string& filename, const size_t streamIndex, Profile::ProfileDesc& profileDesc )
{
_profile.update( profileDesc );
Expand Down Expand Up @@ -99,6 +125,33 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
add( filename, streamIndex, subStreamIndex, transcodeProfile );
}

void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, CodedDesc& essenceDesc )
{
if( subStreamIndex < 0 )
{
add( filename, streamIndex, profileName, essenceDesc );
return;
}

if( profileName.length() == 0 ) // no profile, only re-wrap stream
{
if( _verbose )
std::cout << "add re-wrap stream for substream " << subStreamIndex << std::endl;

if( filename.length() == 0 )
{
std::cerr << "can't add a dummy stream with no profileName indicated" << std::endl;
return;
}

addRewrapStream( filename, streamIndex );
return;
}

Profile::ProfileDesc& transcodeProfile = _profile.getProfile( profileName );
add( filename, streamIndex, subStreamIndex, transcodeProfile, essenceDesc );
}

void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, Profile::ProfileDesc& profileDesc )
{
_profile.update( profileDesc );
Expand Down
16 changes: 16 additions & 0 deletions src/AvTranscoder/Transcoder/Transcoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
namespace avtranscoder
{

/**
* @brief: Enum to set a policy of how we manage the transcode in case of several streams.
* eProcessMethodShortest: stop transcode at the end of the shortest stream.
* eProcessMethodLongest: stop transcode at the end of the longest stream (default method).
* eProcessMethodInfinity: stop transcode by outside of avTranscoder.
*/
enum EProcessMethod
{
eProcessMethodShortest = 0,
Expand All @@ -43,6 +49,11 @@ class Transcoder
* @note If profileName is empty, rewrap.
*/
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName = "" );
/*
* @note If filename is empty, add a dummy stream.
* @note If filename is empty, profileName can't be empty (no sens to rewrap a dummy stream).
*/
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName, CodedDesc& essenceDesc );

/**
* @brief Add a stream and set a custom profile
Expand All @@ -60,6 +71,11 @@ class Transcoder
* @note If subStreamIndex is negative, no substream is selected it's the stream.
*/
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName = "" );
/**
* @note If filename is empty, add a dummy stream.
* @note If filename is empty, profileName can't be empty (no sens to rewrap a dummy stream).
*/
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, CodedDesc& essenceDesc );

/**
* @brief Add a stream and set a custom profile
Expand Down