Time Remap

PieroF_Time_Remap_v2.2.5.fxscript.zip: (click the link to Download)
What does it do ?
Time Remap is a freeware filter designed for Final Cut Express HD v3.5 and later that provides a time remap function, otherwise missing in FCE, that is similar to Time Remap built in Final Cut Pro. This filter allows to keyframe the speed of the clip so the clip will play at different speeds in different timecodes, or to individually remap frames from the source media into the clip. The possibility to keyframe the filter controls is a basic requirement to make use of this filter.
As a main difference from the FCP Time Remap function, a new mode Variable Speed in this Time Remap filter allows to keyframe speed at different clip timecodes; do get the same result, FCP implements a kind of speed fade in - fade out by applying Bezier controls at the clip ends. In addition, the Position control in this filter allows to select frames by using their position as a percentage of the clip duration, in place of their exact frame number, as in FCP. On the other hand, the Time Remap - Frame n. control in this filter behaves very similarly to the Time Remap function provided by the Motion tab in FCP.
In the picture above an example of Info Box is presented, that optionally displays how the clip frames are mapped when you apply one of the 3 operating modes of this filter. The info box above shows that frame 636 of the source media at the current playhead position (this frame: = position 84.48% in the clip), is replaced by frame 572 of the clip (to: = position 75.99% in the clip). In addition, due to this time remapping, the speed of the remapped frames is 179.60%. A control in the filter selects whether the the Info Box is rendered together with the clip, or not.
Basic Usage
After its Installation drag the filter Time Remap v2.2.5 from the Video Filter > pf folder of Effects into the Viewer on the clip you want to apply it to.
As a basic use of the Time Remap, with default Mode = Variable Speed, you only have to keyframe the Variable Speed (%) value, in order to define different speeds at different clip positions. This way you can easily speed up a clip from speed 0 (or any other speed) at the IN point, or slow down a clip to 0 at the OUT point. More in general you can make the clip run forward and backward, or change speed at different timecodes by simply typing appropriate values to the Variable Speed (%) field.
In the following example the clip starts with no motion and gradually speeds up to full speed: Variable Speed (%) control is keyframed from 0% at the IN point of the clip to 100% 5 seconds later: the current playhead is shown halfway between the two keyframes, where Variable Speed (%) has value 52%.

Obviously It is possible also to slowdown the clip until it stops: in the following example Variable Speed (%) control is keyframed from 100% 5 seconds before the end of the clip, to 0% at the OUT point: the current playhead is shown halfway between the two keyframes, where Variable Speed (%) has value 52%.

Remember to always render the clip before evaluating the final result, because Unlimited RT is not sufficient to show it.
If however you want more control on the frame timecodes and on the quality applied by the blending algorithms, you must move to the Advanced Usage section below.
Compatibility, Disclaimer
This Time Remap filter has been tested in Final Cut Express HD v3.5 and Final Cut Pro v5.1. While it will likely work also in other versions of FCE and FCP, a basic requirement for its use is the possibility to keyframe the filter controls. So it cannot run on any version of FCE earlier than v3.5 (see also the Disclaimer).
Version History
v2.2.5 - Info Box fixes - New: it may show both current frame and remapped frame side by side.
v2.2.1 - Removed debugging tools - added negative speed.
v2.3d - Added Blend Type (1-1, 1-2, 2-1, 2-2) - debug version with possibility to display fields info.
v2.2 - Added the ability to use only even fields (“Skip 2nd Field” control) to smooth progressive video, and to control Blending Balance.
v2.0 - Used workaround to avoid bug in FCE while enlarging keyframe graph areas.
v1.9 - Better blending, green frame for Source Media, Reverse function, minor fixes.
v1.5 - Added possibility to choose one of 3 modes (Variable Speed, Time Remap - Frames and Percentage), Preview Information, Source and Final Clip preview.
Advanced Usage
After its Installation, choose the filter as described in Basic Usage above, and then set the following controls:

•Mode (default: Variable Speed): it is one of the following:
‣Variable Speed: you can keyframe different speeds at different timecodes of the clip. In this case the Variable Speed (%) control defines the clip speed at the current position of the playhead (Time Remap - Frame n. and Time Remap - Position values are ignored);
‣Time Remap - Frames: you can keyframe different frames chosen from the same clip in different timecodes of the clip. The Time Remap - Frame n. control defines the frame number from the source media to be remapped into the current position of the playhead (Variable Speed (%) and Time Remap - Position values are ignored);
‣Time Remap - Position: you can keyframe different frames chosen from the same clip in different timecodes of the clip. The Time Remap - Position control defines the position (in %) within the clip duration of the frame to be remapped into the current position of the playhead (Variable Speed (%) and Time Remap - Frame n. values are ignored). By clip duration here we mean all frames between the IN and the OUT points included.
•Variable Speed (%) (default: 100% - range: -400 to +400): value of the speed at the current playhead, used only when Mode = Variable Speed is selected. When a fixed value and no keyframes are set, the whole clip runs at constant Speed (%), as when applying the FCE Speed command. However, the power of this filter is exploited when Speed (%) is keyframed; for example if the speed = 0% at the IN point frame, the speed=200% in the middle, and speed=0% at the OUT point frame, the clip will start slowly, speed up to the middle and slowdown to stop at the end. See also the example in the Basic Usage above.
Note1: As a general rule, if Reverse = OFF (default) Variable Speed (different from Time Remap - Frame n. and from Time Remap - Position) allows to select only the first frame of the clip and it will compute the following frames depending on its speed on a step by step basis; as a result the last frame of the filtered clip cannot be easily forecasted. Similarly, if Reverse = ON this filter allows to select only the last frame of the clip (that will be used as the first frame), and it will compute all the following frames depending on its speed on a step by step basis.
Note2: This filter uses only frames within the IN and the OUT points of a clip (clip duration). Then, if frames outside this range are required to build the filtered clip (frame n. < 0, or ≥ the clip duration) frame n.0 will be used for all negative frame numbers and frame n. duration-1 will be used for all frames n. ≥ duration.
As an effect of this approach (different from FCP approach, where the limits are the media limits, not the clip limits) for example a constant negative speed will result as a frozen frame n.0 if Reverse = OFF, or frozen frame n. duration-1 if Reverse = ON. Negative speed values are useful only when they are keyframed and intermixed with positive speed values, and as long as frames are not required outside of the allowed range.
•Reverse (default: OFF): if checked the clip is played backward starting from the last frame of clip (at the OUT point) and the Variable Speed (%) value changes sign.
However, a fixed (not keyframed) Variable Speed = 50% and Reverse = ON does not behave the same way as a fixed Variable Speed = -50% and Reverse = OFF: in the first case (with Reverse = ON) the clip is played back at half speed starting from the native OUT frame, in the second case the result is a frozen frame n.0 (see Note2 above).
Reverse affects only the Variable Speed mode.
•Time Remap - Frame n. (default: 0 - range: 0 to 15000): frame number from the source media of the frame to be remapped to the current playhead position, used only when Mode = Time Remap - Frames is selected. When a fixed value and no keyframes are set, the clip plays only frame Frame n. (as when applying the FCE Freeze Frame command). However, the power of this filter is exploited when Frame is keyframed; for example in order to synchronize a video frame to an audio track (see Examples below).
•Time Remap - Position (default: 0%): position (in % of the clip duration) in the source media of the frame to be remapped to the current playhead position, used only when Mode = Time Remap - Position is selected. When a fixed value and no keyframes are set, the clip plays only the frame at Position (as when applying the Freeze Frame command). However, the power of this filter is exploited when Position is keyframed as for Time Remap - Frames.

•Field Blending (default: ON): if checked new fields (where necessary) are created by blending adjacent fields, with an appropriate balance between fields, to smooth the clip playback.
•Blending Balance (default: 0): valid range is from -1 to +1; it allows to control the amount of blending between the adjacent fields. When it is 0, the automatic balance is used; when negative more weight is given to the first field, and when positive more weight is given to the second field.
•Skip 2nd Fields (default: 0): valid values are only 0 and 1; if 1 (and if Field Blending = ON) all even fields (2nd, 4th, 6th, etc. in time, not in frame position) in each frame are skipped and replaced by new fields built by blending the adjacent odd fields, as defined by Blending Balance: for example the 2nd field is replaced by blending the 1st and the 3rd field, the 4th field is replaced by blending the 3rd and the 5th field, etc.
The purpose of this control is to smooth progressive video by emulating interlacing; in progressive video each frame has 2 almost identical fields taken at exactly the same time: by discarding the second field in each frame and substituting it with a new field created by blending existing fields, the resulting motion is smoother, even if not as smooth as in interlaced video.

•Show Clip Frames (default: Time Remapped): it allows to select the information to be displayed when Info Box is ON (warning: Time Remapped must be selected when rendering, otherwise no effect is applied):
‣Source Media: the original frame of the clip under the playhead is displayed, and, when set, the Info Box displays the values of the source media only. You can use this selection to check and compare source frame with the remapped frame (Time Remapped) with just a click of the mouse.
‣Time Remapped: the remapped frame is displayed according to the setting of the mapping controls, and, when set, the Info Box displays the frame information of both the source media (to:) and the current playhead position (this frame:). The green line highlights the current operating Mode (Variable Speed, Time Remap - Frames or Position). See below for some examples of this display.

In the figure above the Frame under playhead n. 577 (on the left) will be replaced by the the time remapped New frame n. 685 (on the right). Below are the parameters for each frame.
•Info Box (default: Previewing only): it defines when the Info Box must be displayed:
‣No: the Info Box is not displayed.
‣Previewing only: the Info Box is displayed only during previewing (not in the rendered media or during playback).
‣Yes: the Info Box is always displayed both during previewing and in the rendered media.
Depending on the selection of Show Clip Frames one of the two following boxes is displayed during preview:


The displayed information is:
‣frame n.: if Time Remapped is selected, it displays the frame number in the source media (to:), and the frame number under the playhead (this frame:). If Source Media is selected, only the source media info are displayed.
‣position: if Time Remapped is selected, it displays the position of the frame in the source media (to:), and the position of the frame under the playhead (this frame:). If Source Media is selected, only the source media info are displayed.
‣clip duration: it displays the size in frames of the clip (from the IN to the OUT points) for both source media (to:) and playhead position (this frame:).
‣velocity: if Time Remapped is selected it displays the speed of the remapped frames (to:). Playhead speed is always 100%.
•Info Box Position (default: 0,0 = centered): it defines the position of the Info Box in the window.
•Info Box Opacity (default: 50 - range: 0-100): it defines the opacity of the Info Box.
•Scale PIP (default: 50 - range: 0-50): it defines the size of the frames when Show Clip Frames = Both.
Important notes:
a.After applying the filter and setting its controls always render the whole clip to see its final effect. This is an important step: without a whole clip rendering (not just a section of it) the effect might not be correctly applied.
b.In addition the visual result of the filter is visible only in the Canvas Window; the Viewer Video window is meaningless.
c.Audio is never affected by the filter.
Examples.
Note: some examples below refer to a debugging version of the filter v2.3d with a slightly different interface and the addition of the Blend Type control. This is not relevant to their main purpose to show some use of this filter. These examples will be updated in the future to show the correct user interface.
A. Synchronization of video
Using the Time Remap - Frames (or Position) mode you can stretch the video speed to force a specific frame in the clip to occur at a specific time, without shifting the whole clip: in the example you want to anticipate frame 81 of the video to occur at position 67; this will speed up the clip before 67 and slow it down after, to compensate.

For this purpose the needed steps are:
➡select Mode: Time Remap - Frames
➡position the playhead at the IN point (shift-I), set a Frame n. keyframe with value 0
➡position the playhead at the OUT point (shift-O), set a Frame n. keyframe with value=last frame number; this value is the clip duration - 1; the clip duration can be read in the Info Box. In this example duration = 122, so last frame number = 121.
Note: if we stop at this point, the filter will simply map each source media frame into itself (1 to 1, 2 to 2, ...121 to 121) as in any clip without this filter. But here comes the point:
➡position the playhead at frame 67, that is the frame where you want to remap frame 81 of the source media, and there set a Frame n. keyframe with value 81. This will force frame 81 taken from the source media to be presented in place of 67.
As a result, all frames before 67 will be remapped and sped up to smoothly reach 81 in position 67, while all frames after 67 will be remapped and slowed down to smoothly reach back 121 in 121.
➡Speed and Position values are discarded, whatever is their value.
B. Using “Position” instead of “Frame n.”:
•The same result may be reached using Mode: Time Remap - Position, where in place of using frame numbers you can use a % frame position to both select the frame from the source media, and to reposition it into the clip. The choice between Frame n. and Position is just a metter of preference; Frame n. allows a more precise tuning frame by frame, while Position is less precise but faster to use, and may be sufficient in most cases.
C. Reverse Effect:
•By inverting values in the IN and OUT keyframes (121 for IN and 0 for OUT) you get a Reverse effect.

The same Reverse effect you can get with the standard FCE Speed command, or without keyframes:

D. Back and Forth:
•In the following example, using Mode: Time Remap - Position, the clip is sped up (200%) till mid of the clip; then the speed is reversed (-200%) and the clips plays back reverse to its first frame:

E. Slow down to stop:
•To slow down and stop the action at the end of the clip (the first keyframe has been “smoothed”) :

F. Slow down to stop at a selected frame:
•If you check carefully you see that, after applying the filter in the example above, the motion stops at a frame that is not the last frame (OUT point) of the original clip, but at some earlier frame: since the clip duration doesn’t change, the slowed down motion has to discard the last frames that cannot fit into the modified clip.
This may be OK or may be not OK: it all depends on whether or not you need the action to stop at a precise frame.
•If you want to have control on the exact frame where the action stops you may use the following steps:
1.create a new support sequence (to be later nested into the main sequence - see step 4 below), insert the clip into the new sequence, and make sure that you set the clip OUT point where you want the clip to stop
2.revert the clip using Modify > Speed, and select Revert (don’t change the other parameters)
3.apply the Time Remap Filter with Mode: Variable Speed, and keyframe the “Variable Speed (%)” control from 0 on the first frame (that is the last frame of the original clip before reverting) to 100% where you want the slowdown to start - and render.

If you playback the clip now, you see that it is going backward and speeding up.
4.drag the support sequence with the modified clip into the main sequence and revert it as in step 2. above using Modify > Speed, and selecting Revert.
Now in the main sequence you have the original clip (with unmodified length) slowing down and ending exactly on the selected frame.
The rational for this solution is that reverting the clip the first time (step 2.) sets the selected last frame as the first frame, so that Time Remap has precise control over the speed-up. The second revert (step 4.) flips back to the correct time direction, together with the keyframes.
Why a nested sequence is needed ? because this is the only way to apply again Modify > Speed with Revert after the Time Remap filter has effect (as a general rule in FCE/FCP Speed is always applied before any filter in the same sequence - to apply it after you must make a nested sequence as in this example).
Note 1: You could skip step 2 (first clip reversing) and select the Reverse checkbox in the Time Remap Filter, leaving the remaining setting as in step 3. above. It works, if you know what you are doing...
Note 2: If you need to keep the original soundtrack (that in any case is not modified by Time Remap) with the slowed down clip, you’d better unlink video and audio of the clip and apply steps 2., 3. and 4. to the video alone: this avoids a useless and time consuming audio rendering due to its double reverse.
Hints and Technical Notes:
a. Field Blending - Blending Balance.
When Field Blending is ON, the filter applies field blending to create the smoothest possible movement when the clips are sped up or slowed down in each of the 3 available Modes of operation.
For example, when the speed is 50% one new field is created every other existing field, resulting from blending 50%-50% the previous and the next existing fields. If the speed is 33%, two new fields are created between each pair of existing fields, but with different blendings: 66%-33% the first one and 33%-66% the second one. And so on. If Field Blending is OFF the new fields are also created, but they contain exact copies of their previous field (same as 100%-0% blending).
The same principle applies to speed ups.
No blending is applied when speed is 100%.
When Blending Balance is not equal to 0, the filter applies a correction factor to the blending automatically evaluated by Field Blending.

In the above example, where Blending Balance = 0.5, the second field will weight more than the first field. Then the automatic 50%-50% blending (for 50% speed) will be corrected to 25%-75%, the automatic 66%-33% blending (for 33% speed) will be corrected to 33%-66%, and the automatic 33%-66% blending will be corrected to 17%-83%. If, on the contrary, Blending Balance = -0.5 the second field will weight less than the first field.
b. Smoothing progressive video.
When Skip 2nd Fields is 1 and Field Blending is ON, the filter makes progressive video smoother, and more similar to interlaced video, by replacing duplicated fields with new blended fields.
In this case an algorithm similar to that used in Field Blending is applied to the new blended fields; the Blend Type (see below) control defines which fields to blend. Note that when Skip Fields is 1, field blending is applied also at speed 100%: then, the second field of each frame is replaced by a new field built by blending 50%-50% one field of the same frame and one field of the next frame.
Only the 2 values 0 or 1 should be used; however, a Slider control is made available, in place of a Checkbox control, in order to allow keyframing: by means of keyframes you can easily switch Skip Fields ON and OFF many times within each clip, in cases when the camera switched from interlaced to progressive in the same clip.
Blend Type adds the possibility to choose which fields to blend: the 2-1 default blends the 2nd field of the current frame with its very next field: the 1st field of the next frame. This empirically gives the best results.
c. The clip length doesn’t change as in the FCE Speed command. Why ?
In this filter the length of the clip does not change whatever Mode is used. While this is intuitive for the 2 Time Remap modes, it is less evident when Variable Speed is used (mainly if compared with the FCE Speed function). Note that also FCP Variable Speed and Time Remap do not change the clip length nor affect the audio.
To explain how Variable Speed works, let’s apply a fixed speed (even if this is not the main purpose of this filter) different from 100%; then the following will occur:
‣if Speed is lower than 100%, e.g. 50%, the clip cannot contain all the slowed down frames of the source media: the result will be a clip with the original length but with half of the original frames. The action will stop at the end of the clip, even if it is only half the way of the original action.
‣if Speed is higher than 100%, e.g. 200%, the source media has not enough frames to fill the whole clip length. All action in the clip will be squeezed in its first half, while the second half will have a freeze frame.
More in general this applies to any intermediate value of Speed, and again when keyframes are used to set variable speeds. Whether the action of the source clip will fit into the remapped clip, or a part of action will be cut out, or some frozen frame will fill its end, all depends on its average speed: if this is about 100%, the slowdown and the speedup effects compensate across the whole clip.
d. What can I do when there is no speed compensation ?
Two techniques may be used.
e.If the clip is not long enough to fit all the original action from the source media, because in the average the original clip slows down, use the nested sequence approach as follows:
1.make a new sequence A;
2.drag the clip you want to time remap into sequence A twice, or more times if the average slow down > 50%. Note that only the first clip in the new sequence is relevant; the following clips or just “stubs”.
3.now drag the new sequence A from the browser to the place in the timeline where you want the time remapped clip: it will use more room than the original clip (2, 3 or more times, depending on how many clips or copies you dragged into A)
4.apply the Time Remap filter to the nested sequence A (alt-double click opens the filter tab in the Viewer for the nested sequence), and set its controls as needed
5.render the nested sequence A;
6.depending on the amount of average slowdown you might need to ripple left the nested sequence A.
b.If the original clip is too long, because in the average the original clip speeds up, use the following approach:
1.apply the Time Remap filter to the original clip, and set its controls as needed
2.render the original clip
3.ripple left the original clip till all freeze frames at its right end are discarded.