help with timecode

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

help with timecode

Tim Selander
Dear Listers,

I am trying to convert the currenttime of a player showing video
into standard video timecode -- hours:minutes:seconds:frames --
in both drop and non-drop timecode. I'm not being too successful
at it. As I struggled with it, it occured to me I may be trying
to re-invent the wheel.

Does anyone of a solution for turning the current time of an LC
player into time code that they could share?

Thanks,

Tim Selander
Tokyo, Japan


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: help with timecode

Walt Brown
You are using timescale? My assumption is that "interval" = "frame".

"Use the timeScale property <javascript:void(0)> to convert internal movie
or sound times into seconds. The timeScale is the number of intervals per
second of a movie or sound. These intervals are used for the player's
<javascript:void(0)> startTime <javascript:void(0)>, endTime
<javascript:void(0)>, duration <javascript:void(0)>, and currentTime
<javascript:void(0)>properties <javascript:void(0)>, and you can use the
timeScale property <javascript:void(0)> to convert from the time scale used
by the movie or sound to seconds."

On Sat, May 30, 2015 at 9:38 AM, Tim Selander <[hidden email]>
wrote:

> Dear Listers,
>
> I am trying to convert the currenttime of a player showing video into
> standard video timecode -- hours:minutes:seconds:frames -- in both drop and
> non-drop timecode. I'm not being too successful at it. As I struggled with
> it, it occured to me I may be trying to re-invent the wheel.
>
> Does anyone of a solution for turning the current time of an LC player
> into time code that they could share?
>
> Thanks,
>
> Tim Selander
> Tokyo, Japan
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: help with timecode

Mike Bonner
In reply to this post by Tim Selander
Be aware I have no clue about drop, no drop etc so I am probably way off
base here but..

It seems to me that first you need to make sure you're working in seconds,
so you need to divide the currenttime by the timescale to get the total
seconds.
Then its just a matter of math.

Having said that, I may have an easy way to do the conversion.  The first
thing to do would be to grab a padding number when your app starts up like
so:

put 0 into tSeconds
convert tSeconds to dateitems
put (24 - (item -4 of tSeconds)) * 3600 into myAdjustment --the adjustment
allows for timezone differences

gives an adjustment number of seconds that will be used later.

Then, it should be easy.

put ((the currenttime of player "yourplayer"  / the timescale of player
"yourPlayer" ) + myAdjustment) into tCurrentTime
convert tCurrentTime  to dateitems

At this point the hours of tCurrentTime should be item 4, minutes is 5, and
seconds is 6.
When displaying them, look at numberformat in the dictionary.


On Sat, May 30, 2015 at 7:38 AM, Tim Selander <[hidden email]>
wrote:

> Dear Listers,
>
> I am trying to convert the currenttime of a player showing video into
> standard video timecode -- hours:minutes:seconds:frames -- in both drop and
> non-drop timecode. I'm not being too successful at it. As I struggled with
> it, it occured to me I may be trying to re-invent the wheel.
>
> Does anyone of a solution for turning the current time of an LC player
> into time code that they could share?
>
> Thanks,
>
> Tim Selander
> Tokyo, Japan
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: help with timecode

Peter Bogdanoff

This is what I use for minutes & seconds. You can extend it to include hours & frames.

You’ll want to do the send command at the frame interval (1/30) of a second.

on updateCurrTime
     put round(the currentTime of player “thePlayer" 1005 / 600) into theTime
      put theTime div 60 into theMin
      put theTime mod 60 into theSec
      if len(theSec) = 1 then put "0" & theSec into theSec
      put theMin & ":" & theSec into field "CurrTime"
      send "updateCurrTime" to me in 1 seconds
end updateCurrTime

Peter Bogdanoff
UCLA

On May 30, 2015, at 7:07 AM, Mike Bonner <[hidden email]> wrote:

> Be aware I have no clue about drop, no drop etc so I am probably way off
> base here but..
>
> It seems to me that first you need to make sure you're working in seconds,
> so you need to divide the currenttime by the timescale to get the total
> seconds.
> Then its just a matter of math.
>
> Having said that, I may have an easy way to do the conversion.  The first
> thing to do would be to grab a padding number when your app starts up like
> so:
>
> put 0 into tSeconds
> convert tSeconds to dateitems
> put (24 - (item -4 of tSeconds)) * 3600 into myAdjustment --the adjustment
> allows for timezone differences
>
> gives an adjustment number of seconds that will be used later.
>
> Then, it should be easy.
>
> put ((the currenttime of player "yourplayer"  / the timescale of player
> "yourPlayer" ) + myAdjustment) into tCurrentTime
> convert tCurrentTime  to dateitems
>
> At this point the hours of tCurrentTime should be item 4, minutes is 5, and
> seconds is 6.
> When displaying them, look at numberformat in the dictionary.
>
>
> On Sat, May 30, 2015 at 7:38 AM, Tim Selander <[hidden email]>
> wrote:
>
>> Dear Listers,
>>
>> I am trying to convert the currenttime of a player showing video into
>> standard video timecode -- hours:minutes:seconds:frames -- in both drop and
>> non-drop timecode. I'm not being too successful at it. As I struggled with
>> it, it occured to me I may be trying to re-invent the wheel.
>>
>> Does anyone of a solution for turning the current time of an LC player
>> into time code that they could share?
>>
>> Thanks,
>>
>> Tim Selander
>> Tokyo, Japan
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: help with timecode

Peter Bogdanoff
Had some odd stuff...once again (600 is the timescale I was working with; you can find the timescale() with that function) :

on updateCurrTime
    put round(the currentTime of player "thePlayer" / 600) into theTime
     put theTime div 60 into theMin
     put theTime mod 60 into theSec
     if len(theSec) = 1 then put "0" & theSec into theSec
     put theMin & ":" & theSec into field "CurrTime"
     send "updateCurrTime" to me in 1 seconds
end updateCurrTime

> On May 30, 2015, at 11:16 AM, Peter Bogdanoff <[hidden email]> wrote:
>
> on updateCurrTime
>     put round(the currentTime of player “thePlayer" 1005 / 600) into theTime
>      put theTime div 60 into theMin
>      put theTime mod 60 into theSec
>      if len(theSec) = 1 then put "0" & theSec into theSec
>      put theMin & ":" & theSec into field "CurrTime"
>      send "updateCurrTime" to me in 1 seconds
> end updateCurrTime

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: help with timecode

Tim Selander
Peter,

This worked great at getting me min:sec timecode; I hadn't even
gotten that far yet. But I need the timecode down to the frame,
so min:sec:fra.  Timescale of the videos I'm using is 600.

What's bending my head is that min & sec are sets of 60. 60 secs
per min, 60 min per hour. But the frames are sets of 30; 30
frames per second.

Further head-bending happens with DF & NDF time code. Non-drop
frame time code is exactly 30 frames per second. But to broadcast
color, the frame rate had to be scaled back to 29.97 frames per
second.

So, drop frame TC drops 2 frame counts every minute, except every
tenth minute, achieving 30×0.999 = 29.97 frame/s. The error is
the difference between 0.999 and 1/1.001 = 0.999000999000999….

For example, the sequence when frame counts are dropped:
  H:  M: S: F
01:08:59:28
01:08:59:29
01:09:00:02
01:09:00:03

For each tenth minute
01:09:59:28
01:09:59:29
01:10:00:00
01:10:00:01

I'm pretty stuck. But it must be possible as we have stopwatches
with built-in timecode calculators!

If I can't get the frames accurately, I could settle for a
decimal point and remainder after the seconds:
  H: M:  S
01:09:55.38

I'm making an in-house app for our subtitle translators -- the
rule of thumb in Japanese subtitling is 4 characters per second.
So having the fraction at .38 as in the above example, would let
the translator know he could use one more character for the .38
fraction of the second.

Tim Selander



On 5/31/15, 10:34 AM, Peter Bogdanoff wrote:

> Had some odd stuff...once again (600 is the timescale I was working with; you can find the timescale() with that function) :
>
> on updateCurrTime
>      put round(the currentTime of player "thePlayer" / 600) into theTime
>       put theTime div 60 into theMin
>       put theTime mod 60 into theSec
>       if len(theSec) = 1 then put "0" & theSec into theSec
>       put theMin & ":" & theSec into field "CurrTime"
>       send "updateCurrTime" to me in 1 seconds
> end updateCurrTime
>
>> On May 30, 2015, at 11:16 AM, Peter Bogdanoff <[hidden email]> wrote:
>>
>> on updateCurrTime
>>      put round(the currentTime of player “thePlayer" 1005 / 600) into theTime
>>       put theTime div 60 into theMin
>>       put theTime mod 60 into theSec
>>       if len(theSec) = 1 then put "0" & theSec into theSec
>>       put theMin & ":" & theSec into field "CurrTime"
>>       send "updateCurrTime" to me in 1 seconds
>> end updateCurrTime
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: help with timecode

Peter Bogdanoff
Tim,

I must admit I am truly horrible at math (and quite busy right now).

But, I can calculate that in a movie with a timescale of 600, there are 20 standard frames in those 600 ticks. Beyond that, (and into drop frame) my head spins…

Perhaps someone with real math chops can take this further….

There is a drop frame info (and programming source code) at:
        http://www.dropframetimecode.org

All the best!

Peter

On May 31, 2015, at 1:27 AM, Tim Selander <[hidden email]> wrote:

> Peter,
>
> This worked great at getting me min:sec timecode; I hadn't even gotten that far yet. But I need the timecode down to the frame, so min:sec:fra.  Timescale of the videos I'm using is 600.
>
> What's bending my head is that min & sec are sets of 60. 60 secs per min, 60 min per hour. But the frames are sets of 30; 30 frames per second.
>
> Further head-bending happens with DF & NDF time code. Non-drop frame time code is exactly 30 frames per second. But to broadcast color, the frame rate had to be scaled back to 29.97 frames per second.
>
> So, drop frame TC drops 2 frame counts every minute, except every tenth minute, achieving 30×0.999 = 29.97 frame/s. The error is the difference between 0.999 and 1/1.001 = 0.999000999000999….
>
> For example, the sequence when frame counts are dropped:
> H:  M: S: F
> 01:08:59:28
> 01:08:59:29
> 01:09:00:02
> 01:09:00:03
>
> For each tenth minute
> 01:09:59:28
> 01:09:59:29
> 01:10:00:00
> 01:10:00:01
>
> I'm pretty stuck. But it must be possible as we have stopwatches with built-in timecode calculators!
>
> If I can't get the frames accurately, I could settle for a decimal point and remainder after the seconds:
> H: M:  S
> 01:09:55.38
>
> I'm making an in-house app for our subtitle translators -- the rule of thumb in Japanese subtitling is 4 characters per second. So having the fraction at .38 as in the above example, would let the translator know he could use one more character for the .38 fraction of the second.
>
> Tim Selander
>
>
>
> On 5/31/15, 10:34 AM, Peter Bogdanoff wrote:
>> Had some odd stuff...once again (600 is the timescale I was working with; you can find the timescale() with that function) :
>>
>> on updateCurrTime
>>     put round(the currentTime of player "thePlayer" / 600) into theTime
>>      put theTime div 60 into theMin
>>      put theTime mod 60 into theSec
>>      if len(theSec) = 1 then put "0" & theSec into theSec
>>      put theMin & ":" & theSec into field "CurrTime"
>>      send "updateCurrTime" to me in 1 seconds
>> end updateCurrTime
>>
>>> On May 30, 2015, at 11:16 AM, Peter Bogdanoff <[hidden email]> wrote:
>>>
>>> on updateCurrTime
>>>     put round(the currentTime of player “thePlayer" 1005 / 600) into theTime
>>>      put theTime div 60 into theMin
>>>      put theTime mod 60 into theSec
>>>      if len(theSec) = 1 then put "0" & theSec into theSec
>>>      put theMin & ":" & theSec into field "CurrTime"
>>>      send "updateCurrTime" to me in 1 seconds
>>> end updateCurrTime
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode