(This section describes how to cut MP4 files efficiently on Android.
Business requirement example: cutting a 2-minute MP4 file from 00:42 to 01:16 into video requires short enough execution time and as few errors as possible.
Analysis: mp4parser can only cut at keyframes. For example, if there is a cutable key frame at 00:40 and 00:45, the head and tail of the cut video should be cut short. Then the video with errors is very short. If the error is greater than 0.5s, ffmpeg is used to encode and decode the file frame by frame. In this way, the MP4 file can have up to three segments, and you can splice these three segments together again.
Key codes are listed directly below. These codes can also be implemented by creating a new Java project on the PC.)