> 文章列表 > FFmpeg基础

FFmpeg基础

FFmpeg基础

FFmpeg介绍

FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。

FFmpeg在Linux平台下开发,但它同样也可以在其它操作系统环境中编译运行,包括Windows、Mac OS X等。这个项目最早由Fabrice Bellard发起,2004年至2015年间由Michael Niedermayer主要负责维护。许多FFmpeg的开发人员都来自MPlayer项目,而且当前FFmpeg也是放在MPlayer项目组的服务器上。项目的名称来自MPEG视频编码标准,前面的"FF"代表"Fast Forward"。 FFmpeg编码库可以使用GPU加速。【----摘自百度百科】

目前已经迭代到FFmpeg5.1 version。

官网:http://ffmpeg.org/

FFmpeg编译与调试

Mac平台编译

  • 历史版本下载:http://www.ffmpeg.org/releases/
  • 依赖库:pkg-config、nasm、yasm、cmake、sdl
  • 编译(链接需要的库)
   ./configure --enable-libx264 --enable-libx265 --enable-openh264 --enable-gplmake -j 8sudo make install

调试

  • Mac平台xcode调试

参考:https://blog.csdn.net/yanceyxin/article/details/88820851

  • Mac平台vscode调试
先编译ffmpeg:
./configure --enable-debugmake -j8
然后配插件:组合键“shift+command+X”或者直接搜插件,出入“c/c++”、“c/c++ clang command adapter”,重启生效;组合件“shift+command+D”(或者直接左边按键),跳转到调试页面,选择c++(GDB/LLDB)环境弹出launch.json 文件,修改如下:其中program是要调试的运行程序,args是命令行参数,preLaunchTask是编译的任务名称;按下组合键“⇧⌘B(shift+command+B)”,点击"没有找到要运行的生成任务。配置生成任务…",点击"使用模版创建task.json文件",点击"Others运行任意外部命令的示例",弹出task.json,修改如下: 在对应源码里可以打断点进行调试;

FFmpeg的组成

FFMpeg的框架基本组成主要有AVFormat、AVCodec、AVFilter、AVDevice、AVUtil等几个模块库组成,还包括一些其他doc、tools、swresample、swscale、postproc等部分。

├── CONTRIBUTING.md
├── COPYING.GPLv2
├── COPYING.GPLv3
├── COPYING.LGPLv2.1
├── COPYING.LGPLv3
├── CREDITS
├── Changelog
├── INSTALL.md
├── LICENSE.md
├── MAINTAINERS
├── Makefile
├── README.md
├── RELEASE
├── VERSION
├── compat
├── configure
├── doc
├── ffbuild
├── fftools
├── libavcodec
├── libavdevice
├── libavfilter
├── libavformat
├── libavresample
├── libavutil
├── libpostproc
├── libswresample
├── libswscale
├── presets
├── tests
└── tools

FFmpeg基础

AVFormat

libavformat is a library containing demuxers and muxers for multimedia container formats.
封装模块,包括MP4、FLV、TS等文件封装格式,也包括RTMP、RTSP、HLS等网络协议封装格式。

AVCodec

libavcodec is a library containing decoders and encoders for audio/video codecs.
编解码模块。

AVFilter

libavfilter is a library containing media filters.
滤镜模块。

AVDevice

libavdevice is a library containing input and output devices for grabbing from and rendering to many common multimedia input/output software frameworks, including Video4Linux, Video4Linux2, VfW, and ALSA.
设备输入输出模块。

AVUtil

libavutil is a library containing functions for simplifying programming, including random number generators, data structures, mathematics routines, core multimedia utilities, and much more.
基础功能模块,一般其他模块都依赖它。

swscale

libswscale is a library performing highly optimized image scaling and color space/pixel format conversion operations.
图像采样和颜色格式转化模块。

swresample

libswresample is a library performing highly optimized audio resampling, rematrixing and sample format conversion operations.
音频重采样、重矩阵和采样格式转化模块。

FFmpeg命令行使用

参考:https://blog.csdn.net/yanceyxin/article/details/126453647