Jump to content

Add frames to timecode calculation


Recommended Posts

Hi all,

I'm a film editor and have started building a FM database to be able to track visual effects shots that go in and out of an editing timeline. 

I am trying to create a calculation that will enable me to add frames to timecode and get the result back in timecode.

At the moment I have a text field called 'Scan TC In' which has the following TC entry 18:59:48:23 (HH:MM:SS:FF) and I need to add 8 frames to it, the timeline runs at 24 frames a second. 

Does anyone know how I can achieve this?

I'm a newbie to FM so any help is greatly appreciated!

Thanks

Michael

 

Link to post
Share on other sites

Start by converting your timecode to frames and adding the duration to the result to get the total number of frames. Then convert the result back to timecode format:

Let ( [
totalFrames = 24 * GetAsTime ( Left ( YourTimecode ; 8 ) ) + Right ( YourTimecode ; 2 ) + YourDuration ;
totalSeconds = Div ( totalFrames ; 24 ) ; 
remFrames = Mod ( totalFrames ; 24 ) 
] ;
SerialIncrement ( "00" ; Mod ( Hour ( totalSeconds ) ; 24 ) ) &
SerialIncrement ( ":00" ; Minute ( totalSeconds ) ) &
SerialIncrement ( ":00" ; Seconds ( totalSeconds ) ) &
SerialIncrement ( ":00" ; remFrames )
)

 

Edited by comment
  • Like 1
Link to post
Share on other sites

Hi there, thanks so much for this

I should add that the result of Scan TC In + 8 frames needs to go into a new field called Cut In TC... so would I enter this calculation in the Cut In TC field? 

I have been putting in place of 'YourTimecode' the Scan TC In field... is this correct for both left and right and also do I need to first work out the duration of the timecode or does this calculation do it for me?

Thanks for you help

Michael

Link to post
Share on other sites
46 minutes ago, Mike_FM said:

I should add that the result of Scan TC In + 8 frames needs to go into a new field called Cut In TC... so would I enter this calculation in the Cut In TC field? 

Yes. The  Cut In TC field should be defined as a calculation field, using the formula above. Replace both instances of `YourTimecode` with the name of your input field (Scan TC In) and 'YourDuration` with the name of the field that has the duration in frames - or with the number 8 if that's a constant. Set the result type of the calculation to Text.

46 minutes ago, Mike_FM said:

do I need to first work out the duration of the timecode or does this calculation do it for me?

The calculation does everything. I suggest you follow it step-by-step; it's not very difficult and it's good exercise.

 

Edited by comment
Link to post
Share on other sites

That's thanks again, works perfectly. I wish I knew how it worked but I'll look at it step by step to try and learn.. I guess what is most confusing in the script is  '+ Right ( YourTimecode ; 2 )' and what that means

Link to post
Share on other sites
2 hours ago, Mike_FM said:

I guess what is most confusing in the script is  '+ Right ( YourTimecode ; 2 )' and what that means

It extracts the FF part (the last two characters) of your timecode and adds it to the frame count.

 

Link to post
Share on other sites

Hi there, the above calculation has been very useful in adding 8 frames to a timecode.

I have another field that when a timecode is entered, a calculation should convert it into a frame count, so for eg if TC: 00:00:42:09 was entered the result in frames would be 1017 (frame rate 24)

The above calculation that you gave me converts timecode to frames, adds 8 frames to the value and then converts the frame count back to timecode. I have tried to extract the part of the script that converts timecode to frames but with no luck, can you show me how to convert timecode to frames?

Any help would be appreciated and thanks in advance!

Link to post
Share on other sites

Why it's right there in the first line of the code:

24 * GetAsTime ( Left ( YourTimecode ; 8 ) ) + Right ( YourTimecode ; 2 )

Here the result type should be set to Number.

--
P.S. It's a calculation, not a script.

 

Link to post
Share on other sites

Awesome! Thanks :) 

So the only complication is that the TC of the media that I am converting to frames, by default starts at 1 hour so 01:00:42:09 equals 87389 frames... however in my editing application 01:00:42:09 when converted into frames on the timeline actually gives the value of 989 frames... so seems to be ignoring the hour or seeing it as 0...

As a general rule media and timelines in editing software start at 01 hour in order to give ample space for any credits or such that might need to go before the programme starts and therefore avoiding a negative timecode ie if a programme started at TC: 00:00:10:00 but there were 20 seconds of credits to go beforehand this would cause a problem so as a standard programmes and media usually start at 01:00:00:00

Is there a way to make the above calculation do the same as my editing software ie 01:00:42:09 = 989 frames? 

Hope this makes and thanks again!

 

Link to post
Share on other sites
48 minutes ago, Mike_FM said:

01:00:42:09 equals 87389 frames... however in my editing application 01:00:42:09 when converted into frames on the timeline actually gives the value of 989 frames

I am somewhat confused by this, because I get the result of 87417 frames as the equivalent of timecode 01:00:42:09, and if you subtract 1 hour from that it will become 1017. 

You can easily verify these results by calculating:

42 seconds * 24 fps + 9 frames = 1017

and if you add the number of frames in 1 hour =

60 minutes * 60 seconds * 24 fps = 86400

to the above result, you will see that it matches the original calculation:

86400 + 1017 = 87417

so I am not sure how you got the numbers you quote.

 

In any case, if you want to start the frame count at 01:00:00:00, you simply need to subtract 86400 from the actual count.

(This is assuming your program will never be longer than 23 hours. Otherwise you would also need to prevent timecodes between 00:00:00:00 and 00:59:59:23 from returning negative frame counts.)

 

Edited by comment
  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Similar Content

    • By Mike_FM
      Hi all,
      I would like to create a page count for a found set of records when I am in preview mode and when I export to PDF  ie if a found set of records has 3 pages then the first page would contain a field that reads '1 of 3'
      Can anyone help with how to achieve this?
      Any help is much appreciated
      Thanks
      Michael
    • By Don_Macaroni
      I cannot select inside an input field at a specific character. Clicking on the field works and selects the field, but I then need to use the arrow keys to go to a specific characters. Mouse clicking at a specific characters does nothing. Anyone has experienced this?
      screen.mov
    • By Amanco
      Hello, 
      I moved fields (and scripts) from one FM file to another one.
      Now, I have a table to 2 fields that has same function but different names, example: Container1 and Container2
      Both have their own attached scripts and calculations.
      I would like to merge "container2" into "Container1" field so the attached scripts and calculations will also change, but I can't rename it simply to "container1"
      is there a way to without going through all the scripts and calculations?
       
      Thanks
       
    • By Mike_FM
      Hi all,
      I have created a portal in a related table and I want to apply a filter to it so that it only shows the latest versions from a found set of records and to hide the others. There is a related field within the portal called 'scan version' which displays the version number as eg 'v001' 'v002' 'v003' etc
      I've been hunting around online to find a calculation that fits my needs and have played around with the 'Max' function but to no avail
      If anyone can give me some pointers that would be awesome, I'm still very new to this and learning so any help is always appreciated!
      If you need any more info please let me know
      Thanks
       
      I have just worked this out and used the following calculation
      Scans::Scan Versions = Max ( Scans::Scan Versions )
      and it worked!
    • By Selva
      Hi,
      I have tried to pass the below JSON data to the API. But it doesn't accept the JSON data due to Square brackets[] in the JSON Key. Is there any solution available to pass the below value?
      JSONSetElement ( "{}" ; "[Name | Last]" ; "Test" ; JSONString )
      We need the output like below.
      {
      "[Name | Last]": "Test"
      }
       
      Thanks in advance.
       
  • Who Viewed the Topic

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.