Skip to content

Commit 34b89c0

Browse files
author
Clement Champetier
committed
FormatContext: print error message if unable to open file
1 parent 955da92 commit 34b89c0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/AvTranscoder/file/FormatContext.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ FormatContext::FormatContext( const std::string& filename, int req_flags )
1414
{
1515
av_register_all(); // TODO: call it once
1616

17-
int err = avformat_open_input( &_avFormatContext, filename.c_str(), NULL, NULL );
18-
if( err < 0 )
17+
int ret = avformat_open_input( &_avFormatContext, filename.c_str(), NULL, NULL );
18+
if( ret < 0 )
1919
{
20-
std::string msg = "unable to open file: ";
20+
char err[AV_ERROR_MAX_STRING_SIZE];
21+
av_strerror( ret, err, sizeof(err) );
22+
std::string msg = "unable to open file ";
2123
msg += filename;
24+
msg += ": ";
25+
msg += err;
2226
throw std::ios_base::failure( msg );
2327
}
2428
loadOptions( _options, _avFormatContext, req_flags );

0 commit comments

Comments
 (0)