Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize multi-grid by FFmpeg

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

This article introduces you how to achieve FFmpeg multi-grid, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Let's use the FFmpeg command line to achieve the multi-grid effect of the picture! When it comes to the multi-grid, I believe our first reaction is the nine-grid, but because using the FFmpeg command line to achieve the parameters of the nine-grid is really too bloated, the effect of realizing the four-grid in our case is cool enough! All right, let's get back to business:

Command line parameters

Ffmpeg-re-I test.mp4-filter_complex "nullsrc=size=1920x1080 [base]; [0VV] setpts=PTS-STARTPTS,scale=960x540 [upperleft]; [1test.mp4 v] setpts=PTS-STARTPTS,scale=960x540 [upperright]; [2test.mp4 v] setpts=PTS-STARTPTS,scale=960x540 [lowerleft]; [3test.mp4 v] setpts=PTS-STARTPTS,scale=960x540 [lowerright]; [base] [upperleft] overlay=shortest=1 [tmp1]; [tmp1] [upperright] overlay=shortest=1:x=960 [tmp2] [tmp2] [lowerleft] overlay=shortest=1:y=540 [tmp3]; [tmp3] [lowerright] overlay=shortest=1:x=960:y=540 "- CVR v libx264 out_ 1080p.mp4II, parameter interpretation-re-I: in the process of implementing multiple grids, this means multiple inputs, followed by the video file name.

-filter_complex: indicates the use of a composite filter, followed by the specific parameters of the filter in quotation marks

Nullsrc: understand it as a canvas, that is, we want to draw all the videos on the canvas and specify its size in the parameters.

[upperleft]: indicates the parameter of the nth video, setpts indicates the setting method of pts, scale indicates the zoom size of the video, and [upperleft] indicates the tag corresponding to the nth video. In this case, n is 0min1, 1, 2, 3 next, please take a closer look:

First of all, add the content of [upperleft] to [base], and use the overlay filter to create a new tag tmp1 when the filter superimposed starting position is (0memo) (left empty defaults to origin).

Based on [tmp1], use overlay to stack with [upperright] again to generate the tag [tmp2].

Based on [tmp2], use overlay with [lowerleft] to generate tags [tmp3]; based on [tmp3], use overlay with [lowerright] to stack again, and all four tags are built. -CRARV points out how to encode the synthesized video. 3. In actual combat, due to the bloated parameters, it will not be typed one by one. Let's take a look at the effect of the command execution:

Fourth, the effect is good, this is the end of today's issue, welcome friends to come next time, and don't forget to practice a lot! On how to achieve FFmpeg multi-grid to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Parameters videos tags content commands effects filters overlay again bloated next ninth house size guys buddies ways more canvas help good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft NVidia Huawei OPPO Reno MariaDB