FFMPEG basic operation command guide (1)

FFmpeg is a set of open source computer programs that can be used to record, convert digital audio and video, and convert them into streams. FFmpeg has very powerful functions including video capture function, video format conversion , video capture, adding watermark to video, etc.

The following are some common ffmpeg commands.

One: video compression resolution

Command example:

ffmpeg -y -i input.mp4 -vf scale=1920:1080 output.mp4

illustrate:

Common video resolutions are: 720P: [1280x720], 1080P: [1920*1080], 2K: [2560*1440], 4K: [3840*2160], 8K: [7680*4320]

Two: Change the video format

Command example:

ffmpeg -i input.mp4 -c:v copy output.ts

illustrate:

Common video formats are: [.mp4], [.ts], [.mov], [.mpeg], [.avi], etc.

Three: Video Merging

Command example:

ffmpeg -f concat -i filelist.txt -c copy output.mp4

illustrate:

First, you need to create a txt text document named filelist, and add the videos to be merged line by line, such as:

file 'input1.mp4'
file 'input2.mp4'

 Then execute the merge command above.

PS: merge command FAQ,

1. The time after the merger is wrong

Solution: First convert the original video into ts files and merge them. ffmpeg -i input.mp4 -c:v copy output.ts

2. The merged video has no sound

Solution: After FFMPEG merges videos, the audio track information of the merged video uses the first information in the txt file. If the first video has no sound, the entire video will have no sound after the merge. Therefore, we need to get the audio track information of the original video first. The command is as follows:

ffprobe -i input2.mp4 -show_streams -select_streams a -loglevel error

The returned results are as follows:

 Extract the information in the red box and import it into the first video. The command is as follows:

ffmpeg -i input1.mp4 -f lavfi -i anullsrc=cl=stereo:r=44100 -shortest -y output.mp4
 

 

Four: picture synthesis video

Command example:

ffmpeg -f image2 -i %d.jpeg output.mp4

 illustrate:

%d is a number placeholder, ffmpeg will load 1-250.jpeg in order as input. We didn’t specify other parameters here, so ffmpeg uses the default parameters, such as the frame rate is 25fps, the video uses h264 encoding, and the resolution directly uses the original resolution of the picture...

Guess you like

Origin blog.csdn.net/m0_58954887/article/details/126300333