@@ -138,27 +138,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
138
138
{
139
139
if ( _verbose )
140
140
std::cout << " Add transcoded stream (because of demultiplexing)" << std::endl;
141
- // Create profile as input configuration
142
- InputFile inputFile ( filename );
143
- NoDisplayProgress progress;
144
- inputFile.analyse ( progress, InputFile::eAnalyseLevelFast );
145
- AudioProperties audioProperties = inputFile.getProperties ().audioStreams .at ( streamIndex ); // Warning: only manage audio case
146
-
147
- ProfileLoader::Profile profile;
148
- profile[ constants::avProfileIdentificator ] = " presetRewrap" ;
149
- profile[ constants::avProfileIdentificatorHuman ] = " Preset rewrap" ;
150
- profile[ constants::avProfileType ] = avtranscoder::constants::avProfileTypeAudio;
151
- profile[ constants::avProfileCodec ] = audioProperties.codecName ;
152
- profile[ constants::avProfileSampleFormat ] = audioProperties.sampleFormat ;
153
- std::stringstream ss;
154
- ss << audioProperties.sampleRate ;
155
- profile[ constants::avProfileSampleRate ] = ss.str ();
156
- profile[ constants::avProfileChannel ] = " 1" ;
157
-
158
- // Add profile
159
- _profileLoader.update ( profile );
160
-
161
- add ( filename, streamIndex, subStreamIndex, profile, offset );
141
+ addTranscodeStream ( filename, streamIndex, subStreamIndex, offset );
162
142
}
163
143
}
164
144
// Transcode
@@ -194,27 +174,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
194
174
{
195
175
if ( _verbose )
196
176
std::cout << " Add transcoded stream (because of demultiplexing)" << std::endl;
197
- // Create profile as input configuration
198
- InputFile inputFile ( filename );
199
- NoDisplayProgress progress;
200
- inputFile.analyse ( progress, InputFile::eAnalyseLevelFast );
201
- AudioProperties audioProperties = inputFile.getProperties ().audioStreams .at ( streamIndex ); // Warning: only manage audio case
202
-
203
- ProfileLoader::Profile profile;
204
- profile[ constants::avProfileIdentificator ] = " presetRewrap" ;
205
- profile[ constants::avProfileIdentificatorHuman ] = " Preset rewrap" ;
206
- profile[ constants::avProfileType ] = avtranscoder::constants::avProfileTypeAudio;
207
- profile[ constants::avProfileCodec ] = audioProperties.codecName ;
208
- profile[ constants::avProfileSampleFormat ] = audioProperties.sampleFormat ;
209
- std::stringstream ss;
210
- ss << audioProperties.sampleRate ;
211
- profile[ constants::avProfileSampleRate ] = ss.str ();
212
- profile[ constants::avProfileChannel ] = " 1" ;
213
-
214
- // Add profile
215
- _profileLoader.update ( profile );
216
-
217
- add ( filename, streamIndex, subStreamIndex, profile, offset );
177
+ addTranscodeStream ( filename, streamIndex, subStreamIndex, offset );
218
178
}
219
179
}
220
180
// Transcode
@@ -417,6 +377,47 @@ void Transcoder::addRewrapStream( const std::string& filename, const size_t stre
417
377
_streamTranscoders.push_back ( new StreamTranscoder ( referenceFile->getStream ( streamIndex ), _outputFile ) );
418
378
}
419
379
380
+ void Transcoder::addTranscodeStream ( const std::string& filename, const size_t streamIndex, const size_t subStreamIndex, const size_t offset )
381
+ {
382
+ InputFile* referenceFile = addInputFile ( filename, streamIndex );
383
+
384
+ // Create profile as input configuration
385
+ NoDisplayProgress progress;
386
+ referenceFile->analyse ( progress, InputFile::eAnalyseLevelFast );
387
+ AudioProperties audioProperties = referenceFile->getProperties ().audioStreams .at ( streamIndex );
388
+
389
+ ProfileLoader::Profile profile;
390
+ profile[ constants::avProfileIdentificator ] = " presetRewrap" ;
391
+ profile[ constants::avProfileIdentificatorHuman ] = " Preset rewrap" ;
392
+ profile[ constants::avProfileType ] = avtranscoder::constants::avProfileTypeAudio;
393
+ profile[ constants::avProfileCodec ] = audioProperties.codecName ;
394
+ profile[ constants::avProfileSampleFormat ] = audioProperties.sampleFormat ;
395
+ std::stringstream ss;
396
+ ss << audioProperties.sampleRate ;
397
+ profile[ constants::avProfileSampleRate ] = ss.str ();
398
+ profile[ constants::avProfileChannel ] = " 1" ;
399
+
400
+ // Add profile
401
+ _profileLoader.update ( profile );
402
+
403
+ switch ( referenceFile->getStreamType ( streamIndex ) )
404
+ {
405
+ case AVMEDIA_TYPE_VIDEO:
406
+ case AVMEDIA_TYPE_AUDIO:
407
+ {
408
+ _streamTranscoders.push_back ( new StreamTranscoder ( referenceFile->getStream ( streamIndex ), _outputFile, profile, subStreamIndex , offset ) );
409
+ break ;
410
+ }
411
+ case AVMEDIA_TYPE_DATA:
412
+ case AVMEDIA_TYPE_SUBTITLE:
413
+ case AVMEDIA_TYPE_ATTACHMENT:
414
+ default :
415
+ {
416
+ throw std::runtime_error ( " unsupported media type in transcode setup" );
417
+ }
418
+ }
419
+ }
420
+
420
421
void Transcoder::addTranscodeStream ( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, const size_t offset )
421
422
{
422
423
InputFile* referenceFile = addInputFile ( filename, streamIndex );
0 commit comments