ffmpeg-tutorials icon indicating copy to clipboard operation
ffmpeg-tutorials copied to clipboard

Examples and tutorials for FFmpeg

FFmpeg Examples

包括 解 / 编码(复杂)滤波器屏幕 / 摄像头 / 音频捕获音视频播放 的基础示例以及相关教程。

Examples and tutorials for decoding / encoding, (complex) filtering, screen, camera, and audio capture, audio / video playing, etc.

Examples

  • [x] remuxing
  • [ ] transcoding
  • [x] camera / screen / microphone recording
  • [ ] simple filter
  • [ ] complex filter
  • [x] generating high quality GIF
  • [ ] audio player with Qt
  • [x] video player with Qt
  • [ ] media player with Qt (syncing audio and video)
  • [x] RTMP Streaming
  • [ ] hardware acceleration

Platform Specific

  • [ ] Windows - WASAPI : audio capture
  • [ ] Windows - WASAPI : audio rendering
  • [ ] Windows - Windows Graphics Capture : screen capture
  • [ ] Linux - PulseAudio : audio capture
  • [ ] Linux - V4L2 : camera capture
  • [ ] Windows - DirectShow : camera capture

Installation

Windows

Windows Graphics Capture 示例需要较高的Windows版本:

  • Windows Version >= 10.0.17134.48 (aka Windows 10 Version 1803)
  • Windows SDK Version >= 10.0.20348.0
  • FFmpeg >= 6.0

如果你的Windows或SDK不能满足要求,你可以选择:

  • 通过 -DDISABLE_WGC=ON 来禁用 Windows Graphics Capture 示例
  • 通过 Visual Studio Installer 安装最新的 Windows SDK

FFmpeg

Version : > 4.3 (-DDISABLE_WGC=OFF : >= 6.0)

  • Windows builds: 注意下载shared版本,添加到环境变量
  • Build from source

Qt5

6.0 > Version >= 5.12

  • Download: 安装后注意添加目录到环境变量

Ubuntu

sudo apt install build-essential git cmake

sudo apt install ffmpeg libavfilter-dev libavdevice-dev libavutil-dev libavformat-dev libswresample-dev libswscale-dev

# Ubuntu 20.04 
sudo apt install qt5-default libqt5x11extras5-dev qtmultimedia5-dev
# Ubuntu 22.04
sudo apt install qtbase5-dev libqt5x11extras5-dev qtmultimedia5-dev

# pulse
sudo apt install libpulse-dev

# v4l2
sudo apt install libv4l-dev v4l-utils

# for error: GL/gl.h: No such file or directory
sudo apt install mesa-common-dev

C++ & CMake

  • C++ 20
  • CMake >= 3.16

Other dependencies

No installation required

  • glog: Google Logging (glog) is a C++98 library that implements application-level logging. The library provides logging APIs based on C++-style streams and various helper macros.
  • fmt: {fmt} is an open-source formatting library providing a fast and safe alternative to C stdio and C++ iostreams.

Usage

git clone https://github.com/ffiirree/ffmpeg_examples.git --recursive

# 或者单独获取子模块
git submodule init
git submodule update

References