Source code and APK download, if you like the star

If you have not seen the previous article, you can first look at the imitation wechat video shooting UI, video recording and editing based on FFMPEG (on), help to better understand this article





Four new features:

1. Segmented video shooting, multiple video synthesis, and video paragraph deletion;

2. Change the video speed (acceleration or deceleration);

3. Copy wechat cutting picture control, custom View to achieve the function;

4. Cut video width and height;

1. Segmented video shooting, multi-segment video synthesis, and video paragraph deletion:





As shown in the figure, it is also very simple to implement. Previously, the logic of shooting a single segment of video was to convert a TS file into an MP4. This change is to generate a TS file every time the user clicks on a shot, and then to combine multiple TS files into an MP4.

ffmpeg -i “concat:ts0.ts|ts1.ts|ts2.ts|ts3.ts” -c copy -bsf:a aac_adtstoasc out2.mp4

Then we need to improve the RecordedButton by drawing paragraphs (little white dots in the outer blue circle) to remind the user:





When clicking the delete video paragraph button, the current paragraph should be drawn in red to remind the user, and the current paragraph should be deleted only when the user clicks again.

2. Video speed can be changed (acceleration or deceleration):









It is also simple to execute the FFMPEG statement, pass in the source video directory, and adjust the video speed, but note that the minimum video multiple is 0.5(slow down to play twice), and the maximum is 2(speed up to play twice). When out of the range, it will fail to compile and return the value I =1.

3. Copy wechat cutting picture control, custom View functions:





The first is to draw the entire rectangle (because I don’t have a cut image, so I can only draw myself step by step, if conditions can be drawn to the UI to cut the image, it is easier):





Divided into two parts to draw, show outside a circle of rectangle, and then is 4 lines and 4 bold Angle, drawing process is very boring, is according to the position of all kinds of coordinates, very simple, want to understand their own source.

Next comes the most important onTouchEvent. When the finger is pressed, it detects the position of the finger to determine whether to scale or drag the frame:





In ACTION_MOVE event:









GetCutArr () is used to get the clipped margin value:





4.tailoringvideoWide high:









X +cropWidth <= width of the original video, y+cropHeight <= height of the original video, otherwise the execution will fail. Rate is the bit rate of the video, and 1.5 times of the original bit rate is suggested here, so that the video quality will not change much.

Ps: If I share the technology to help you, or solve some of your problems, please click on the I like and Github star oh!! Github home page where I often share my work problems and cool effects implementation, check it out)