MeiCam SDK For Android  3.10.0
PIP

1.Create the timeline.

2.Add video tracks matching the required quantity into timeline.

(For example, for the PIP effect of two videos/pictures, two video tracks are needed to be added to the timeline.)

NvsVideoTrack mVideoTrack = mTimeline.appendVideoTrack();
NvsVideoTrack mPipVideoTrack = mTimeline.appendVideoTrack();

3.Add clips into those tracks(Here two clips are shown as examples).

NvsVideoTrack mVideoTrack = mTimeline.getVideoTrackByIndex(0);
NvsVideoClip mVideoClip = mVideoTrack.appendClip(firstMediaPath);
//If the added material is a picture,Disable motion animation for image, You can decide whether to call this method according to your needs
mVideoClip.setImageMotionAnimationEnabled(false);
NvsVideoTrack mPipVideoTrack = mTimeline.getVideoTrackByIndex(1);
NvsVideoClip mPipVideoClip = mPipVideoTrack.appendClip(secondMediaPath);
//If the added material is a picture,Disable motion animation for image, You can decide whether to call this method according to your needs
mPipVideoClip.setImageMotionAnimationEnabled(false);

4.Add "Transform 2D” fx into clips which need to be transformed.

NvsVideoFx mVideoFx = mPipVideoClip.appendBuiltinFx("Transform 2D");

5.Set corresponding attribute values for the "Transform 2D" effect according to detail needs (take the gesture dragging the second clip as an example here)

*Note that view coordinates need to be converted into timeline coordinates here

//view coordinates be converted into timeline coordinates
PointF pointF1 = mLiveWindow.mapViewToCanonical(currentPoint);
PointF pointF2 = mLiveWindow.mapViewToCanonical(previousPoint);
double transX = mVideoFx.getFloatVal("Trans X");
double transY = mVideoFx.getFloatVal("Trans Y");
mVideoFx.setFloatVal("Trans X", transX + (pointF1.x - pointF2.x));
mVideoFx.setFloatVal("Trans Y", transY + (pointF1.y - pointF2.y));
Attributes Meaning
Trans X The X axis offset
Trans Y The Y axis offset
Scale X X Scale
Scale Y Y Scale
Rotation Rotation

Other attributes in the above attribute table can be assigned and applied according to the demand reference axis offset example code.