What i want to do is to make a sample application using msvc++ which will take input as a video file and decode it. I want all the decoding to be done using ffmpeg functions used in my application.I read dranger's tutorial but could not implement it, any help would be really appreciated.
1 Answers
You have two options:
- you can build the source code yourself.
- you can download an "already builded version" with dlls.
If I were you, I would have chosen the second option. It was what I have had done when I started to experiencing with ffmpeg. Building can be a pain if you have never built a source code.
You can find latest ffmpeg builds from here (You should download the "dev" version).
Put this file inside VisualStudio20xx/Projects/yourProjectName/yourProjectName/
After downloading you should show MSVC the destination of headers & the .lib files. Go to Project -> Properties -> Configuration Properties -> C/C++ -> General then set the "Additional Include Directories" to ffmpeg/include
This should set the include files for ffmpeg.
For .lib files:
Project -> Properties -> Configuration Properties -> Linker -> General set "Additional Library Directories" to ffmpeg/lib
This should set the .lib files.
Now should be able to include ffmpeg libraries by
extern "C"
{
#include <libavcodec/avcodec.h>
}
*(!) If you get a thousands of LNK2001 linker errors after these steps, you should add some pragma comments for your includes. I am not %100 sure what do these comments do, you can search it. But it is something for MSVC to understand stuff.
For example,
#pragma comment (lib,"avcodec.lib")
this pragma comment too, should be in extern "C" scope.
*(!)If you get this compile error : 'UINT64_C': identifier not found
You can use this macro as a workaround:
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
Now about the encode/decode stuff, you can check this question of mine which contains a code that
- demuxes the file into packets
- decodes the packets into frames
- encodes the frames into packages
- muxes packets into a file.
I learnt from hard way but the code is well-commented therefore I think you can understand what/how exactly it does to overcome the process.