Highlighted

Control Time-remapping with expression

Engaged ,
Nov 03, 2020

Copy link to clipboard

Copied

I have a composition with several spots separated by10 seconds. I need to be able to view the spot in the composition via a slider that is set in a number. 1,2,3,4,5 etc, which controls ten seconds within the composition. Start 0:00 to 10:00, Start 10:00 to 20:00, Start 20:00 to 30:00, Start 40:00 to 50:00 etc.
The Simplest way that I could think of is to time-remap my composition and control somehow the timecodes via an expression. Suggestions?

TOPICS
Expressions, How to

Views

98

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Control Time-remapping with expression

Engaged ,
Nov 03, 2020

Copy link to clipboard

Copied

I have a composition with several spots separated by10 seconds. I need to be able to view the spot in the composition via a slider that is set in a number. 1,2,3,4,5 etc, which controls ten seconds within the composition. Start 0:00 to 10:00, Start 10:00 to 20:00, Start 20:00 to 30:00, Start 40:00 to 50:00 etc.
The Simplest way that I could think of is to time-remap my composition and control somehow the timecodes via an expression. Suggestions?

TOPICS
Expressions, How to

Views

99

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 03, 2020 0
Guide ,
Nov 03, 2020

Copy link to clipboard

Copied

Is this slider going to be animated, so that at each slider keyframe you want the corresponding section to begin, or is it a static control? What should happen when it gets to the end of the section?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

Copy link to clipboard

Copied

The value an expression generates for the time remapping property is time in seconds. If you just type a number in you get whatever the Time indicator is set to. Set the time indicator to frames and type in 40 and you'll get 40 frames, Change the Time indicator (Ctrl/Cmnd + Click) to timecode in a 30 fps comp and the display will read 0:00:01:10. 

 

Add an expression and type in 1.5 and you'll get 45 if the 30 fps comp is set to frames, but change the display to Timecode and you'll get 0:0:01:15. 

 

If you want to jump to 10 seconds then just multiply the slider value by 10. If you want to make sure that it is exactly 10 seconds then add Math.floor(slider value) so you don't get any frames between the sections and multiply that by 10. Math floor will keep the time from advancing to the next 10 seconds until the next whole number is generated by the slider. That expression would look like this:

sectionID = effect("Slider Control")("Slider");
Math.floor(sectionID) * 10;

If you want the section to play from its starting point and not continue past the endpoint of the animation then you need to have every animated section be the exact number of frames you want to play, then complicate the expression by finding the time value of the keyframe for the slider, and only allowing the time value to increase by 1 frame until the frame count is one less than 10 seconds. I would need AE open to write that expression and be confident in making it work for you, but the idea is to find the time of the nearest slider keyframe, then allow the frame count to move up at the rate of one frame per comp frame until the count is 1 frame less than 10 seconds, then hold on that frame. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 1
Engaged ,
Nov 04, 2020

Copy link to clipboard

Copied

Thank you, I understand about the conversion rate between frames and seconds and what the expression slider returns, Thank you for explaining. I think my question would better be asked is how would I advanced the time-remap keyframe 10:00 (this would be 10 seconds) from anotehr keyframe which would be 00:00 (this would be 0 seconds) which the keyframe values would be defined by the expression slider?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 04, 2020 0
Adobe Community Professional ,
Nov 04, 2020

Copy link to clipboard

Copied

If you set keyframes for the slider and use the Math.floor() expression the time will stay at zero until the slider reaches 1, then the time will jump to 10 seconds and stay there until the slider reaches 2. 

 

If you need an animation to play, between keyframes then the expression gets more complicated.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 04, 2020 0
Guide ,
Nov 04, 2020

Copy link to clipboard

Copied

If you have your slider on a layer named "Control" and keyframe it so that a value of 1 corresponds to the first segment, etc., I think an expression like this will do what you want (assumes each segment is 10 seconds):

 

segDur = 10;
t = time%segDur;
ctrl = thisComp.layer("Control").effect("Slider Control")("Slider");
curSeg = Math.max(Math.floor(ctrl.value) - 1,0);
if (ctrl.numKeys > 0){
  n = ctrl.nearestKey(time).index;
  if (time < ctrl.key(n).time) n--;
  if (n > 0){
    curSeg = Math.max(Math.flooe(ctrl.key(n).value) - 1,0);
  }
}
curSeg*segDur + t

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 04, 2020 1