这段代码有什么问题?它在av_find_stream_info处中断(访问冲突)。在调试时,ctx-> filename是“3”而不是“1.MP3”:前4个字符被忽略,也检查其他文件,结果相同。C++ ffmpeg访问冲突
av_register_all();
AVFormatContext *ctx=0;
ctx=avformat_alloc_context();
avformat_open_input(&ctx,"1.MP3",0,0);
av_find_stream_info(ctx);
int istream;
for(int i=0;i<ctx->nb_streams;i++){
if(ctx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO){
istream=i;
break;
}
您将永远无法调试不包含错误检查的代码。 'avformat_open_input'的返回值是什么? – 2012-03-29 09:57:02
avformat_open_input返回-2。 – user1288043 2012-03-29 10:11:11