学习课题:逐步构建开发播放器【QT5 + FFmpeg6 + SDL2】
环境配置
我这边的是使用macOS;IDE用的是CLion;CMake构建,除了创建项目步骤、CMakeLists文件有区别之外的代码层面不会有太大区别。
配置上只添加一下CMakeLists中FFmpeg和SDL的配置就可以了
FFmpeg配置
include_directories(./ffmpeg6.0/include)
link_directories(./ffmpeg6.0/lib)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -stdlib=libc++ -framework OpenGL -framework AppKit -framework Security -framework CoreFoundation -framework CoreVideo -framework CoreMedia -framework QuartzCore -framework CoreFoundation -framework VideoDecodeAcceleration -framework Cocoa -framework AudioToolbox -framework VideoToolbox -framework OpenCL ")
# for macos
# target_link_libraries 内添加libavformat.a libavcodec.a libavutil.a libswscale.a swresample liblzma.tbd libz.1.2.5.dylib libbz2.dylib libiconv.dylib
SDL配置
include_directories(./SDL2/include/SDL2)
link_directories(./SDL2/lib)
# target_link_libraries 内添加libSDL2.a
最终CmakeLists(根据自己系统环境进行修改)
cmake_minimum_required(VERSION 3.26)
project(SimplePlayer)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
include_directories("./")
set(CMAKE_PREFIX_PATH "/usr/local/Cellar/qt@5/5.15.10_1")
# ffmpeg path
include_directories(./ffmpeg6.0/include)
link_directories(./ffmpeg6.0/lib)
# sdl path
include_directories(./SDL2/include/SDL2)
link_directories(./SDL2/lib)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -stdlib=libc++ -framework OpenGL -framework AppKit -framework Security -framework CoreFoundation -framework CoreVideo -framework CoreMedia -framework QuartzCore -framework CoreFoundation -framework VideoDecodeAcceleration -framework Cocoa -framework AudioToolbox -framework VideoToolbox -framework OpenCL ")
find_package(Qt5 COMPONENTS
Core
Gui
Widgets
REQUIRED)
add_executable(SimplePlayer main.cpp)
target_link_libraries(SimplePlayer
Qt5::Core
Qt5::Gui
Qt5::Widgets
libavformat.a libavcodec.a libavutil.a libswscale.a
swresample
liblzma.tbd
libz.1.2.5.dylib
libbz2.dylib
libiconv.dylib
# sdl2
libSDL2.a
)
导入方式
# FFmpeg
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavfilter/avfilter.h"
#include "libavformat/avformat.h"
#include "libavutil/avassert.h"
#include "libavutil/ffversion.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/time.h"
#include "libswresample/swresample.h"
#include "libswscale/swscale.h"
#include "libavutil/audio_fifo.h"
}
# SDL2
#include "SDL.h"
原文地址:https://blog.csdn.net/xyl192960/article/details/134606662
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_21460.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。