MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Access saved reference time

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
902 Views, 7 Replies

Access saved reference time

Hey gang,

 

I've got a quick question about accessing the reference time within MotionBuilder.

By reference time, I am talking about timecode that has been 'streamed' into MotionBuilder via an LTC device, and that has been recorded into a take.

 

The closest i've been able to come is by using:

 

foo = FBReferenceTime()

t = foo.GetTime(foo.ItemIndex, FBSystem().SystemTime)

print t.GetTimeString()

 

This always seems to return a running string (looks like timecode) of digits, but is nothing close to the timecode that was 'streamed' into the take through the LTC device.  The output from this code snip appears to be a live, system-generated version of timecode.

 

Here is a quick screen of the information I was to obtain, as it appears within the GUI:

MBRefTC.PNG

 

As I scrub on the timeline, I can see the values moving.  When I stop scrubbing, the values stop.  

 

I am hoping this is cear; if my description is unclear, please let me know and i'll try to rephrase 🙂

 

 

Cheers,
Trizoy

 

 

7 REPLIES 7
Message 2 of 8
cmot
in reply to: Anonymous

Hey Troy,

 

I've been digging around a bit trying to figure how FBReferenceTime is supposed to work, and I still haven't figured out quite how to use it, but I did notice that when I park the time slider on any frame and run the script on that frame over and over again in succession, the number keeps increasing. It seems like it's returning my computer clock's time (to slightly varying degrees depending on the framerate, it looks like 30fps gives me the exact time on my computer).  That's probably due to the "FBSystem().SystemTime" part in the "t = foo.GetTime(foo.ItemIndex, FBSystem().SystemTime)" line, as the SystemTime is the computer's clock.

 

Is there some reason you couldn't use something like the following?

 

print FBSystem().LocalTime.GetTimeString()

 

I've only tried it on a mocap file that I imported that was captured with timecode embedded, and it outputs the the same timecode value that is showing on my Transport Controls as long as it's set to Show Local Time and Show as Timecode.

 

Although it just occured to me that it might be that FBReferenceTime is supposed to be used while you're live with the LTC device currently streaming instead of in an offline file? I just tried dragging an LTC device into the scene and switching to display LTC time in the Transport Controls and it goes from showing the current time to just 0.  I don't currently have access to a timecode generator to confirm this, though.

 

 

By the way, this is Ryan from the shoots you guys came down to do in LA last year. How's it going?

Message 3 of 8
Anonymous
in reply to: cmot

Hey Ryan!  How's it going?

We're all good here, though swamped as usual 🙂

 

Hope things have been well for you guys!

 

Thanks for the reply!  I didn't even consider using FBSystem().LocalTime.GetTimeString()…

 

I just read through the docs and figured that the FBReferenceTime() class was the way to go.  Lemme try to use the method you’ve written out; I have access to a timecode generator so I’ll probably be able to test the ‘online’ theory you have, too J

 

I’ll give it a go, and let you know how it turns out!

 

Cheers!
Trizoy

Message 4 of 8
Anonymous
in reply to: Anonymous

Hey again,

 

So I’ve tested out using print FBSystem().LocalTime.GetTimeString(), and I seem to recall running into this issue before, so I must have tried it at one point, but unfortunately it doesn’t work.  The reference time (LTC time) is different that than of the ‘local time’.  Even if you change the transport controls to “Show as Timecode”, the transport timecode will be different than the saved LTC:

 

MBTime1.JPG

 

The code snippet above will return the timesliders value, not the LTC value (in this case it returns 00:00:15:17, when my LTC time reads 15:46:35:12).

 

I think it boils down to MotionBuilder having a concept of three different ‘times’:

 

1) Local time, which I believe is local to the timeslider, and accessed through FBSystem().LocalTime.GetTimeString()

2)System time, which is essentially the system clock time.  And

3)Reference time, which is supposed to be time generated from an input source, such as an LTC generator. 

 

In my case, I wish to access the Reference time, and I figured I could go about it with the FBReferenceTime class, but to pull time from this class, it seems you need to pass it an FBTime object which is either FBSystem().LocalTime or FBSystem().SystemTime.  Each of these two objects makes this class return either the local time, or the system time, but I can’t for the life of me figure out how to get MotionBuilder to return the magical third type of time – Reference…

 

The other side of the coin is that you may be correct – the FBReferenceTime class may only return LTC timecode when its ‘streaming’ live into MotionBuilder (I couldn’t get my hands on the generator today so I’ll have to test this some other time), but you’d think there would be some way to access this reference time once it’s been saved into the file…

 

 

Message 5 of 8
akira.kudo
in reply to: Anonymous

Hi,

 

I cannot say that I understand your question 100% at this time though. However if you need to access LTC time, property 'Time Code' should be work for you like code below, I think.

 

<code_begin>

from pyfbsdk import *

devices = FBSystem().Scene.Devices
for device in devices:
    print device.Name
    prop = device.PropertyList.Find('Time Code')
    print prop.Data.GetTimeCodeString(FBTime.eFrame)
    print prop.Data.GetTimeCodeString(FBTime.eSMPTE)

<code_end>

 

I hope this help.

 





Akira Kudo

Developer Technical Services

Autodesk Developer Network


Message 6 of 8
cmot
in reply to: Anonymous

I think I see where the LocalTime is running into a problem between our tests.  Your file was recorded realtime and had it's timecode streamed through the LTC device and my file is just an imported mocap file with embedded timecode.  So where your local time would start at 0 and have a timecode way out, my timecode and local time are actually the same number and that tripped me up.

 

But I've been messing around with this a bit more, and I might have found another piece of the puzzle.  I tried adding a new reference to the FBReferenceTime with the name "LTC" (I picked it out of the air, there's no documentation of reserved words or enums to use with this thing) and setting an arbitrary time.  When I run it again (with my Transport Controls set to "Show Local Time" and "Show as Timecode" checked) it returns the arbitrary time I gave it, but also adds and checks "Show LTC Time" which wasn't in the Transport Control's dropdown list before I ran the command.

 

Now, the value it returns doesn't change when I move the slider and run it again, it just gives back what I gave it, but maybe it's something you could test out in a file that used LTC for recording?  I wasn't really expecting it to behave the way it did.

 

Here's the test I was using, commenting out the "foo.Add" if I run it more than once

 

from pyfbsdk import *

print "Local"
print FBSystem().LocalTime.GetTimeString()

print "Reference"
foo = FBReferenceTime()

thisTime = FBTime(1,40,30,20,0)
foo.Add("LTC")

print foo.Count
foo.ItemIndex = foo.Count-1
print foo.ItemIndex
foo.SetTime(foo.ItemIndex,thisTime,FBSystem().SystemTime)

t = foo.GetTime(foo.ItemIndex, FBSystem().SystemTime)
print t.GetTimeString()

 

Message 7 of 8
cmot
in reply to: cmot

Can't seem to find a way to edit my last post...
Anyway, I might have found another thing to try. I noticed that Takes have a ReferenceTimeSpan in them. The following, I hope, will be able to give you the value of your reference time at the start of your clip so you can add to it to get your final value.

thisTake = FBSystem().CurrentTake
thisRefRange = thisTake.ReferenceTimeSpan
thisStartTime = thisRefRange.GetStart()
print thisStartTime.GetTimeString()
Message 8 of 8
Anonymous
in reply to: cmot

Embarrassingly late reply to this thread… But better late than never! 

The above worked for what I need!  Thanks so much for putting it together!

 

I used the previous example you’ve given, and replaced the FBTime instance you’ve created, with the one that was embedded by using your example above. 

The final code looks like this:

 

referenceTime = FBReferenceTime()

thisTake = FBSystem().CurrentTake
thisRefRange = thisTake.ReferenceTimeSpan
thisStartTime = thisRefRange.GetStart()

referenceTime.Add("LTC")

referenceTime.SetTime(referenceTime.ItemIndex,thisStartTime,FBSystem().SystemTime)

startTimeInTimeCode = referenceTime.GetTime(referenceTime.ItemIndex, FBSystem().SystemTime)
print startTimeInTimeCode.GetTimeString()

 This will draw out the starting timecode that was embedded from the LTC device.  From here, its simple math to figure out how many frames ahead or behind to crop the file.

 

Sorry it took so long to reply; this project got shelved for a while, but we're back onto it now, and boy, this helped!!


Thanks so much, again, for figuring this out - I knew there had to be a way to get this embedded timecode systematically 🙂

Cheers,
Trizoy

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report