Skip to content

Commit 50af13f

Browse files
Merge pull request #38 from cchampet/dev_Transcoder
Transcoder: complete API
2 parents 323f28b + a9c85b6 commit 50af13f

File tree

3 files changed

+97
-3
lines changed

3 files changed

+97
-3
lines changed

app/genericProcessor/genericProcessor.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include <sstream>
99
#include <cstdlib>
1010

11+
static const size_t dummyWidth = 1920;
12+
static const size_t dummyHeight = 1080;
13+
static const std::string dummyPixelFormat = "yuv420p";
14+
static const std::string dummyVideoCodec = "mpeg2video";
15+
static const std::string dummyAudioCodec = "pcm_s16le";
16+
1117
// bool verbose = false;
1218
bool verbose = true;
1319

@@ -47,9 +53,27 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
4753
std::cout << ( transcodeProfile.length() ? transcodeProfile : "rewrap" );
4854
std::cout << std::endl;
4955
}
50-
51-
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile );
52-
56+
57+
// dummy stream, need a CodedDesc (audio or video)
58+
if( ! filename.length() )
59+
{
60+
// video
61+
avtranscoder::VideoFrameDesc imageDesc;
62+
imageDesc.setWidth( dummyWidth );
63+
imageDesc.setHeight( dummyHeight );
64+
imageDesc.setDar( dummyWidth, dummyHeight );
65+
avtranscoder::Pixel inputPixel( dummyPixelFormat );
66+
imageDesc.setPixel( inputPixel );
67+
68+
avtranscoder::VideoDesc inputVideoDesc( dummyVideoCodec );
69+
inputVideoDesc.setImageParameters( imageDesc );
70+
71+
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile, inputVideoDesc );
72+
}
73+
else
74+
{
75+
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile );
76+
}
5377
}
5478
}
5579
}
@@ -85,6 +109,7 @@ int main( int argc, char** argv )
85109

86110
avtranscoder::Transcoder transcoder( outputFile );
87111
transcoder.setVerbose( verbose );
112+
transcoder.setProcessMethod( avtranscoder::eProcessMethodShortest );
88113

89114
if( verbose )
90115
std::cout << "parse config file" << std::endl;

src/AvTranscoder/Transcoder/Transcoder.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ namespace avtranscoder
55

66
Transcoder::Transcoder( OutputFile& outputFile )
77
: _outputFile( outputFile )
8+
, _inputFiles()
9+
, _inputStreams()
10+
, _streamTranscoders()
11+
, _dummyAudio()
12+
, _dummyVideo()
813
, _profile( true )
914
, _finalisedStreams( 0 )
1015
, _eProcessMethod ( eProcessMethodLongest )
@@ -47,6 +52,27 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
4752
add( filename, streamIndex, transcodeProfile );
4853
}
4954

55+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const std::string& profileName, CodedDesc& essenceDesc )
56+
{
57+
if( profileName.length() == 0 ) // no profile, only re-wrap stream
58+
{
59+
if( _verbose )
60+
std::cout << "add re-wrap stream" << std::endl;
61+
62+
if( filename.length() == 0 )
63+
{
64+
std::cerr << "can't add a dummy stream with no profileName indicated" << std::endl;
65+
return;
66+
}
67+
68+
addRewrapStream( filename, streamIndex );
69+
return;
70+
}
71+
72+
Profile::ProfileDesc& transcodeProfile = _profile.getProfile( profileName );
73+
add( filename, streamIndex, transcodeProfile, essenceDesc );
74+
}
75+
5076
void Transcoder::add( const std::string& filename, const size_t streamIndex, Profile::ProfileDesc& profileDesc )
5177
{
5278
_profile.update( profileDesc );
@@ -99,6 +125,33 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
99125
add( filename, streamIndex, subStreamIndex, transcodeProfile );
100126
}
101127

128+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, CodedDesc& essenceDesc )
129+
{
130+
if( subStreamIndex < 0 )
131+
{
132+
add( filename, streamIndex, profileName, essenceDesc );
133+
return;
134+
}
135+
136+
if( profileName.length() == 0 ) // no profile, only re-wrap stream
137+
{
138+
if( _verbose )
139+
std::cout << "add re-wrap stream for substream " << subStreamIndex << std::endl;
140+
141+
if( filename.length() == 0 )
142+
{
143+
std::cerr << "can't add a dummy stream with no profileName indicated" << std::endl;
144+
return;
145+
}
146+
147+
addRewrapStream( filename, streamIndex );
148+
return;
149+
}
150+
151+
Profile::ProfileDesc& transcodeProfile = _profile.getProfile( profileName );
152+
add( filename, streamIndex, subStreamIndex, transcodeProfile, essenceDesc );
153+
}
154+
102155
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, Profile::ProfileDesc& profileDesc )
103156
{
104157
_profile.update( profileDesc );

src/AvTranscoder/Transcoder/Transcoder.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
namespace avtranscoder
2424
{
2525

26+
/**
27+
* @brief: Enum to set a policy of how we manage the transcode in case of several streams.
28+
* eProcessMethodShortest: stop transcode at the end of the shortest stream.
29+
* eProcessMethodLongest: stop transcode at the end of the longest stream (default method).
30+
* eProcessMethodInfinity: stop transcode by outside of avTranscoder.
31+
*/
2632
enum EProcessMethod
2733
{
2834
eProcessMethodShortest = 0,
@@ -43,6 +49,11 @@ class Transcoder
4349
* @note If profileName is empty, rewrap.
4450
*/
4551
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName = "" );
52+
/*
53+
* @note If filename is empty, add a dummy stream.
54+
* @note If filename is empty, profileName can't be empty (no sens to rewrap a dummy stream).
55+
*/
56+
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName, CodedDesc& essenceDesc );
4657

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

6480
/**
6581
* @brief Add a stream and set a custom profile

0 commit comments

Comments
 (0)