【发布时间】:2012-03-30 01:41:53
【问题描述】:
这段代码有什么问题?它在 av_find_stream_info 中断(访问冲突)。调试时,ctx->filename 是“3”而不是“1.MP3”:前 4 个字符被省略,也检查其他文件,结果相同。
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的返回值是多少? -
avformat_open_input 返回 -2。