Skip to content

Commit effcd7a

Browse files
author
Clement Champetier
committed
OuputFile: allocate AVFormatContext in constructor
* Allocate AVFormatContext in OuputFile's constructor (before the setup). * Reason: if setProfile before setup, the AVFormatContext is NULL and so wa can set no format options.
1 parent 1c1b180 commit effcd7a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/AvTranscoder/File/OutputFile.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ OutputFile::OutputFile( const std::string& filename )
2626
, _filename ( filename )
2727
, _packetCount ( 0 )
2828
{
29+
if( ( _formatContext = avformat_alloc_context() ) == NULL )
30+
{
31+
throw std::runtime_error( "unable to create format context" );
32+
}
2933
}
3034

3135
bool OutputFile::setup()
@@ -38,11 +42,6 @@ bool OutputFile::setup()
3842
throw std::runtime_error( "unable to find format" );
3943
}
4044

41-
if( ( _formatContext = avformat_alloc_context() ) == NULL )
42-
{
43-
throw std::runtime_error( "unable to create format context" );
44-
}
45-
4645
_formatContext->oformat = _outputFormat;
4746

4847
if( !( _outputFormat->flags & AVFMT_NOFILE ) )

0 commit comments

Comments
 (0)