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.)
[timeline appendVideoTrack];
[timeline appendVideoTrack];
3.Add clips into those tracks(Here two clips are shown as examples).
NvsVideoTrack *firstTrack = [timeline getVideoTrackByIndex:0];
NvsVideoClip *firstClip = [firstTrack appendClip:firstFilePath];
firstClip.imageMotionAnimationEnabled = NO; //Disable motion animation for image. You can decide whether to call this method according to your needs
NvsVideoTrack *secondTrack = [timeline getVideoTrackByIndex:1];
NvsVideoClip *secondClip = [secondTrack appendClip:secondFilePath];
secondClip.imageMotionAnimationEnabled = NO; //Disable motion animation for image. You can decide whether to call this method according to your needs
4.Add "Transform 2D” fx into clips which need to be transformed.
NvsVideoFx *fx = [secondClip 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
CGPoint p1 = [self.liveWindow mapViewToCanonical:currentPoint]; //view coordinates be converted into timeline coordinates
CGPoint p2 = [self.liveWindow mapViewToCanonical:previousPoint];
float transX = [fx getFloatVal:@"Trans X”];
float transY = [fx getFloatVal:@"Trans Y"];
[fx setFloatVal:@"Trans X" val:transX+(p1.x-p2.x)];
[fx setFloatVal:@"Trans Y" val:transY+(p1.y-p2.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.