Article Directory
Introduction
- VLC is a free and open source cross-platform multimedia player and framework that can play most multimedia files, as well as DVD, audio CD, VCD and various streaming media protocols.
- Since VLC is completely open source, we can obtain all the project source code and carry out secondary development on this basis
VLC official website: http://www.videolan.org/
VLC source code download address: http://download.videolan.org/pub/videolan/vlc/2.2.4/
The test code refers to Raytheon's blog: http://blog.csdn.net/leixiaohua1020/article/details/42363079
Qt configuration vlc environment
Download vlc source code
Click the download address to choose win64/win32
, I chose to win64
download the end of .7z, I downloaded the vlc-2.2.4-win64.7z
following after downloading and decompressing,
and finding the sdk folder after decompressing, this folder is very important
simple_libvlc_qt_player
Submit the code for the first time, the simplest libvlc player
-
Create a console project (refer to the qt environment construction tutorial )
-
Configuration
.pro
file
Add the following code at the bottom
win32{
INCLUDEPATH += $$PWD/sdk/include
LIBS += -L$$PWD/sdk/lib -llibvlc -llibvlccore
}else{
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib -lvlc -lvlccore
}
- Configure SDK
Copy the decompressed sdk folder to the main.cpp folder to
see the test codesimple_libvlc_qt_player
Run the result to play cuc_ieschool.flv
this video
- Test code
#include <QCoreApplication>
#include <Windows.h>
#include "vlc/vlc.h"
using namespace std;
int main(int argc, char* argv[])
{
libvlc_instance_t* inst;
libvlc_media_player_t* mp;
libvlc_media_t* m;
libvlc_time_t length;
int width;
int height;
int wait_time = 5000;
const char* version;
version = libvlc_get_version();
printf("version: %s\n", version);
inst = libvlc_new(NULL, NULL);
char filename[1024] = "../simple_libvlc_qt_player/cuc_ieschool.flv";
//m = libvlc_media_new_location (inst,"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov" );
m = libvlc_media_new_path (inst,filename);
mp = libvlc_media_player_new_from_media(m);
libvlc_media_release(m);
libvlc_media_player_play(mp);
//wait until the tracks are created
_sleep(wait_time);
length = libvlc_media_player_get_length(mp);
width = libvlc_video_get_width(mp);
height = libvlc_video_get_height(mp);
printf("Stream Duration: %ds\n", length / 1000);
printf("Resolution: %d x %d\n", width, height);
//Let it play
_sleep(length - wait_time);
// Stop playing
libvlc_media_player_stop(mp);
libvlc_media_player_release(mp);
libvlc_release(inst);
return 0;
}
- Program release
On
simple_libvlc_qt_player
to publish a release folder inside the dynamic link library into the packed program directory folder
project address
GitHub project address: https://github.com/ADeRoy/libvlc_qt_demo
If it helps you, you can give a star