From 3490499c5892f10522b00406271c9f579f0910a7 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Aug 2014 14:44:07 +0200 Subject: [PATCH 1/6] Transcoder: can add a dummy with a profile name * Need this new function to add a dummy stream with a preset name (no profile desc is needed). --- src/AvTranscoder/Transcoder/Transcoder.cpp | 21 +++++++++++++++++++++ src/AvTranscoder/Transcoder/Transcoder.hpp | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/src/AvTranscoder/Transcoder/Transcoder.cpp b/src/AvTranscoder/Transcoder/Transcoder.cpp index 9fb8bb6a..6310e23c 100644 --- a/src/AvTranscoder/Transcoder/Transcoder.cpp +++ b/src/AvTranscoder/Transcoder/Transcoder.cpp @@ -47,6 +47,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 ); diff --git a/src/AvTranscoder/Transcoder/Transcoder.hpp b/src/AvTranscoder/Transcoder/Transcoder.hpp index 08f815b3..36adf39c 100644 --- a/src/AvTranscoder/Transcoder/Transcoder.hpp +++ b/src/AvTranscoder/Transcoder/Transcoder.hpp @@ -43,6 +43,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 From 89b87b8a06cf32fab1f35717969417d03723147b Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Aug 2014 14:47:54 +0200 Subject: [PATCH 2/6] Transcoder: can add a dummy with a profile name and a subStreamIndex indicated Complete the API, with keeping symmetry. Now there are: * 4 add functions with only a streamIndex indicated * 4 add functions with a streamIndex and a subStreamIndex indicated --- src/AvTranscoder/Transcoder/Transcoder.cpp | 27 ++++++++++++++++++++++ src/AvTranscoder/Transcoder/Transcoder.hpp | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/src/AvTranscoder/Transcoder/Transcoder.cpp b/src/AvTranscoder/Transcoder/Transcoder.cpp index 6310e23c..60036f61 100644 --- a/src/AvTranscoder/Transcoder/Transcoder.cpp +++ b/src/AvTranscoder/Transcoder/Transcoder.cpp @@ -120,6 +120,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 36adf39c..4b5b8112 100644 --- a/src/AvTranscoder/Transcoder/Transcoder.hpp +++ b/src/AvTranscoder/Transcoder/Transcoder.hpp @@ -65,6 +65,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 From ebf54d648d72f6d0cd16cbc23b72a4b6da672cd3 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Aug 2014 14:50:57 +0200 Subject: [PATCH 3/6] Transcoder: add doc for enum EProcessMethod --- src/AvTranscoder/Transcoder/Transcoder.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/AvTranscoder/Transcoder/Transcoder.hpp b/src/AvTranscoder/Transcoder/Transcoder.hpp index 4b5b8112..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, From 4c34ad965500de4d8eda99d5179f4cc47dd14069 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Aug 2014 14:51:23 +0200 Subject: [PATCH 4/6] Transcoder: complete constructor --- src/AvTranscoder/Transcoder/Transcoder.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AvTranscoder/Transcoder/Transcoder.cpp b/src/AvTranscoder/Transcoder/Transcoder.cpp index 60036f61..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 ) From a956861cc457f29d21a42bb836faca3340b43701 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Aug 2014 16:58:27 +0200 Subject: [PATCH 5/6] avprocessor: can add dummy video * If dummy video, need a VideoDesc. * Warning: can't add a dummy audio, because we need an AudioDesc... Need to add this information in the confi file. Maybe it will be easier in python! --- app/genericProcessor/genericProcessor.cpp | 30 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/app/genericProcessor/genericProcessor.cpp b/app/genericProcessor/genericProcessor.cpp index 9083426f..e54747cc 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 ); + } } } } From a9c85b686808ac634550ccb9a182062072b15f4f Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Aug 2014 16:58:59 +0200 Subject: [PATCH 6/6] avprocessor: setProcessMethod to shortest --- app/genericProcessor/genericProcessor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/app/genericProcessor/genericProcessor.cpp b/app/genericProcessor/genericProcessor.cpp index e54747cc..da67d7a8 100644 --- a/app/genericProcessor/genericProcessor.cpp +++ b/app/genericProcessor/genericProcessor.cpp @@ -109,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;