Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cpp-ffmpeg how to resolve deprecated warning?

I am working with FFmpeg Lib, and I get a warning, my code as below:

if ( avformat_find_stream_info( pFormatCtx, NULL ) < 0 ) {
        std::cout << "Get Stream Information Error 13" << std::endl;
        avformat_close_input( &pFormatCtx );
        pFormatCtx = NULL;
        return -13;
 }
av_dump_format( pFormatCtx, 0, filenameSrc, 0 );

for ( unsigned int i = 0; i < pFormatCtx->nb_streams; i++ ) {
        if (pFormatCtx->streams[i]->codec->coder_type == AVMEDIA_TYPE_VIDEO) {
            video_stream_index = i;
            break;
        }
 }

And I meet the warning at line: pFormatCtx->streams[i]->codec->coder_type == AVMEDIA_TYPE_VIDEO

Warning: AVCodecContext::coder_type’ is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:2815) [-Wdeprecated-declarations]

I dont understand what does this warning mean and how to resolve it.

Anyone can help me !

Thank

like image 474
Trần Quốc Việt Avatar asked Sep 19 '25 21:09

Trần Quốc Việt


1 Answers

Try to use codec_type from codecpar:

if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
        video_stream_index = i;
like image 141
Rainmaker Avatar answered Sep 22 '25 10:09

Rainmaker