During video processing, you usually need to codec the video data. At this time, using the open-source FFMPEG video and audio processing solution is the choice of most programmers, after all, writing your own codecs is too inefficient, and in most cases it is not enough to write... However, it is only the first step to use FFMPEG, because it is quite troublesome to build the environment later.
There are two methods to build the FFMPEG Development Environment on vs. One is to download the source code from the FFMPEG official website and compile it by yourself. Its high complexity is really frustrating for me. After reading a few tutorials, I feel that I will not love it any more. Of course, if you are determined to do a great job on the video, we also recommend that you download the latest source code for research. Second, you can download the FFMPEG package that has been compiled by others and available directly on vs from the Internet, this is what I have taken and what this blog will introduce.
For this method, there are some tutorials on the Internet, but the problem is that there are many FFMPEG versions, and the general tutorial is only to provide the configuration method but not the version, as a result, the test code that follows the configuration cannot be used after the configuration is complete or is not applicable to this version, sometimes it is even worse that the code package has some functions or is useless because of the negligence of the compiler. I have been stuck in this situation for a long time. I have been using the version I downloaded for almost a year and thought it was okay, but there was a problem with the Code recently (I had been doing decoding before ), therefore, after finding and solving the problem, I decided to write this blog, introduce how to configure the environment, and add my current FFMPEG package that is no problem for the time being, in the subsequent blog posts, I will introduce some codec code I have made using the FFMPEG package of this version for your reference and correction.
How to configure FFMPEG on vs is actually very simple, and only five steps are required (I configured it on vs2013, And it is basically the same in earlier versions of ).
Step 1: Download The FFMPEG package. The address of the FFMPEG package provided by myself is shown in right: Click the open link. Decompress the downloaded package to the path you want to store it. You can store the downloaded package in the path "F: \" on the drive.
Step 2: Create a project on Vs and open the project properties page (right-click Solution Explorer and select Properties from the project name pop-up menu), as shown in:
Select: Configure properties-> C/C ++, and add the include folder path under the FFMPEG package to "add include directory" on this page (my path is F: \ ffmpeg_lib \ include), as shown in:
Select: Configure properties-> linker-> General, and add the Lib folder path under the Win32 folder under the FFMPEG package to "additional library directory" on this page (my path is F: \ ffmpeg_lib \ Win32 \ Lib), as shown in:
Step 3: Select Configuration Properties> linker> input to add swscale to "additional dependencies" on the page. LIB; avcodec. LIB; avutil. LIB; avformat. LIB; these libraries (if you want to use other libraries later, you can add them. The above four libraries can complete video encoding and decoding). The structure is shown in:
Step 4: Include the files to be used in the FFMPEG package in the header file of the project, as follows:
#ifndef INT64_C #define INT64_C(c) (c ## LL) #define UINT64_C(c) (c ## ULL) #endif #ifdef __cplusplus extern "C" {#endif /*Include ffmpeg header file*/#include <libavformat/avformat.h> #include <libavcodec/avcodec.h> #include <libswscale/swscale.h> #include <libavutil/imgutils.h> #include <libavutil/opt.h> #include <libavutil/mathematics.h> #include <libavutil/samplefmt.h>#ifdef __cplusplus }#endif
Step 5: Set the bin folder under the Win32 folder under the FFMPEG package (my path is F: \ ffmpeg_lib \ Win32 \ bin) all the DLL files in are copied to the project created by vs (if the project name is ffmpegtest, the files are copied. \ ffmpegtest folder), if you want to release it, copy it to the corresponding release folder.
OK. The configuration of FFMPEG on vs is complete. Then you can write the relevant code. I will write a blog about Video Codec in the near future. Once completed, I will add the link:
Video Encoding with FFMPEG: Click to open the link
Video decoding with FFMPEG: (incomplete)