diff --git a/app/genericProcessor/genericProcessor.cpp b/app/genericProcessor/genericProcessor.cpp index 9083426f..da67d7a8 100644 --- a/app/genericProcessor/genericProcessor.cpp +++ b/app/genericProcessor/genericProcessor.cpp @@ -8,6 +8,12 @@ #include #include +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; @@ -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 ); + } } } } @@ -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; diff --git a/src/AvTranscoder/Transcoder/Transcoder.cpp b/src/AvTranscoder/Transcoder/Transcoder.cpp index 9fb8bb6a..676db7cb 100644 --- a/src/AvTranscoder/Transcoder/Transcoder.cpp +++ b/src/AvTranscoder/Transcoder/Transcoder.cpp @@ -5,6 +5,11 @@ namespace avtranscoder Transcoder::Transcoder( OutputFile& outputFile ) : _outputFile( outputFile ) + , _inputFiles() + , _inputStreams() + , _streamTranscoders() + , _dummyAudio() + , _dummyVideo() , _profile( true ) , _finalisedStreams( 0 ) , _eProcessMethod ( eProcessMethodLongest ) @@ -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 ); @@ -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 ); diff --git a/src/AvTranscoder/Transcoder/Transcoder.hpp b/src/AvTranscoder/Transcoder/Transcoder.hpp index 08f815b3..2bfdffba 100644 --- a/src/AvTranscoder/Transcoder/Transcoder.hpp +++ b/src/AvTranscoder/Transcoder/Transcoder.hpp @@ -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, @@ -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 @@ -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