在C / C ++中使用libavcodec与linux时出错

时间:2012-07-07 22:39:45

标签: c++ libavcodec libavformat libav

问题: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”计划运作良好。

0 个答案:

没有答案