Skip to content

Commit b6e449d

Browse files
adding error message and AvOutputStream to stack
1 parent c27a0f6 commit b6e449d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/AvTranscoder/File/OutputFile.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ AvOutputStream& OutputFile::addVideoStream( const VideoDesc& videoDesc )
8585
INT_MAX );
8686

8787
_stream->time_base = _stream->codec->time_base;
88+
89+
_outputStreams.push_back( AvOutputStream( *this, _formatContext->nb_streams ) );
90+
8891
return _outputStreams.back();
8992
}
9093

@@ -101,6 +104,8 @@ AvOutputStream& OutputFile::addAudioStream( const AudioDesc& audioDesc )
101104
_stream->codec->channels = audioDesc.getCodecContext()->channels;
102105
_stream->codec->sample_fmt = audioDesc.getCodecContext()->sample_fmt;
103106

107+
_outputStreams.push_back( AvOutputStream( *this, _formatContext->nb_streams ) );
108+
104109
return _outputStreams.back();
105110
}
106111

@@ -111,9 +116,14 @@ AvOutputStream& OutputFile::getStream( const size_t streamId )
111116

112117
bool OutputFile::beginWrap( )
113118
{
114-
if( avformat_write_header( _formatContext, NULL ) != 0 )
119+
int ret = avformat_write_header( _formatContext, NULL );
120+
if( ret != 0 )
115121
{
116-
throw std::runtime_error( "could not write header" );
122+
char err[250];
123+
av_strerror( ret, err, 250);
124+
std::string msg = "could not write header: ";
125+
msg += err;
126+
throw std::runtime_error( msg );
117127
}
118128
return true;
119129
}

0 commit comments

Comments
 (0)