windows 10 vscode cmake ffmpeg SDL2 环境搭建

学习目标:

  • 最简单的基于FFmpeg的视频播放器系列文章列表

https://blog.csdn.net/leixiaohua1020/article/details/8652605#t3 


学习内容:

1 搭建 windows 10 vscode cmake ffmpeg 开发环境  参见 CSDN


 2 添加 SDL2

        2.1 下载SDL2  Simple DirectMedia Layer - SDL version 2.0.22 (stable)

windows 10 vscode cmake ffmpeg SDL2 环境搭建_第1张图片

         2.2 修改cmakefiles.txt

cmake_minimum_required(VERSION 3.4.0)
project(video VERSION 0.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

cmake_policy(SET CMP0074 NEW)
#set(FFMPEG_ROOT "D:\\lib_for_vnc\\ffmpeg-4.4")
set(FFMPEG_ROOT "D:\\lib_for_vnc\\ffmpeg-n4.4.2-2-g7ffb7d4b04-win64-lgpl-shared-4.4")
#set(FFMPEG_ROOT "D:\\lib_for_vnc\\ffmpeg-n5.0-latest-win64-lgpl-shared-5.0")
find_package(FFMPEG COMPONENTS avcodec avutil  avformat   swscale)
include_directories(${FFMPEG_INCLUDE_DIRS}) 
message(STATUS ${FFMPEG_LIBRARIES}) 

set(SDL2_LIBRARY "D:/lib_for_vnc/SDL2-2.0.22/x86_64-w64-mingw32/lib")
include_directories("D:\\lib_for_vnc\\SDL2-2.0.22\\x86_64-w64-mingw32\\include")


include(CTest) 
enable_testing()

add_executable(video main.cpp) 

target_link_libraries(video ${FFMPEG_LIBRARIES} mingw32 ${SDL2_LIBRARY}/libSDL2main.a ${SDL2_LIBRARY}/libSDL2.dll.a )

#target_link_libraries(hello ${jpeg_lib} ${GTK2_LIBRARIES})  
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 
include(CPack) 

测试文件:


#include 
extern "C"{
    #include 
    #include 
    #include 
	#include 
	#include 
}
#include 
#include 
#include 
#include 

// Refresh Event
#define SFM_REFRESH_EVENT (SDL_USEREVENT + 1)
#define SFM_BREAK_EVENT (SDL_USEREVENT + 2)

int thread_exit = 0;
int thread_pause = 0;

int sfp_refresh_thread(void *opaque)
{
    thread_exit = 0;
    thread_pause = 0;
    while (!thread_exit)
    {
        if(!thread_pause)
        {
            SDL_Event event;
            event.type = SFM_REFRESH_EVENT;
            SDL_PushEvent(&event);
        }
        SDL_Delay(40);
    }
    thread_exit = 0;
    thread_pause = 0;
    // Break;
    SDL_Event event;
    event.type = SFM_BREAK_EVENT;
    SDL_PushEvent(&event);
    return 0;
}

int main(int argc, char *argv[]

你可能感兴趣的:(vscode,ide,编辑器)