Ffmpeg-doc-cn-03.md

Source: Internet
Author: User

3 Detailed description

ffmpegEach conversion process is like a description of the program

 _______              ______________|            |              | ||  Input | Demuxer |   Encoded Data | decoder| File | ---------> | Packets |            -----+|_______|      |______________|                                           |         V _________ |                                      | |                                      decoded | |                                      Frames | |_________|        ________             ______________       ||           |              |      | || Output | <--------| Encoded Data | <----+|   File | Muxer |   Packets |           encoder|________| |______________|

ffmpegThe Call libavformat library (with separators) reads the input file, separating out the various encoded packets (streams), and ffmpeg attempting to trace the minimum timestamp for any input stream synchronization when there are multiple input files. Encode the packet (unless it is specified as a streaming copy, refer to the description of the feature description convection copy) decode the uncompressed data frame by decoder (RAW video/PCM format Audio ... ), these data frames can be further processed by the filter (described below). The filter-processed data is re-encoded into a new packet (stream), which is then mixed with the mixer (for example, by combining the audio packet and the video packet in a certain order and proportion) and writing to the output file.

Filter Handling/filtering

ffmpegRaw (Real/original) audio and video can be libavfilter processed using the filters in the library before encoding. Multiple filters can form a filter chain diagram (filter chain filtergraphs). ffmpegIt appears that there are only 2 filters: Simple filter, composite filter.

Simple filters

A simple filter is a filter with only 1 inputs and outputs, and the data on both sides of the filter is of the same type, which can be understood as simply attaching a step before the uncompressed data frame to re-encode:

 _________                        ______________|         |                      |              || decoded |                      | encoded data || frames  |\                   _ | packets      ||_________| \                  /||______________|             \   __________   /  simple     _\||          | /  encoder  filtergraph   | filtered |/                | frames   |                |__________|

Simple filters are typically used to configure each flow-filter option (-VF and-AF correspond to video and audio respectively). One of the simplest video filters is as follows:

 _______        _____________        _______        ________|       |      |             |      |       |      |        || input | ---> | deinterlace | ---> | scale | ---> | output ||_______|      |_____________|      |_______|      |________|

Note that some filters change the frame properties rather than the frame contents. For example, the FPS filter mentioned above only causes the frame rate to change, but does not process the frame content, another example is that setpts only sets the timestamp, the frame content of the filter does not change completely.

Composite Filter

Composite filters are those cases where a linear process cannot be described as being applied to a stream, such as when there are multiple inputs and/or outputs in the process, or when the output stream type differs from the input, as follows:

 _________| || Input 0 |\ __________|_________|          \                  |             | \   _________    /|              Output 0 |         \ |  | / |__________| _________     \| Complex |         /|     |         | |/| Input 1 |---->| Filter | |     _________|         | | \   __________               /|  Graph |          \ |              |         / |   | \| Output 1 |    _________   /  |_________|         |__________|| | /| Input 2 |/|_________|  

composite filter by -filter_complex option is set. Note This is a global option because a composite filter must not be associated with only one single stream or file. -LAVFI option is equivalent to -filter_complex

A simple example of a composite filter is a overlay filter that overlays a video onto an output from two inputs. The corresponding audio filter is amix .

Stream copy

Stream copy is a pattern that replicates only the specified stream data 拷贝(copy) . In this case ffmpeg , the specified stream is not decoded and encoded, but only the packets are detached and mixed. This pattern is often used to convert or modify some metadata information in a file wrapper format, which is simply illustrated below:

 _______              ______________            ________|       |            |              |          |        || input |  demuxer   | encoded data |  muxer   | output || file  | ---------> | packets      | -------> | file   ||_______|            |______________|          |________|

Because there is no decoding and encoding process in this mode, it is also very fast and does not cause new loss of quality. However, this also makes the pattern unsuitable for many job requirements, such as the ability to use a large number of filters in this mode, because the filter can only process uncompressed (encoded) data.

Ffmpeg-doc-cn-03.md

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.