FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It’s not difficult to write your own simple video editor with it.
This post will give you a guide, how to write a program with FFmpeg on Windows, with Visual Studio.
Download FFmpeg library and development files
In general, for an Open Source library, we may usually need build one from source code. And on Windows, it could be kind of confusing.
Luckily, there is a nice hacker, who has built FFmpeg on Windows for us.
We can find them on https://ffmpeg.zeranoe.com/builds/.
What we need is two linking type files on Windows. So, for “Architecture”, Windows-32bits or Windows-64bits. And in linking, we need dev and shared. Shared library can proivde runtime for the compiled program, meanwhile, in dev, we will have header files and exported symbol information to use during development.
Create VS Project
Create a new Visual C++ project, do not use precompiled header file.
Then, right click on the project to open Property panel.
DLL files
Add your ffmpeg-<version>-win64-shared\bin
into your system PATH.
Include files
Add your ffmpeg-<version>-win64-dev\include
into VC++ Directory -> Include directory.
Lib files
Add your ffmpeg-<version>-win64-dev\lib
into VC++ Directory -> Reference directory.
Add swscale.lib
, avutil.lib
, avformat.lib
, avcodec.lib
, avdevice.lib
, avfilter.lib
, swresample.lib
and postproc.lib
into Linker -> Input -> Addons.
Code
This code comes from FFmpeg samples, it works as a video decoder but it just gets and prints video meta information.
1 |
|
Launch
To run it in Visual Studio, in debugging
, add the path of your video into command line arguments.
And right click on the green triangle.
In the terminal, you should be able to see the meta information like this:
1 | major_brand=mp42 |
Enjoy!