Skip to content

Commit 9c1534a

Browse files
author
Clement Champetier
committed
OutputFile: update setProfile
* avProfileFormat is necessary in a format profileDesc. * Update _outputFormat depending on avProfileFormat in the profile.
1 parent 75d64c8 commit 9c1534a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/AvTranscoder/File/OutputFile.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ OutputFile::OutputFile( const std::string& filename )
3333
bool OutputFile::setup()
3434
{
3535
av_register_all();
36-
_outputFormat = av_guess_format( NULL, _filename.c_str(), NULL);
36+
if( ! _outputFormat )
37+
_outputFormat = av_guess_format( NULL, _filename.c_str(), NULL);
3738

3839
if( ! _outputFormat )
3940
{
@@ -182,14 +183,26 @@ bool OutputFile::endWrap( )
182183

183184

184185
void OutputFile::setProfile( const Profile::ProfileDesc& desc )
185-
{
186+
{
187+
if( ! desc.count( Profile::avProfileFormat ) )
188+
{
189+
throw std::runtime_error( "The profile " + desc.find( Profile::avProfileIdentificatorHuman )->second + " is invalid." );
190+
}
191+
192+
if( ! matchFormat( desc.find( Profile::avProfileFormat )->second, _filename ) )
193+
{
194+
throw std::runtime_error( "Invalid format according to the file extension." );
195+
}
196+
_outputFormat = av_guess_format( desc.find( Profile::avProfileFormat )->second.c_str(), _filename.c_str(), NULL);
197+
186198
ParamSet paramSet( _formatContext );
187199

188200
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
189201
{
190202
if( (*it).first == Profile::avProfileIdentificator ||
191203
(*it).first == Profile::avProfileIdentificatorHuman ||
192-
(*it).first == Profile::avProfileType )
204+
(*it).first == Profile::avProfileType ||
205+
(*it).first == Profile::avProfileFormat )
193206
continue;
194207

195208
try
@@ -208,7 +221,8 @@ void OutputFile::setProfile( const Profile::ProfileDesc& desc )
208221
{
209222
if( (*it).first == Profile::avProfileIdentificator ||
210223
(*it).first == Profile::avProfileIdentificatorHuman ||
211-
(*it).first == Profile::avProfileType )
224+
(*it).first == Profile::avProfileType ||
225+
(*it).first == Profile::avProfileFormat )
212226
continue;
213227

214228
try

0 commit comments

Comments
 (0)