A dynamic library written in C++ with API for most of the main tasks with FFmpeg. Much faster for your GUI interfaces than using processes.
Running on Windows.
Running on GNU/Linux.
Need Clang:
winget install --id=MartinStorsjo.LLVM-MinGW.UCRT -e
Invoke-WebRequest -Uri "https://bit.ly/libffppwin" -OutFile "libffppwin.rar"-
Unzip(
.rar) -
Enter the folder
cd .\libffppwin- Create basic code, example:
main.cpp
#include "ffpp/ffpp.hpp"
#include <memory>
int main(){
auto ffpp = std::make_unique<FFPP>();
std::cout << "Duration: "
<< ffpp->ffpp_info(FFPP_INFO::DURATION, "video.mp4") << '\n';
}If you want, use this video as an example: video.mp4
- Build and run:
# PowerShell
pwsh build.ps1 main.cpp # Or more files
# Or: Windows PowerShell
powershell build.ps1 main.cpp # Or more files
# Or directly
.\build.ps1 main.cpp # Or more filesIf Windows Defender prevents it from running, give permission to run the script:
pwsh -ExecutionPolicy Bypass -File build.ps1 main.cpp # Or more filesThe build.ps1 script compiles and runs the built binary, the output provides information on the video duration, for example: Duration: 00:00:05
If you want to download libffmpeg, build the dll from scratch, see this file: build-win.md.
Dependencies:
sudo pacman -S gcc ffmpeg make cmake pkg-config gitsudo apt install build-essential ffmpeg make cmake pkg-config gitRun all command below:
git clone https://github.com/terroo/ffpp
cd ffpp
cmake . -B build
cmake --build build
sudo cmake --install build
# Important pos install
# Similar to this: export LD_LIBRARY_PATH=/usr/local/lib
# But for the entire system:
echo /usr/local/lib | sudo tee /etc/ld.so.conf.d/ffpp.conf
sudo ldconfigCreate basic code, example: main.cpp
#include <ffpp/ffpp.hpp>
#include <memory>
int main(){
auto ffpp = std::make_unique<FFPP>();
std::cout << "Duration: "
<< ffpp->ffpp_info(FFPP_INFO::DURATION, "video.mp4") << '\n';
}If you want, use this video as an example: video.mp4
- Build and run:
g++ main.cpp -lavformat -lavcodec -lavutil -lswscale -lffpp
./a.outExample output:
Duration: 00:00:05.
Assuming you created the object in heap(auto ffpp = std::make_unique<FFPP>();).
ffpp->ffpp_convert("video.mp4", "new.wmv");Only converts between video extensions:
.mp4,.flv,.wmvand.mov
ffpp->ffpp_extract_frames("video.mp4", "my_frames_dir");
.ppmimages will be generated in the folder provided: (my_frames_dir/).
std::cout << "Duration: "
<< ffpp->ffpp_info(FFPP_INFO::DURATION, "video.mp4") << '\n';
std::cout << "Bitrate: "
<< ffpp->ffpp_info(FFPP_INFO::BITRATE, "video.mp4") << '\n';
std::cout << "FPS: "
<< ffpp->ffpp_info(FFPP_INFO::FPS, "video.mp4") << '\n';
std::cout << "Audio frequency: "
<< ffpp->ffpp_info(FFPP_INFO::AUDIO_FREQUENCY, "video.mp4") << '\n';
std::cout << "Resolution: "
<< ffpp->ffpp_info(FFPP_INFO::RESOLUTION, "video.mp4") << '\n'; ffpp->ffpp_cut("video.mp4", "00:00:10", 6, "output.mp4");The cut starts after 10 seconds of the video and will last 6 seconds.
There will be more features in the API in the future. If you want to submit a PR, feel free!

