[英]c++ ffmpeg access violation
What's wrong in this code? 这段代码有什么问题? It is breaking (access violation) at av_find_stream_info. 它在av_find_stream_info处中断(访问冲突)。 While debugging, ctx->filename is "3" instead of "1.MP3": first 4 chars are omitted, checked for other files too, same result. 调试时,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
is failing. avformat_open_input
失败。
Use av_strerror
to find out why avformat_open_input
is failing. 使用av_strerror
找出avformat_open_input
失败的原因。 A negative value returned by avformat_open_input
indicates an error condition. avformat_open_input
返回的avformat_open_input
表示错误情况。
Your code contains a bug -- it is calling av_find_stream_info
even if avformat_open_input
fails. 您的代码包含一个错误-即使avformat_open_input
失败,它也会调用av_find_stream_info
。
-2
is probably -ENOENT
-- no such file or directory. -2
可能是-ENOENT
没有这样的文件或目录。 Perhaps you're in the wrong directory. 也许您在错误的目录中。 Perhaps the file's name is 1.mp3
, not 1.MP3
, and your filesystem is case-sensitive. 也许文件的名称是1.mp3
而不是1.MP3
,并且您的文件系统区分大小写。
But you can't debug code that doesn't check for errors. 但是您不能调试不检查错误的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.