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
Thread: libavcodec.dll in VC++
Thread
-
Similar Threads
-
FreeEnc can't find libavcodec
By zakman in forum Video ConversionReplies: 2Last Post: 31st Jan 2009, 08:38 -
Problem with libavcodec.dll
By Mitchum22 in forum Newbie / General discussionsReplies: 3Last Post: 30th Aug 2008, 13:28 -
Libavcodec has been miscompiled (ffmpeg)
By thymej in forum Video ConversionReplies: 10Last Post: 19th Jan 2007, 22:52 -
How to use avcodec.dll,avformt.dll & avutil.dll in VB
By nee1709 in forum ProgrammingReplies: 0Last Post: 10th Jan 2007, 17:28 -
libavcodec
By leo77 in forum ProgrammingReplies: 3Last Post: 13th May 2005, 05:28
-



I 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.
Quote