Hi,
I am trying to use the libavcodec.dll in my dialog based VC++ program. After a lot of messing aroundI have a program that successfully links to the dll and the lib file(libavcodec and libavformat) and can run without any errors. I then started to try and encode an audio file.
The below is my entire code so far
The bold part(avctx->......) is where I am getting Unhandled Exception/Access Violation. Up until I got there,I didnt have any errors whatsoever. You will notice that I numbered my pointers, so that gives you an idea as to in which order i proceeded.Code:AVCodecContext *avctx; AVCodec *codec; avctx = new AVCodecContext; codec = new AVCodec; avctx=NULL; //int codec_id; HMODULE hDll = LoadLibrary("libavcodec.dll"); if(hDll== NULL) { GetLastError(); AfxMessageBox("Failed loading1"); } //(hDll should not be NULL here) typedef void (avcodec_init)(); avcodec_init* p = (avcodec_init*)GetProcAddress(hDll, "avcodec_init"); if(p==NULL) AfxMessageBox("Failed loading2"); p(); FreeLibrary(hDll); HMODULE hDll3 = LoadLibrary("libavcodec.dll"); typedef void (avcodec_find_encoder)(int CODECID); avcodec_find_encoder* p3 = (avcodec_find_encoder*)GetProcAddress(hDll3, "avcodec_find_encoder"); if(p3==NULL) AfxMessageBox("Failed loading3"); p3(CODEC_ID_MP2); if(p3==NULL) AfxMessageBox("Failed loading3"); FreeLibrary(hDll3); codec=(AVCodec *)p3; HMODULE hDll4 = LoadLibrary("libavcodec.dll"); //(hDll should not be NULL here) typedef void (avcodec_alloc_context)(); avcodec_alloc_context* p4 = (avcodec_alloc_context*)GetProcAddress(hDll4, "avcodec_alloc_context"); if(p4==NULL) AfxMessageBox("Failed loading4"); p4(); FreeLibrary(hDll4); avctx=(AVCodecContext *)p4; avctx->bit_rate=64000; avctx->sample_rate=44100; avctx->channels=2; HMODULE hDll2 = LoadLibrary("libavcodec.dll"); //(hDll should not be NULL here) typedef int (avcodec_open)(AVCodecContext *avctx, AVCodec *codec); avcodec_open* p2 = (avcodec_open*)GetProcAddress(hDll2, "avcodec_open"); if(p2==NULL) AfxMessageBox("Failed loading2"); p2((AVCodecContext *)p4,(AVCodec *)p3); FreeLibrary(hDll2);
Can somebody point out the error of my ways??
Thank you so much![]()
+ Reply to Thread
Results 1 to 1 of 1
Similar Threads
-
Need aacenc32.dll & aac.dll for be light
By tofuguy in forum AudioReplies: 5Last Post: 30th Oct 2011, 18:58 -
Problem with libavcodec.dll
By Mitchum22 in forum Newbie / General discussionsReplies: 8Last Post: 31st Mar 2011, 09:15 -
MeGui -> Unable to locate libsndfile-1.dll and FFTW3.DLL
By whatever911 in forum Video ConversionReplies: 0Last Post: 21st Feb 2009, 14:34 -
FreeEnc can't find libavcodec
By zakman in forum Video ConversionReplies: 2Last Post: 31st Jan 2009, 08:38 -
Nero 7 installed but no aac.dll or aacenc32.dll?
By AndyD in forum AudioReplies: 5Last Post: 13th Jan 2008, 18:28