Use ffmpeg for video cutting and splicing

Preparation: To cut video encoding format requirements, consistent with resolution

Video length cut
A first inter-coded into intra video coding, which can cut at any point in time, the key frame is not affected. No person may happen: When 00 you need to cut a video: 00: 10-00: 00: 40 result this time, but may not be cut out of the whole 30 seconds, because that is 10 seconds and 40 seconds at office is not a keyword, resulting in that part of the video length is not what you need, so you need to have inter-frame video encoding into intra-coded, and then do the cutting work.
-i C FFmpeg: \ 1.mp4 -qscale 0 -intra C: \ 11.mp4 // coded into intra-coded by the inter
-i C FFmpeg: \ 11.mp4 -vcodec Copy Copy -acodec -ss 00:00:00 00:00:20 -t C:. \ -Y -ss time_off to MP4 111 // when cut length of 20 seconds, the start time 00:00:00 video

-ss start time, such as: 00:00:20, represented by 20 seconds from the start;
-t duration, such as: 00:00:10, represented by the video taken 10 seconds long;
-i input, followed by a space, followed by that of the input video files;
-Vcodec video encoding format shows a video type to be used;
-acodec encoded audio video format represented by formula to be used;

Merge MP4 Video
ffmpeg + ts
Mp4 first converted to the same stream coded form ts, ts because the flow can be merged. After the merger ts ts stream flow into mp4.
ffmpeg -i 1.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 1.ts
ffmpeg -i 2.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 2.ts
ffmpeg -i "concat:1.ts|2.ts" -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4




Published 11 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/LQ753799168/article/details/53915866