libvlcpp is a header-only, modern C++ wrapper around libvlc, the cross-platform multimedia API powering VLC media player. It is the official VideoLAN C++ binding and runs everywhere libvlc does.
The wrapper is intentionally thin: it adds RAII lifetime management, type safety and C++ interfaces on top of libvlc, while mapping closely to the underlying C API.
- Header-only: just needs to be added to your include path.
- RAII: handles are reference-counted and released automatically.
- C++11: works with any reasonably modern compiler and standard library.
- Cross-platform: across all libvlc supported platforms.
- A C++11-capable compiler.
- libvlc development files (
libvlc-devor equivalent), version 3.0 or later.
libvlcpp was originally designed to be retro-compatible across libvlc versions. However, libvlc 4 introduced a large number of fundamental breaking changes to the API, so support is now split across two branches:
| Branch | libvlc version | Status |
|---|---|---|
3.0.x |
libvlc 3 | Stable |
master |
libvlc 4 | In development |
Pick the branch matching the libvlc you build against.
Since libvlcpp is header-only, the simplest integration is to add the repository to your include path and include the main header:
#include <vlcpp/vlc.hpp>
#include <thread>
int main(int argc, char** argv)
{
auto instance = VLC::Instance(0, nullptr);
auto media = VLC::Media(argv[1], VLC::Media::FromPath);
auto player = VLC::MediaPlayer(instance, media);
player.play();
std::this_thread::sleep_for(std::chrono::seconds(10));
player.stopAsync();
return 0;
}Link the resulting program against libvlc (for example pkg-config --libs libvlc).
libvlcpp ships with Meson and can be consumed as a subproject. Drop a
wrap file in subprojects/ and pull in the dependency:
libvlcpp_dep = dependency('libvlcpp')
executable('myplayer', 'main.cpp', dependencies: libvlcpp_dep)The dependency transitively provides libvlc, so no further wiring is needed.
More complete samples live in the examples folder, including
helloworld, in-memory input and renderer
discovery.
libvlcpp closely mirrors libvlc, so its documentation is your primary reference alongside the wrapper headers themselves. See the libvlc documentation.
Contributions are always welcome! Tickets and merge requests are handled on our GitLab:
libvlcpp is used and tested extensively across VideoLAN projects, such as the medialibrary and the former VLC for UWP app, among others.
libvlcpp is released under the LGPL-2.1-or-later license. See COPYING for details.