0

问题: AVFormatContext::nb_streams 价值太小。我的 C++ 代码(错误处理、包含等省略以减少列表):

void printA(AVFormatContext* _a)
{
std::cout << "duration    " << (unsigned long)_a->duration << "\n";
std::cout << "streams     " << _a->nb_streams << "\n";
std::cout << "format name " << _a->iformat->name << "\n";
std::cout << "bit_rate    " << _a->bit_rate << "\n";
std::cout << "long name   " << _a->iformat->long_name << "\n";
}

int main(int argc, char **argv)
{


if ( argc < 2 )
{
    std::cout << "Usage: " << argv[0] << " <file>\n";
    return 1;
}

    av_register_all();

AVFormatContext *pFormatCtx = avformat_alloc_context();

avformat_open_input (&pFormatCtx, argv[1], NULL, NULL);
avformat_find_stream_info(pFormatCtx, NULL);

printA( pFormatCtx );
return 0;
}

跑步:

xx@xx /tmp/avlib $ ./avlibtest /ar/video/Nauka.Sna.2006.HDRip.AVC.mkv 
[matroska,webm @ 0x804c040] max_analyze_duration reached
[matroska,webm @ 0x804c040] Estimating duration from bitrate, this may be inaccurate
duration    134741408
streams     134531840     <---- !!! :-O
format name matroska,webm
bit_rate    0
long name   Matroska/WebM file format

但是“avplay”程序运行良好。

4

0 回答 0