[英]c++ ffmpeg access violation
這段代碼有什么問題? 它在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
失敗。
使用av_strerror
找出avformat_open_input
失敗的原因。 avformat_open_input
返回的avformat_open_input
表示錯誤情況。
您的代碼包含一個錯誤-即使avformat_open_input
失敗,它也會調用av_find_stream_info
。
-2
可能是-ENOENT
沒有這樣的文件或目錄。 也許您在錯誤的目錄中。 也許文件的名稱是1.mp3
而不是1.MP3
,並且您的文件系統區分大小寫。
但是您不能調試不檢查錯誤的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.