目录
前两篇文章仅仅说了视频播放,而没有加入音频,而本篇将加入音频的内容,通过ffmpeg解码音频,SDL实现音频播放
为什么选择SDL?
-
简介
SDL(Simple DirectMedia Layer)是一套使用C语言编写的开源跨平台多媒体开发库
提供了数种控制图像、声音、输出入的函数,让开发者只要用相同或是相似的代码就可以开发出跨多个平台(Linux、Windows、Mac OS X等)的应用软件
目前SDL多用于开发游戏、模拟器、媒体播放器等多媒体应用领域
-
使用SDL的好处
- 网上资料多,学习起来方便
- 跨平台,Windows、Linux、Android、IOS通吃
- 库体积相对比较小
- 应用较为广泛
SDL库下载地址:http://www.libsdl.org/
项目配置
首先在Qt Creator中新建一个C++工程项目SDLDemo
将下载好的SDL和ffmpeg拷贝到与main.cpp同级的工程目录下
在SDLDemo.pro项目配置文件中加入头文件和引入库,同时引用SDL和ffmpeg的文件
以C语言的方式添加头文件,并定义两个宏,用于后续的音频解码
加入SDL的头文件后编译