ffmpeg record screen and screenshot

This article is based on the premise that ffmpeg has been downloaded and installed. It is a continuation of the previous ffmpeg download and installation tutorial and introduction_水w的博客-CSDN博客

1. Record video without sound

(1) Open cmd, enter the command,

ffmpeg -f gdigrab -i desktop -pix_fmt yuv420p .\out.mp4

(2) After the command is finished running, we find the video according to the path, open the generated video,

Note: The default save path of the generated video is in the folder where the command is located,
eg: I executed the cmd command under C:\user\water\, so the video will be saved in this path after it is generated.

2. Splicing of two videos in succession: splicing two video files back and forth into one video file

(1) Open Notepad, create a new "videolist.txt" file, which will be written in the video to be spliced,

At this point the folder structure is:

(2) Open cmd under the folder, enter the command,

ffmpeg.exe -f concat -i video/videolist.txt joinoutput.mp4

Note: I am in the D:\ffmpeg-5.0.1-essentials_build folder (the video to be spliced ​​is in the video folder under this path), open cmd, enter the command,

(3) After the command is executed, we find the video according to the path, open the generated video,

3. Two videos are played at the same time, the left and right are displayed at the same time, and the middle part is separated by a red background

(1) Open cmd, enter the command,

ffmpeg -i video\out.mp4 -i video\out1.mp4 -filter_complex "pad=4000:1080:color=red[x0];[0:v]scale=w=1920:h=1080[inn0];[x0][inn0]overlay=0:0[x1];[1:v]scale=w=1920:h=1080[inn1];[x1][inn1]overlay=2000:0" out14.mp4

(2) After the command is finished running, we find the video according to the path, open the generated video,

4. Two videos are played at the same time, and the top and bottom are displayed at the same time

(1) Open cmd, enter the command,

ffmpeg -i video\out.mp4 -i video\out1.mp4 -filter_complex "pad=1920:2160:color=green[x0];[0:v]scale=w=1920:h=1080[inn0];[x0][inn0]overlay=0:0[x1];[1:v]scale=w=1920:h=1080[inn1];[x1][inn1]overlay=0:1080" out15.mp4

(2) After the command is finished running, we find the video according to the path, open the generated video,

5. Screen capture designated area

(1) Open cmd, enter the command,

ffmpeg -f gdigrab -s 500x500 -offset_x 100 -offset_y 100 -i desktop   -frames:v 1 test.png

(2) After the command is completed, we find the screenshot according to the path, open the generated screenshot,

6. Record screen to specify desktop area

(1) Open cmd, enter the command,

ffmpeg.exe -r 1 -f gdigrab -s 500x500 -offset_x 100 -offset_y 100  -i desktop -vcodec libx264  a.mp4

(2) After the command is executed, we can find the generated video according to the path.

7. Crop the existing video in the specified area of ​​the recording screen

Idea: intercept the specified area of ​​the existing video file

(1) Open cmd, enter the command,

ffmpeg -i 0614.mp4 -vf crop=200:200:0:0 0614-1.mp4

(2) After the command is executed, we can find the generated video according to the path.

Original  ffmpeg recording screen and screenshot_ffmpeg screenshot_water w's blog-CSDN blog

★The business card at the end of the article can receive audio and video development learning materials for free, including (FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, srs) and audio and video learning roadmaps, etc.

see below!

 

Guess you like

Origin blog.csdn.net/yinshipin007/article/details/130650747