Проблема: дикие значения переменной AVFormatContext::nb_streams (оч. большое число).
Код:
(для краткости выкинута обработка ошибок).
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)
{
const char *filename;
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 format name matroska,webm bit_rate 0 long name Matroska/WebM file format
«streams 134531840» - вот проблема.