Skip to content

Commit a786476

Browse files
author
Clement Champetier
committed
hotfix: load private FormatContext options only when it's possible
According to the ffmpeg documentation, priv_data of AVFormatContext is "... an AVOptions-enabled struct if and only if iformat/oformat.priv_class is not NULL."
1 parent 48d71ec commit a786476

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/AvTranscoder/file/FormatContext.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ FormatContext::FormatContext( const std::string& filename, int req_flags, AVDict
2525

2626
loadOptions( _options, _avFormatContext, req_flags );
2727
// when demuxing, priv_data of AVFormatContext is set by avformat_open_input()
28-
loadOptions( _options, _avFormatContext->priv_data, req_flags );
28+
if( _avFormatContext->iformat->priv_class )
29+
loadOptions( _options, _avFormatContext->priv_data, req_flags );
2930
}
3031

3132
FormatContext::FormatContext( int req_flags )
@@ -91,7 +92,8 @@ void FormatContext::writeHeader( AVDictionary** options )
9192
throw std::runtime_error( "could not write header: " + getDescriptionFromErrorCode( ret ) );
9293
}
9394
// when muxing, priv_data of AVFormatContext is set by avformat_write_header()
94-
loadOptions( _options, _avFormatContext->priv_data, _flags );
95+
if( _avFormatContext->oformat->priv_class )
96+
loadOptions( _options, _avFormatContext->priv_data, _flags );
9597
}
9698

9799
void FormatContext::writeFrame( AVPacket& packet, bool interleaved )

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy