Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize video matting on FFmpeg command line

Shulou Source: shulou.com Published: 2022-06-02 01:52:36 10月03日 Update

FFmpeg command line how to achieve video matting, in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

How to use the FFmpeg command line to achieve video matting! Talk less, and then let's get down to business.

I. Preface

When it comes to matting, the first thing you may think of is the picture and the powerful PS (Photoshop). For video, you can also achieve matting, which can be achieved using the FFmpeg command line.

II. Orders

Ffmpeg-I in_1.mp4-I in_3.mp4-shortest-filter_complex "[1 out v] chromakey=red:0.3:0.9 [ckout]; [0 in_3.mp4 v] [ckout] overlay [out]"-map "[out]" output.mp4

III. Parameter interpretation

-I: specify the name of the input video file. Note that matting requires two video files.

-shortest: indicates encoding within the shortest input

-filter_complex: indicates the use of complex filters

Chromakey=red:0.3:0.9: chromakey is the core filter used in matting. The following parameters are used for matting. Interested friends can learn more chromakey chromaticity filters by themselves.

Overlay: the video of matting is combined with the destination video using overlay filter.

A description of the use of tags in the same grid.

IV. Material preparation

Two video files, one is used as the target video overlaid after matting, and the other has a more obvious background color, we matting in this video. The video used for matting measured by the author is made of two portrait photos with a red background in order to demonstrate a more intuitive effect. As shown below:

Target Video (in_1.mp4)

For matting video (in_3.mp4)

V. actual combat video

6. the effect of matting after merging.

All right, that's it for this issue, the old rule, go down and practice hard!

This is the answer to the question about how to achieve video matting on the FFmpeg command line. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Tags: Video commands filters files questions two parameters effects more goals goals help solutions input complex powerful obvious easy intuitive next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia MariaDB OPPO Reno Microsoft