先初始化 輸入封裝格式背景關系ps 和 輸入格式 fmt,然后打開檔案,回傳值為 -5,
ps = avformat_alloc_context();
fmt = av_find_input_format("dshow");
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
====================解決辦法=========================================================
查找了一番原因,是因為我的 filename輸入有一點錯誤,這個檔案路徑,一定要仔細核對,不能有一丁點的錯誤,
尤其是打開麥克風,出現中文的時候,一定要進行寬字符轉換,
char *psDevName = dup_wchar_to_utf8(L"audio=麥克風陣列 (Conexant SmartAudio HD)");
// 用于將中文字串,轉化為UTF8
static char *dup_wchar_to_utf8(wchar_t *w)
{
char *s = NULL;
int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0);
s = (char *)av_malloc(l);
if (s)
WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, 0, 0);
return s;
}
以上程式是在VS2010 MFC上寫的,其他平臺可能不適用哦,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/168724.html
標籤:其他
上一篇:黃毅然的JAVA學習
