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
VS configure vlc development environment
Which version of VS is fine, preferably VS2013 and above, I use VS2019
Download vlc source code
Click on the download address to choose win64/win32
, I chose to win64
download the one ending in .7z, and I downloadedvlc-2.2.4-win64.7z
After downloading and decompressing, it looks like this
Find the sdk folder after decompression, this folder is very important
Create a vlc environment
Open VS2019 and create a new console application project
- Adjust the project properties to Debug x64 mode (I downloaded the 64-bit version), as shown in the figure below
- Open the project-project properties window, add the sdk\include in the vlc file directory you unzipped to the "additional include directory" under the C/C++ option
- Add the sdk\lib in the vlc file directory you unzipped to the "additional library directory" under the linker options
- Finally, copy the plugins folder in the vlc file directory and the two files libvlc.dll and libvlccore.dll to the \x64\Debug directory of your project. If there is no such directory, first menu bar -> generate -> generate solution, the directory will be there
- Remember to turn off the SDL security check
The development environment configuration under vlc VS is complete
Test vlc code
#include <Windows.h>
#include "vlc/vlc.h"
#pragma comment(lib,"libvlc.lib")
#pragma comment(lib,"libvlccore.lib")
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] = "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;
}
Run the vlc program
operation result:
Complete project file acquisition
Follow WeChat public account [Programming Learning Base] , Send keywords vlcObtain