Before using FFmpeg, we need to look at this tool, this article will introduce the use of FFmpeg, processing principle and process, as well as the commonly used three tools introduction of FFmpeg
1. What is FFmpeg
FFmpeg is both an audio and video codec tool, but also a set of audio and video codec development kit. - "FFmpeg from entry to the master."
FFmpeg command is different from here we often use ffmpeg , FFmpeg is a suite, ffmpeg as a tool it offers. FFmpeg codec as a development kit to provide developers with a rich audio and video processing interface.
FFmpeg : Fast Forward Moving Picture Experts Group
2.FFmpeg basic modules 7
- AVFormat
provide encapsulation or de-encapsulation function (Section 3 will explain about packing and unpacking), supported by the vast majority of packaging formats, such as MP4, FLV, KV, TS and other package file format, RTMP, RTSP, MMS, HLS, etc. network protocol encapsulation format. - AVCodec
provide codec functions (section 3 below will explain about the codec), to achieve the vast majority of multimedia codecs.
Support MPEG4, AAC, MJPEG codecs such as built-in media formats, and also supports H.264 (AVC) encoding - using the x264 encoder, H.265 (HEVC) coding - using the x265 encoder, MP3 (mp3lame) encoding - use libmp3lame encoder. - AVFilter
provides filter processing functions, the filter can have multiple inputs and multiple outputs, we can easily handle audio and video, subtitles, as well as some special effects - AVDevice
device module can be easily call the relevant hardware of the equipment, such as cameras. - AVUtil
tools - swresample
audio conversion calculation module, provide advanced audio resampling API. It allows operation of the audio samples, the audio channel layout conversion layout adjustment. - swscale
video image conversion calculation module that provides advanced image conversion API. It allows for image scaling and pixel format conversion.
3. Now we have to understand the two concepts
encode decode
Encapsulation, decapsulation
Before looking at these two concepts, first look ffmpeg video processing process
can be seen, the video file is to be de-encapsulated, and then decoded and then calculated. Until we, the video simple sense, in fact, a series of images arranged in sequence. Then, the process flow diagram above is actually processed for each picture. That is, the video image needs to be first encoded information, and then the package, and then written to the file.
The video encoding, decoding is actually different data structures for image compression and storage information, different codec means different quality and efficiency under different scenarios.
The package, that is, a container full bloom encoded information, MP4, AVI, FLV, etc. are. To visualize and understand coding package, a few examples below.
3.1 MP4 format AVC encoding, is converted into MP4 format, encoded schematic flow diagram of the HEVC
3.2 MP4 format AVC encoding, is converted into AVI format, AVC encoding a schematic flow
3.3 MP4 format AVC encoding, it is converted into AVI format, the HEVC encoding a schematic flow chart
continued ...