ffmpeg lossless cropping and merging of videos

The version I use is
ffmpeg version git-2020-06-23-ce297b4

official document

https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
time format

[-][HH:]MM:SS[.m...][-]S+[.m...][s|ms|us]

crop video

Suppose you need to crop the video aaa.mp4, from the 5th second to the 15th second

ffmpeg -ss 5 -to 15 -i aaa.mp4 -c copy output.mp4

It should be noted here that the parameters -ss and -to need to be placed before -i, otherwise it has another meaning, and the actual test time is always a little bit wrong
insert image description here

merge video

Non-MPEG containers, but MPEG encoders (H.264, DivX, XviD, MPEG4, MPEG2, AAC, MP2, MP3, etc.), first pack into TS containers, and then merge them. For example, merge aaa.mp4 and bbb.mp4
into A video output.mp4

ffmpeg -i aaa.mp4 -c copy -vbsf h264_mp4toannexb input1.ts
ffmpeg -i bbb.mp4 -c copy -vbsf h264_mp4toannexb input2.ts
ffmpeg -i "concat:input1.ts|input2.ts" -c copy -absf aac_adtstoasc output.mp4

Other video transcoding, editing software (lossy)

HandBrake, simple transcoding
https://handbrake.fr/
Shotcut, video editing
https://www.shotcut.org/

reference

https://blog.csdn.net/weixin_46021205/article/details/105078552
https://blog.csdn.net/doublefi123/article/details/47276739
https://blog.csdn.net/qq_36292543/article/details/116466013
https://blog.csdn.net/qq_16504067/article/details/114575615

Guess you like

Origin blog.csdn.net/tangyin025/article/details/128767481