Hi,
Within Avid Media Composer I would like to OCR two timecodes and calculate with them.
(Substract one timecode from the other and use the result)
The format is hh:mm:ss:ff (->frames) in a 24 Frames-per-second-project.
I managed to get it running. I just fail to get the right result within the 24fps calculation.
Any ideas?
Cheers,
Simon
My first instinct is to convert both values to number of frames
, then do the calculation, then convert back to HH:MM:SS:FF
display. My solution feels cumbersome and as if it could be done simpler – and hopefully someone will chime in with a more elegant solution – but the math displayed in the macro bellow should work, despite the following caveats:
• It only works for frame rates of integer values, so no 23.976fps. (This is because the MOD
and DIV
operators treats all values as integers.)
• Also I guess the hours should wrap arround at either 24 or 100 hours. In the macro below calculations of 99:59:59:23 + 00:00:00:01 = 100:00:00:00
(in 24fps) and 00:00:00:01 - 00:00:00:02 = -00:00:00:01
, (whereas I guess results of 00:00:00:00
and 99:59:59:23
respectively, is how Time Codes would be treated in most video applications)
TimeCode Calculation.kmmacros (8.6 KB)
You're the man! Thanks a lot.
Last question since I can't fully comprehend your macro:
Can you modify your macro so that the end result is in frames (so instead of '00:00:03:16' it would be '88')?
I tested KM'S OCR (both Apple's and the English version) on a timecode and it worked flawlessly in a dozen tests.
However it may fail about 1% of the time, by inserting a space between digits, or misreading a colon as a semicolon, so I recommend you OCR the digits in a loop until they meet your expected format... like this:
Notice how I "assert" that you have a timecode, and if there is no timecode in the standard format I rerun the OCR until there is one. This may fix some failures. Make sure you turn off "Failure Aborts macro" for the Assert action, but you can leave the Notify on Failure flag on.
Very cool. Thanks!
After creating a few of my own variations of macros like this, and having some issues with fractional framerates and other problems, i now just use this python library:
To get results in frames you just use local__framesCalculation
(or something else you name it to) as your output, instead of local__result
. You can then also disable or delete the Frames to TC Conversion-group of the macro:
Very cool. Thanks again!
The only remaining issue is how to use the 'frame result' as a repeat variable for further actions within Media Composer.
Basically my macro should help to sync my chosen audio track with the correspondent Reverb track.
I have the OCR routine running to get the timecodes of those two tracks and Alexanders macro to calculate the frame difference and now I just want to move the Reverb track back to sync.
I tried it with the 'Repeat Action'-command using the frame difference-Variable but thats not working.
I still struggle how to 'modify' variables into different formats to work with them.
Hope this is understandable.
I might be thinking this all wrong or misunderstanding what you ask for. But is it that you want to nudge your selected Reverb track forwards or backwards based on the number of frames the calculation gives?
If so, might something that resembles this be a possible solution?
Hi,
Sorry for getting back so late.
It's almost perfect, but doesn't work when the 'local_framesCalculation'-Variable is negative.
Could it be that I first have to 'invert' the variable to positive in order to use it as a repeat-trigger?
Thanks again,
Simon
Makes a whole lot of sense!
You can do this by calculating the absolute values of local__framesCalculation
, by enclosing it like this:
ABS(local__framesCalculation)
Now it works perfectly. Thanks so much.
Learnt a lot!