|
I think he's shooting in the dark!
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
VuNic wrote: I think he's shooting in the dark!
Mostly
ffmpeg was written for LINUX. All I am trying to do is create a simple application that will encode audio/video files. Trying this with the dlls.
|
|
|
|
|
Quoting from the apiexample.c
AVCodec *codec;<br />
AVCodecContext *c= NULL;<br />
int frame_size, i, j, out_size, outbuf_size;<br />
FILE *f;<br />
short *samples;<br />
float t, tincr;<br />
uint8_t *outbuf;<br />
<br />
codec = avcodec_find_encoder(CODEC_ID_MP2);<br />
c= avcodec_alloc_context();<br />
<br />
c->bit_rate = 64000;<br />
c->sample_rate = 44100;<br />
c->channels = 2;
This is what I am trying to re-write.
This is how alloc_code_context is defined in the .h file
AVCodecContext *avcodec_alloc_context(void);
I just tried this
typedef AVCodecContext*(avcodec_alloc_context)(); and I didnt have any errors.It ran perfectly.
Though yes, there is something about memory leaks.Thank you so much for the heads-up
|
|
|
|
|
It seems that you didn't read properly everything I wrote . Or you didn't understand. Basically, it's exactly what I'm trying to say till the begining: that you have to use the exact prototype for the typedef (so, with return type and parameters).
Anyway, why don't you focus on your main problem ? Which is these link errors you get when you use the header and the lib ? Did you even try that ? Are you sure you properly linked to the library ?
Please when answering, read at least my post and answer the questions I ask (there is a reason for which I ask these, even if this is pretty obscure to you).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
I am so sorry.
I tried the typedef AVCodecContext* thingy based on your post except that I didnt quote it in my reply.
I believe I am properly linked to the library files. These are the steps I followed
In the project Properties Select C/C++ General Tab
and set the path for 'Include directories' seperated by semicolon( i.e path to libavcodec, libavformat)
In the Linker Tab put the path to Lib files of ffmpeg in the option 'Additional Library Directories path' (i.e the path to avformat.lib etc)
In the Linker Tab Put the Library files names to the option 'Additional dependencies' ( avformat.lib avcodec.lib)
These are the linker errors I am getting
fflib2 error LNK2001: unresolved external symbol ___divdi3
fflib2 error LNK2001: unresolved external symbol ___divdi3
fflib2 error LNK2019: unresolved external symbol ___divdi3 referenced in function _av_reduce
fflib2 error LNK2001: unresolved external symbol ___divdi3
fflib2 error LNK2001: unresolved external symbol ___divdi3
fflib2 error LNK2001: unresolved external symbol ___divdi3
fflib2 error LNK2019: unresolved external symbol ___moddi3 referenced in function _av_reduce
fflib2 error LNK2001: unresolved external symbol ___moddi3
fflib2 error LNK2001: unresolved external symbol ___moddi3
fflib2 error LNK2001: unresolved external symbol __alloca
fflib2 error LNK2001: unresolved external symbol __alloca
fflib2 error LNK2019: unresolved external symbol __alloca referenced in function _rd8x8_c
fflib2 error LNK2001: unresolved external symbol __alloca
fflib2 error LNK2001: unresolved external symbol __alloca
fflib2 error LNK2001: unresolved external symbol __alloca
fflib2 error LNK2019: unresolved external symbol ___udivdi3 referenced in function _mpeg1_encode_sequence_header
fflib2 error LNK2019: unresolved external symbol ___udivdi3 referenced in function _MPV_common_end
fflib2 error LNK2019: unresolved external symbol ___umoddi3 referenced in function _mpeg1_encode_sequence_header
fflib2 error LNK2019: unresolved external symbol ___fixunssfdi referenced in function _ff_rate_control_init
fflib2 error LNK2019: unresolved external symbol ___fixunsdfdi referenced in function _ff_rate_estimate_qscale
p.s. Would you mind giving me your e-mail address?
|
|
|
|
|
Hmmm, strange... Are you sure you linked to all the required libraries ? Didn't you forget some ?
Is there any documentation you can read and check if you did everything properly ?
RahulOP wrote: Would you mind giving me your e-mail address?
I would prefer not to do that. Because this is a forum so if we find a solution to your problem, this can be usefull to somebody else.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Well, this is an open-source encoder/decoder. So I downloaded both a release version and the SVN version.The SVN version also contains a "libavutil" folder that isnt there in the release version. Apparently when you build the SVN version, you should get a lib for libavutil which you are supposed to link to your program.Unfortuantely I didnt get any lib only dlls for the 3 folders libavformat, libavcodec and libavutil. The documentation isnt very clear and is mostly for Linux. The release version built fine but it had only the 2 folders libavcodec and libavformat. The build on this one gave me the lib files that I am now using.
-- modified at 6:05 Wednesday 14th June, 2006
I seem to make the most irresponsible of mistakes
I formatted my system recently and hence missed out on this crucial step which I had done before the format
Add a call to `vcvars32.bat' (which sets up the environment variables for the Visual C++ tools) as the first line of `msys.bat'. The standard location for `vcvars32.bat' is `C:\Program Files\Microsoft Visual Studio8\VC\bin\vcvars32.bat', and the standard location for `msys.bat' is `C:\msys\1.0\msys.bat'. If this corresponds to your setup, add the following line as the first line of `msys.bat': call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
I have my lib files!!!! Yay!!!!!
|
|
|
|
|
All right to cut a long story short, the lib files were faulty. So I went back to Dynamic Linking.
AVCodec *codec;<br />
int i, out_size, size, x, y, outbuf_size;<br />
FILE *f; <br />
uint8_t *outbuf, *picture_buf;<br />
<br />
<br />
HMODULE hDll3 = LoadLibrary("avcodec.dll");<br />
typedef void (avcodec_find_encoder)(int CODECID);<br />
avcodec_find_encoder* p3 = (avcodec_find_encoder*)GetProcAddress(hDll3, "avcodec_find_encoder");<br />
if(p3==NULL)<br />
AfxMessageBox("Failed loading3");<br />
p3(CODEC_ID_MPEG1VIDEO);<br />
if(p3==NULL)<br />
AfxMessageBox("Failed loading3");<br />
<br />
<br />
codec=(AVCodec *)p3;<br />
<br />
HMODULE hDll4 = LoadLibrary("avcodec.dll");<br />
typedef AVCodecContext* (avcodec_alloc_context)();<br />
avcodec_alloc_context* p4 = (avcodec_alloc_context*)GetProcAddress(hDll4, "avcodec_alloc_context");<br />
if(p4==NULL)<br />
AfxMessageBox("Failed loading4");<br />
p4();<br />
if(p4==NULL)<br />
AfxMessageBox("Failed loading4");<br />
<br />
AVCodecContext *avctx = p4();<br />
<br />
avctx->bit_rate=400000;<br />
avctx->width = 352; <br />
avctx->height = 288;<br />
<br />
avctx->frame_rate = 25; <br />
avctx->frame_rate_base= 1;<br />
avctx->gop_size = 10; <br />
avctx->max_b_frames=1;<br />
<br />
HMODULE hDll2 = LoadLibrary("avcodec.dll");<br />
typedef int (avcodec_open)(AVCodecContext *avctx, AVCodec *codec);<br />
avcodec_open* p2 = (avcodec_open*)GetProcAddress(hDll2, "avcodec_open");<br />
if(p2==NULL)<br />
AfxMessageBox("Failed loading2");<br />
p2((AVCodecContext *)p4,(AVCodec*)p3);<br />
Notice the last line--p2. p2 should be of the form (avctx,codec) i.e.alloc_code_context and avcodec_find_Encoder. The problem(given my display of my knowledge of pointes, does this really surprise you?) is that I cant pass avctx and codec directly. Also, since avctx takes values like bit_rate, width,height, those have to be reflected when I open the required codec. Any ideas??
|
|
|
|
|
One thing you still didn't understand is that a line like as follow is completely wrong !!
codec=(AVCodec *)p3
Basically, p3 is a pointer to a function. The (AVCodec *) in front of it specifies that the pointer must in fact be interpreted as a pointer to a AVCodec structure. Which of course completely false. Please, take care of what I said previously !
If this function returns an AVCode pointer, then you should do this instead:
HMODULE hDll3 = LoadLibrary("avcodec.dll");
typedef (AVCode*)(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_MPEG1VIDEO);
if(p3==NULL)
AfxMessageBox("Failed loading3");
AVCodec* codec = p3(...);
Also, note that in the typedef, you specified that this function receive a integer parameter, so of course you need to supply it also (note the ... in the function call).
Next, I repeat it once again: don't call LoadLibrary multiple times for the same library, this is useless. And don't forget to call FreeLibrary after it.
For this:
RahulOP wrote: p2((AVCodecContext *)p4,(AVCodec*)p3);
This is the same as above: you cannot cast pointer to functions this way !!. What you need to do, is call p4 (and store the result somewhere, then call p3 and store the result somewhere and finally, call p2 and giving the previous results):
AVCodecContext* pContext = p4();
AVCoded* pCoded = p3(...);
p2(pContext,pCoded);
If you have problems, please update all the code with the remarks I explained here before posting another question (otherwise, I will correct the same things over and over again). If you don't understand something, ask for more information (instead of blindly copy/pasting).
Hope this helps
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Thanks!! Helps a lot!!
codec=(AVCodec *)p3 is sheer stupidity since that is the only line i wrote that way. Everything else I did exactly the way you told me.
Will be posting my complete code as soon as I iron out the bugs
|
|
|
|
|
Can you e-mail me the files? DejaVuNic -at- Gmail I'll try it a try.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
|
|
|
|
See Here[^]and Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
|
angelfirefox wrote: [Message Deleted]
[Click for User Profile] angelfirefox
you are in now Tox "NO" List!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
How to show gif in CRichEditCtrl not using third dll?
And How to change text color when inputting #G show Green Text to next # or end ?
#R Tom# says: #G Hello,#R everyone.
And when i click tom,get charactor t-o-m.
Just like a chatboard.
-- modified at 2:03 Wednesday 14th June, 2006
|
|
|
|
|
Is there any way to set where a file begins (like SetEndOfFile except that it sets the beginning of the file)? I have a situation where I need to make files smaller by deleting data from the beginning, and reading and writing all the data is very inefficient.
Thanks
|
|
|
|
|
|
_johan wrote: s there any way to set where a file begins (like SetEndOfFile except that it sets the beginning of the file)? I have a situation where I need to make files smaller by deleting data from the beginning, and reading and writing all the data is very inefficient.
I think there is no such way/method to set begins of the file.
But you can maintain your delimiter for the begining of data/file.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
All right. Thanks for the quick responses
|
|
|
|
|
hello
I have a code with VC++ which print on console,I want to show the output in listbox of MS Visual C++ windows forms appl(.NET) .could u plz tell me the solution.
Yogesh Talokar
|
|
|
|
|
The first thing about this is that you should be knowing how to handle unmanaged code from the managed code.
Second issue: Is it possible to change your application from Console to Windows Forms.
You will have to write the entire logic again if you want to do it in windows forms
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|