@@ -33,7 +33,8 @@ OutputFile::OutputFile( const std::string& filename )
33
33
bool OutputFile::setup ()
34
34
{
35
35
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 );
37
38
38
39
if ( ! _outputFormat )
39
40
{
@@ -182,14 +183,26 @@ bool OutputFile::endWrap( )
182
183
183
184
184
185
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
+
186
198
ParamSet paramSet ( _formatContext );
187
199
188
200
for ( Profile::ProfileDesc::const_iterator it = desc.begin (); it != desc.end (); ++it )
189
201
{
190
202
if ( (*it).first == Profile::avProfileIdentificator ||
191
203
(*it).first == Profile::avProfileIdentificatorHuman ||
192
- (*it).first == Profile::avProfileType )
204
+ (*it).first == Profile::avProfileType ||
205
+ (*it).first == Profile::avProfileFormat )
193
206
continue ;
194
207
195
208
try
@@ -208,7 +221,8 @@ void OutputFile::setProfile( const Profile::ProfileDesc& desc )
208
221
{
209
222
if ( (*it).first == Profile::avProfileIdentificator ||
210
223
(*it).first == Profile::avProfileIdentificatorHuman ||
211
- (*it).first == Profile::avProfileType )
224
+ (*it).first == Profile::avProfileType ||
225
+ (*it).first == Profile::avProfileFormat )
212
226
continue ;
213
227
214
228
try
0 commit comments