VideoHelp Forum




+ Reply to Thread
Results 1 to 9 of 9
  1. Does anyone know of any freeware; a small program, an applet, a line of javascript; that'll convert a raw frame count to NTSC SMPTE Timecode?

    I hate doing it by hand & the program I wrote (a web page with javascript) is sometimes off by a frame or two (in either direction).

    Here's the code for the page... It only works in Internet Explorer, but I'm sure someone will find it useful.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>Frame to NTSC Timecode Conversion</TITLE>
    <META http-equiv=Content-Language content=en-us>
    <META content="MSHTML 5.50.4207.2601" name=GENERATOR>
    <META content=FrontPage.Editor.Document name=ProgId>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT language=jscript>
    a=0
    function convertIt(){
    if (isNaN(theForm.frameCount.value )) {
      theForm.reset();
      }
      else {
      iFrameCount=theForm.frameCount.value
      minuteTotal=(iFrameCount/(30*(1000/1001)))/60
      theForm.minutes.value=minuteTotal                           //ok
      droppedFrames=(Math.floor(minuteTotal))*2
      unDroppedFrames=(Math.floor((minuteTotal)/10))*2
      totalCorrection=unDroppedFrames-droppedFrames
      theForm.correction.value=totalCorrection
      nFrameCount=eval(iFrameCount+totalCorrection)
      if (nFrameCount>iFrameCount) nFrameCount=iFrameCount
      newTotal = ((nFrameCount/(30*(1000/1001)))/60)/60
      hourTotal = Math.floor(newTotal)
      newTotal = (newTotal - hourTotal)*60
      if (hourTotal<10) hourTotal = "0" + hourTotal
      minTotal = Math.floor(newTotal)
      newTotal = (newTotal - minTotal)*60
      if (minTotal<10) minTotal = "0" + minTotal
      secTotal = Math.floor(newTotal)
      newTotal = (newTotal-secTotal)*(30*(1000/1001))
      if (secTotal<10) secTotal = "0" + secTotal
      fraTotal = Math.floor(newTotal)
      if (fraTotal<10) fraTotal = "0" + fraTotal
      
      theForm.rightCode.value = hourTotal + ":" + minTotal + ":" + secTotal + ":" + fraTotal
      theForm.rightCode.select();
      }
    }
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <DIV align=center>
    <CENTER>
    <TABLE id=AutoNumber2 style="BORDER-COLLAPSE: collapse" borderColor=#111111 
    cellSpacing=0 cellPadding=0 border=0>
      <TBODY>
      <TR>
        <TD width="100%">
          <FORM name=theForm onsubmit="convertIt();return false;">
          <FIELDSET 
          style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"><LEGEND 
          align=center>Frame to NTSC Timecode Conversion</LEGEND>
          <DIV align=center>
          <CENTER>
          <TABLE id=AutoNumber1 style="BORDER-COLLAPSE: collapse" 
          borderColor=#111111 cellSpacing=0 cellPadding=0 border=0>
            <TBODY>
            <TR>
              <TD width="100%" colSpan=2>
                <HR>
    
                <P align=center>total frames<NOBR> </NOBR></P></TD></TR>
            <TR>
              <TD width="100%" colSpan=2>
                <P align=center><INPUT onfocus=this.select(); onchange=convertIt(); 
                name=frameCount><NOBR><INPUT onclick=convertIt(); type=button value=Convert name=Button><INPUT type=reset value=Reset name=B1></NOBR></P>
                <HR>
              </TD></TR>
            <TR>
              <TD width="50%">
                <P align=center><NOBR>total minutes </NOBR></P></TD>
              <TD width="50%">
                <P align=center>correction</P></TD></TR>
            <TR>
              <TD width="100%" colSpan=2>
                <P align=center><INPUT value=0 name=minutes><INPUT value=0 
                name=correction></P>
                <HR>
              </TD></TR>
            <TR>
              <TD width="100%" colSpan=2>
                <P align=center>timecode with correction</P></TD></TR>
            <TR>
              <TD width="100%" colSpan=2>
                <P align=center><INPUT size=12 value=00:00:00:00 
              name=rightCode></P></TD></TR></TBODY></TABLE></CENTER></DIV></FIELDSET></FORM></TD></TR></TBODY></TABLE></CENTER></DIV></BODY></HTML>
    Any Suggestions?
    Quote Quote  
  2. Having never really written anything Java (script or otherwise), here is something to try. I believe what you were seeing was a rounding error. This should get around it. I know the equiv code in C++ is acurate, as I use it all the time profesionally (albeit sans floating point).

    --- CUT HERE ---
    else{
    iFrameCount = theForm.frameCount.value
    FramesPerSecond = (30*(1000/1001))
    secondsTotal = iFrameCount/FramesPerSecond
    secondsAbs = Math.floor (secondsTotal)
    SMPTE_Frames = Math.floor (((secondsTotal - secondsAbs) * FramesPerSecond) + 0.01)
    // How do we mod 60 in Java? Lets do it the hard way...
    SMPTE_Minutes = Math.floor (secondsAbs / 60)
    SMPTE_Seconds = secondsAbs - (SMPTE_Minutes * 60)
    SMPTE_Hours = Math.floor (SMPTE_Minutes / 60)
    SMPTE_Minutes = SMPTE_Minutes - (SMPTE_Hours * 60)

    hourText = SMPTE_Hours
    minText = SMPTE_Minutes
    secText = SMPTE_Seconds
    fraText = SMPTE_Frames

    if (SMPTE_Hours<10) hourText = "0" + hourText
    if (SMPTE_Minutes<10) minText = "0" + minText
    if (SMPTE_Seconds<10) secText = "0" + secText
    if (SMPTE_Frames<10) fraText = "0" + fraText

    theForm.rightCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    theForm.rightCode.select();
    }

    --- CUT HERE ---
    Quote Quote  
  3. After a few minutes of looking at the original code, I realised that the problem wasn't just a simple rounding error.

    NTSC has a frame rate of ~29.97 frames per second (~59.94 fields). The calculation of 30 * (1000/1001) yeilds ~29.97 for reasons I won't go into.

    SMPTE 30DF uses a FRAME RATE of 30FPS and does the hokey dropping of 2 frames every minute except on the 10th.

    If you look at what 30DF tries to do, you'll see it is doing 17982 frames in 10 minutes (at 30 FPS that would be 18000 frames). 18000 / 17982 comes out to a ratio identical to 30 / 29.97 (nearly NTSC perfect).

    So the issue wasn't rounding, but instead you were appling the concepts of SMPTE 30 Drop Frame to a NTSC 29.97 frame rate.

    I would HIGHLY recomend just using the code I wrote earlier vs. the hokey SMPTE 30DF code unless you are doing cell animation. If you are doing cell animation, stick with SMPTE 30DF at 30 FPS.

    Don't feel too bad, there is another JAVA calculator on the net that has the same bug (rougly). I think this was all triggered by a web page that was improperly punctuated. It correctly describes NTSC as 29.97 and then goes on to describe SMPTE 30DF. It can be missleading and the reader might think you need to place 30DF rules on a 29.97 framerate.

    Doing 30DF on a 29.97 frame rate would yeild a frame rate of ~29.94 FPS.

    Any time you want to check for rounding errors on a frame rate converter, just type in 20000. If should come out 00:11:07:10 (not 00:11:07:09 which is a rounding error). If you do the math, you'll see it is correct.
    Quote Quote  
  4. Ack, I may not have been clear...

    If you actually DO WANT the SMPTE 30DF, just take all the "*(1000/1001)" pieces out of your orriginal code. The "*(1000/1001)" is the NTSC frame rate, and for SMPTE 30 Drop Frame, you want 30 FPS (with the remainder of the algo to determine which frames to drop).
    Quote Quote  
  5. For SMPTE 30DF, use the following:

    --- CUT HERE ---

    // For SMPTE 30DF
    Frames_In_Ten_Minutes = 17982
    Frames_In_One_Minute = 1798
    Frames_In_One_Second = 30
    Seconds_In_Minute = 60

    iFrameCount = theForm.frameCount.value
    tenMinute = Math.floor (iFrameCount / Frames_In_Ten_Minutes)
    iFrameCount = iFrameCount - (tenMinute * Frames_In_Ten_Minutes)
    oneMinute = Math.floor (iFrameCount / Frames_In_One_Minute)
    iFrameCount = iFrameCount - (oneMinute * Frames_In_One_Minute)
    SMPTE_Minutes = (tenMinute * 10) + oneMinute
    SMPTE_Hours = Math.floor (SMPTE_Minutes / Seconds_In_Minute)
    SMPTE_Minutes = SMPTE_Minutes - (SMPTE_Hours * Seconds_In_Minute)
    SMPTE_Seconds = Math.floor (iFrameCount / Frames_In_One_Second)
    SMPTE_Frames = iFrameCount - (SMPTE_Seconds * Frames_In_One_Second)

    hourText = SMPTE_Hours
    minText = SMPTE_Minutes
    secText = SMPTE_Seconds
    fraText = SMPTE_Frames

    if (SMPTE_Hours<10) hourText = "0" + hourText
    if (SMPTE_Minutes<10) minText = "0" + minText
    if (SMPTE_Seconds<10) secText = "0" + secText
    if (SMPTE_Frames<10) fraText = "0" + fraText

    theForm.rightCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    theForm.rightCode.select();
    --- CUT HERE ---
    Quote Quote  
  6. I don't care what anyone says, C++ kicks Javas butt. However, for things like this, it seems pretty cool. Here is the variation of Simmon_Haddad's Java TimeCode that deals with both NTSC timecode as well as SMPTE 30DF timecode.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>Frame to NTSC Timecode Conversion</TITLE>
    <META http-equiv=Content-Language content=en-us>
    <META content="MSHTML 5.50.4207.2601" name=GENERATOR>
    <META content=FrontPage.Editor.Document name=ProgId>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT language=jscript>
    a=0
    function CalculateTimeCode(){
    if (isNaN(theForm.frameCount.value )) {
      theForm.reset();
      }
      else {
      // For NTSC 29.97
      iFrameCount = theForm.frameCount.value
      FramesPerSecond = (30*(1000/1001))
      secondsTotal = iFrameCount/FramesPerSecond
      secondsAbs = Math.floor (secondsTotal)
    
      NTSC_Frames = Math.floor (((secondsTotal - secondsAbs) * FramesPerSecond) + 0.01)
      NTSC_Minutes = Math.floor (secondsAbs / 60)
      NTSC_Seconds = secondsAbs - (NTSC_Minutes * 60)
      NTSC_Hours = Math.floor (NTSC_Minutes / 60)
      NTSC_Minutes = NTSC_Minutes - (NTSC_Hours * 60)
    
      hourText = NTSC_Hours
      minText  = NTSC_Minutes
      secText  = NTSC_Seconds
      fraText  = NTSC_Frames
    
      if (NTSC_Hours   < 10) hourText = "0" + hourText
      if (NTSC_Minutes < 10) minText  = "0" + minText
      if (NTSC_Seconds < 10) secText  = "0" + secText
      if (NTSC_Frames  < 10) fraText  = "0" + fraText
    
      theForm.NtscCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    
      // For SMPTE 30DF
      Frames_In_Ten_Minutes = 17982
      Frames_In_One_Minute  = 1798
      Frames_In_One_Second = 30
      Seconds_In_Minute = 60
    
      iFrameCount = theForm.frameCount.value
      tenMinute = Math.floor (iFrameCount / Frames_In_Ten_Minutes)
      iFrameCount = iFrameCount - (tenMinute * Frames_In_Ten_Minutes)
      oneMinute = Math.floor (iFrameCount / Frames_In_One_Minute)
      iFrameCount = iFrameCount - (oneMinute * Frames_In_One_Minute)
      SMPTE_Minutes = (tenMinute * 10) + oneMinute
      SMPTE_Hours = Math.floor (SMPTE_Minutes / Seconds_In_Minute)
      SMPTE_Minutes = SMPTE_Minutes - (SMPTE_Hours * Seconds_In_Minute)
      SMPTE_Seconds = Math.floor (iFrameCount / Frames_In_One_Second)
      SMPTE_Frames = iFrameCount - (SMPTE_Seconds * Frames_In_One_Second)
    
      hourText = SMPTE_Hours
      minText  = SMPTE_Minutes
      secText  = SMPTE_Seconds
      fraText  = SMPTE_Frames
    
      if (SMPTE_Hours   < 10) hourText = "0" + hourText
      if (SMPTE_Minutes < 10) minText  = "0" + minText
      if (SMPTE_Seconds < 10) secText  = "0" + secText
      if (SMPTE_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Smpte30DfCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
      theForm.NtscCode.select();
      }
    }
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <DIV align=center>
    <CENTER>
    <TABLE id=AutoNumber2 style="BORDER-COLLAPSE: collapse" borderColor=#111111
    cellSpacing=0 cellPadding=0 border=0>
      <TBODY>
      <TR>
        <TD width="100%">
          <FORM name=theForm onsubmit="convertIt();return false;">
          <FIELDSET
          style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"><LEGEND
          align=center>Frame to NTSC Timecode Conversion</LEGEND>
          <DIV align=center>
          <CENTER>
          <TABLE id=AutoNumber1 style="BORDER-COLLAPSE: collapse"
          borderColor=#111111 cellSpacing=0 cellPadding=0 border=0>
            <TBODY>
              <TR>
                <TD width="100%" colSpan=2>
                  <HR>
                    <P align=center>total frames<NOBR> </NOBR></P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT onfocus=this.select(); onchange=CalculateTimeCode();
                  name=frameCount><NOBR><INPUT onclick=convertIt(); type=button value=Convert name=Button><INPUT type=reset value=Reset name=B1></NOBR></P>
                  <HR>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center><NOBR>NTSC</NOBR></P>
                </TD>
                <TD width="50%">
                  <P align=center>SMPTE 30DF</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=NtscCode><INPUT value=00:00:00:00 name=Smpte30DfCode></P>
                </TD>
              </TR>
            </TBODY></TABLE></CENTER></DIV></FIELDSET></FORM></TD></TR></TBODY>
              </TABLE>
              </CENTER>
              </DIV>
    </BODY>
    </HTML>
    Again, this is just my take on what it should do. Sorry about all the posts. I guess the reason I'm so interested in the subject is that I too have missed the ability to get timecode from frame numbers without a calculator. Simmon_Haddad's Java Timecode converter is a pretty good idea.
    Quote Quote  
  7. Boy I must be BORED!
    Here is one that does:
    NTSC
    PAL
    SMPTE 30 DF (Drop Frame)
    SMPTE 30
    Film 24
    Film 23.976 (NTSC 3:2 Pulldown)

    I can't think of a single other timecode at the minute, so here it is:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>Frame to Timecode Conversion</TITLE>
    <META http-equiv=Content-Language content=en-us>
    <META content="MSHTML 5.50.4207.2601" name=GENERATOR>
    <META content=FrontPage.Editor.Document name=ProgId>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT language=jscript>
    a=0
    
    function CalculateFilm32PullDown(){
      // For NTSC Film 23.976
      iFrameCount = theForm.frameCount.value
      FramesPerSecond = 24000/1001
      secondsTotal = iFrameCount/FramesPerSecond
      secondsAbs = Math.floor (secondsTotal)
    
      Film_Frames = Math.floor (((secondsTotal - secondsAbs) * FramesPerSecond) + 0.01)
      Film_Minutes = Math.floor (secondsAbs / 60)
      Film_Seconds = secondsAbs - (Film_Minutes * 60)
      Film_Hours = Math.floor (Film_Minutes / 60)
      Film_Minutes = Film_Minutes - (Film_Hours * 60)
    
      hourText = Film_Hours
      minText  = Film_Minutes
      secText  = Film_Seconds
      fraText  = Film_Frames
    
      if (Film_Hours   < 10) hourText = "0" + hourText
      if (Film_Minutes < 10) minText  = "0" + minText
      if (Film_Seconds < 10) secText  = "0" + secText
      if (Film_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Film32Code.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateFilm24(){
      // For Film 24
      iFrameCount = theForm.frameCount.value
    
      FramesPerSecond = 24
      Film_Seconds = Math.floor (iFrameCount / FramesPerSecond)
      Film_Frames  = iFrameCount - (Film_Seconds * FramesPerSecond)
      Film_Minutes = Math.floor (Film_Seconds / 60)
      Film_Seconds = Film_Seconds - (Film_Minutes * 60)
      Film_Hours   = Math.floor (Film_Minutes / 60)
      Film_Minutes = Film_Minutes - (Film_Hours * 60)
    
      hourText = Film_Hours
      minText  = Film_Minutes
      secText  = Film_Seconds
      fraText  = Film_Frames
    
      if (Film_Hours   < 10) hourText = "0" + hourText
      if (Film_Minutes < 10) minText  = "0" + minText
      if (Film_Seconds < 10) secText  = "0" + secText
      if (Film_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Film24Code.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculatePal (){
      // For PAL
      iFrameCount = theForm.frameCount.value
    
      FramesPerSecond = 25
      PAL_Seconds = Math.floor (iFrameCount / FramesPerSecond)
      PAL_Frames  = iFrameCount - (PAL_Seconds * FramesPerSecond)
      PAL_Minutes = Math.floor (PAL_Seconds / 60)
      PAL_Seconds = PAL_Seconds - (PAL_Minutes * 60)
      PAL_Hours   = Math.floor (PAL_Minutes / 60)
      PAL_Minutes = PAL_Minutes - (PAL_Hours * 60)
    
      hourText = PAL_Hours
      minText  = PAL_Minutes
      secText  = PAL_Seconds
      fraText  = PAL_Frames
    
      if (PAL_Hours   < 10) hourText = "0" + hourText
      if (PAL_Minutes < 10) minText  = "0" + minText
      if (PAL_Seconds < 10) secText  = "0" + secText
      if (PAL_Frames  < 10) fraText  = "0" + fraText
    
      theForm.PalCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateSMPTE30 (){
      // For SMPTE 30
      iFrameCount = theForm.frameCount.value
    
      FramesPerSecond = 30
      SMPTE30_Seconds = Math.floor (iFrameCount / FramesPerSecond)
      SMPTE30_Frames  = iFrameCount - (SMPTE30_Seconds * FramesPerSecond)
      SMPTE30_Minutes = Math.floor (SMPTE30_Seconds / 60)
      SMPTE30_Seconds = SMPTE30_Seconds - (SMPTE30_Minutes * 60)
      SMPTE30_Hours   = Math.floor (SMPTE30_Minutes / 60)
      SMPTE30_Minutes = SMPTE30_Minutes - (SMPTE30_Hours * 60)
    
      hourText = SMPTE30_Hours
      minText  = SMPTE30_Minutes
      secText  = SMPTE30_Seconds
      fraText  = SMPTE30_Frames
    
      if (SMPTE30_Hours   < 10) hourText = "0" + hourText
      if (SMPTE30_Minutes < 10) minText  = "0" + minText
      if (SMPTE30_Seconds < 10) secText  = "0" + secText
      if (SMPTE30_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Smpte30Code.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateSMPTE30DF (){
      // For SMPTE 30DF
      Frames_In_Ten_Minutes = 17982
      Frames_In_One_Minute  = 1798
      Frames_In_One_Second = 30
      Seconds_In_Minute = 60
    
      iFrameCount = theForm.frameCount.value
      tenMinute = Math.floor (iFrameCount / Frames_In_Ten_Minutes)
      iFrameCount = iFrameCount - (tenMinute * Frames_In_Ten_Minutes)
      oneMinute = Math.floor (iFrameCount / Frames_In_One_Minute)
      iFrameCount = iFrameCount - (oneMinute * Frames_In_One_Minute)
      SMPTE_Minutes = (tenMinute * 10) + oneMinute
      SMPTE_Hours = Math.floor (SMPTE_Minutes / Seconds_In_Minute)
      SMPTE_Minutes = SMPTE_Minutes - (SMPTE_Hours * Seconds_In_Minute)
      SMPTE_Seconds = Math.floor (iFrameCount / Frames_In_One_Second)
      SMPTE_Frames = iFrameCount - (SMPTE_Seconds * Frames_In_One_Second)
    
      hourText = SMPTE_Hours
      minText  = SMPTE_Minutes
      secText  = SMPTE_Seconds
      fraText  = SMPTE_Frames
    
      if (SMPTE_Hours   < 10) hourText = "0" + hourText
      if (SMPTE_Minutes < 10) minText  = "0" + minText
      if (SMPTE_Seconds < 10) secText  = "0" + secText
      if (SMPTE_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Smpte30DfCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateNTSC (){
      // For NTSC 29.97
      iFrameCount = theForm.frameCount.value
      FramesPerSecond = (30*(1000/1001))
      secondsTotal = iFrameCount/FramesPerSecond
      secondsAbs = Math.floor (secondsTotal)
    
      NTSC_Frames = Math.floor (((secondsTotal - secondsAbs) * FramesPerSecond) + 0.01)
      NTSC_Minutes = Math.floor (secondsAbs / 60)
      NTSC_Seconds = secondsAbs - (NTSC_Minutes * 60)
      NTSC_Hours = Math.floor (NTSC_Minutes / 60)
      NTSC_Minutes = NTSC_Minutes - (NTSC_Hours * 60)
    
      hourText = NTSC_Hours
      minText  = NTSC_Minutes
      secText  = NTSC_Seconds
      fraText  = NTSC_Frames
    
      if (NTSC_Hours   < 10) hourText = "0" + hourText
      if (NTSC_Minutes < 10) minText  = "0" + minText
      if (NTSC_Seconds < 10) secText  = "0" + secText
      if (NTSC_Frames  < 10) fraText  = "0" + fraText
    
      theForm.NtscCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateTimeCode(){
    if (isNaN(theForm.frameCount.value )) {
      theForm.reset();
      }
      else {
      CalculateNTSC ()
      CalculateSMPTE30DF ()
      CalculatePal ()
      CalculateSMPTE30 ()
      CalculateFilm24 ()
      CalculateFilm32PullDown ()
    
      theForm.NtscCode.select()
      }
    }
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <DIV align=center>
    <CENTER>
    <TABLE id=AutoNumber2 style="BORDER-COLLAPSE: collapse" borderColor=#111111
    cellSpacing=0 cellPadding=0 border=0>
      <TBODY>
      <TR>
        <TD width="100%">
          <FORM name=theForm onsubmit="CalculateTimeCode();return false;">
          <FIELDSET
          style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"><LEGEND
          align=center>Frame to Timecode Conversion</LEGEND>
          <DIV align=center>
          <CENTER>
          <TABLE id=AutoNumber1 style="BORDER-COLLAPSE: collapse"
          borderColor=#111111 cellSpacing=0 cellPadding=0 border=0>
            <TBODY>
              <TR>
                <TD width="100%" colSpan=2>
                  <HR>
                    <P align=center>Enter Frame Number<NOBR> </NOBR></P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT onfocus=this.select(); onchange=CalculateTimeCode();
                  name=frameCount><NOBR><INPUT onclick=CalculateTimeCode(); type=button value=Convert name=Button><INPUT type=reset value=Reset name=B1></NOBR></P>
                  <HR>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center><NOBR>NTSC</NOBR></P>
                </TD>
                <TD width="50%">
                  <P align=center>SMPTE 30DF</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=NtscCode><INPUT value=00:00:00:00 name=Smpte30DfCode></P>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center><NOBR>PAL</NOBR></P>
                </TD>
                <TD width="50%">
                  <P align=center>SMPTE 30</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=PalCode><INPUT value=00:00:00:00 name=Smpte30Code></P>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center>Film 24</P>
                </TD>
                <TD width="50%">
                  <P align=center>Film 23.976</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=Film24Code><INPUT value=00:00:00:00 name=Film32Code></P>
                </TD>
              </TR>
            </TBODY></TABLE></CENTER></DIV></FIELDSET></FORM></TD></TR></TBODY>
              </TABLE>
              </CENTER>
              </DIV>
    </BODY>
    </HTML>
    Enjoy.
    Quote Quote  
  8. Well, I certainly wasn't expecting all that work on my behalf. Thank you, kmorger. I have been using TMPGEnc (with it's raw frame count) to find suitable frames for chaptermarks in Phillips VCD Toolkit, which, for NTSC, uses (I believe) NTSC 30 DF format. What I'll do is, I'll pick the suitable I-Frames in TMPGEnc, convert them to SMPTE timecode (using this handy converter), and compare the timecodes with those reported by Entry Point Assist and report back my results. Once again, thank you.

    Simon.
    Quote Quote  
  9. There was actually a minor bug in what I posted previously. It appears on multiples of frame numbers 17980 and 17981 for SMPTE 30DF. I hadn't posted the fix earlier as I wasn't sure anyone but me needed timecode from frame numbers. Anyway, the following addresses the issue:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>Frame to Timecode Conversion</TITLE>
    <META http-equiv=Content-Language content=en-us>
    <META content="MSHTML 5.50.4207.2601" name=GENERATOR>
    <META content=FrontPage.Editor.Document name=ProgId>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT language=jscript>
    a=0
    
    function CalculateFilm32PullDown(){
      // For NTSC Film 23.976
      iFrameCount = theForm.frameCount.value
      FramesPerSecond = 24000/1001
      secondsTotal = iFrameCount/FramesPerSecond
      secondsAbs = Math.floor (secondsTotal)
    
      Film_Frames = Math.floor (((secondsTotal - secondsAbs) * FramesPerSecond) + 0.01)
      Film_Minutes = Math.floor (secondsAbs / 60)
      Film_Seconds = secondsAbs - (Film_Minutes * 60)
      Film_Hours = Math.floor (Film_Minutes / 60)
      Film_Minutes = Film_Minutes - (Film_Hours * 60)
    
      hourText = Film_Hours
      minText  = Film_Minutes
      secText  = Film_Seconds
      fraText  = Film_Frames
    
      if (Film_Hours   < 10) hourText = "0" + hourText
      if (Film_Minutes < 10) minText  = "0" + minText
      if (Film_Seconds < 10) secText  = "0" + secText
      if (Film_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Film32Code.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateFilm24(){
      // For Film 24
      iFrameCount = theForm.frameCount.value
    
      FramesPerSecond = 24
      Film_Seconds = Math.floor (iFrameCount / FramesPerSecond)
      Film_Frames  = iFrameCount - (Film_Seconds * FramesPerSecond)
      Film_Minutes = Math.floor (Film_Seconds / 60)
      Film_Seconds = Film_Seconds - (Film_Minutes * 60)
      Film_Hours   = Math.floor (Film_Minutes / 60)
      Film_Minutes = Film_Minutes - (Film_Hours * 60)
    
      hourText = Film_Hours
      minText  = Film_Minutes
      secText  = Film_Seconds
      fraText  = Film_Frames
    
      if (Film_Hours   < 10) hourText = "0" + hourText
      if (Film_Minutes < 10) minText  = "0" + minText
      if (Film_Seconds < 10) secText  = "0" + secText
      if (Film_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Film24Code.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculatePal (){
      // For PAL
      iFrameCount = theForm.frameCount.value
    
      FramesPerSecond = 25
      PAL_Seconds = Math.floor (iFrameCount / FramesPerSecond)
      PAL_Frames  = iFrameCount - (PAL_Seconds * FramesPerSecond)
      PAL_Minutes = Math.floor (PAL_Seconds / 60)
      PAL_Seconds = PAL_Seconds - (PAL_Minutes * 60)
      PAL_Hours   = Math.floor (PAL_Minutes / 60)
      PAL_Minutes = PAL_Minutes - (PAL_Hours * 60)
    
      hourText = PAL_Hours
      minText  = PAL_Minutes
      secText  = PAL_Seconds
      fraText  = PAL_Frames
    
      if (PAL_Hours   < 10) hourText = "0" + hourText
      if (PAL_Minutes < 10) minText  = "0" + minText
      if (PAL_Seconds < 10) secText  = "0" + secText
      if (PAL_Frames  < 10) fraText  = "0" + fraText
    
      theForm.PalCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateSMPTE30 (){
      // For SMPTE 30
      iFrameCount = theForm.frameCount.value
    
      FramesPerSecond = 30
      SMPTE30_Seconds = Math.floor (iFrameCount / FramesPerSecond)
      SMPTE30_Frames  = iFrameCount - (SMPTE30_Seconds * FramesPerSecond)
      SMPTE30_Minutes = Math.floor (SMPTE30_Seconds / 60)
      SMPTE30_Seconds = SMPTE30_Seconds - (SMPTE30_Minutes * 60)
      SMPTE30_Hours   = Math.floor (SMPTE30_Minutes / 60)
      SMPTE30_Minutes = SMPTE30_Minutes - (SMPTE30_Hours * 60)
    
      hourText = SMPTE30_Hours
      minText  = SMPTE30_Minutes
      secText  = SMPTE30_Seconds
      fraText  = SMPTE30_Frames
    
      if (SMPTE30_Hours   < 10) hourText = "0" + hourText
      if (SMPTE30_Minutes < 10) minText  = "0" + minText
      if (SMPTE30_Seconds < 10) secText  = "0" + secText
      if (SMPTE30_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Smpte30Code.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateSMPTE30DF (){
      // For SMPTE 30DF
      Frames_In_Ten_Minutes = 17982
      Frames_In_One_Minute  = 1798
      Frames_In_One_Second = 30
      Seconds_In_Minute = 60
    
      iFrameCount = theForm.frameCount.value
      tenMinute = Math.floor (iFrameCount / Frames_In_Ten_Minutes)
      iFrameCount = iFrameCount - (tenMinute * Frames_In_Ten_Minutes)
      oneMinute = Math.floor (iFrameCount / Frames_In_One_Minute)
      // There are two frames at 17980 and 17981 that should still read 9.
      if (oneMinute > 9) oneMinute = 9
      iFrameCount = iFrameCount - (oneMinute * Frames_In_One_Minute)
      SMPTE_Minutes = (tenMinute * 10) + oneMinute
      SMPTE_Hours = Math.floor (SMPTE_Minutes / Seconds_In_Minute)
      SMPTE_Minutes = SMPTE_Minutes - (SMPTE_Hours * Seconds_In_Minute)
      SMPTE_Seconds = Math.floor (iFrameCount / Frames_In_One_Second)
      SMPTE_Frames = iFrameCount - (SMPTE_Seconds * Frames_In_One_Second)
    
      hourText = SMPTE_Hours
      minText  = SMPTE_Minutes
      secText  = SMPTE_Seconds
      fraText  = SMPTE_Frames
    
      if (SMPTE_Hours   < 10) hourText = "0" + hourText
      if (SMPTE_Minutes < 10) minText  = "0" + minText
      if (SMPTE_Seconds < 10) secText  = "0" + secText
      if (SMPTE_Frames  < 10) fraText  = "0" + fraText
    
      theForm.Smpte30DfCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateNTSC (){
      // For NTSC 29.97
      iFrameCount = theForm.frameCount.value
      FramesPerSecond = 30000/1001
      secondsTotal = iFrameCount/FramesPerSecond
      secondsAbs = Math.floor (secondsTotal)
    
      NTSC_Frames = Math.floor (((secondsTotal - secondsAbs) * FramesPerSecond) + 0.01)
      NTSC_Minutes = Math.floor (secondsAbs / 60)
      NTSC_Seconds = secondsAbs - (NTSC_Minutes * 60)
      NTSC_Hours = Math.floor (NTSC_Minutes / 60)
      NTSC_Minutes = NTSC_Minutes - (NTSC_Hours * 60)
    
      hourText = NTSC_Hours
      minText  = NTSC_Minutes
      secText  = NTSC_Seconds
      fraText  = NTSC_Frames
    
      if (NTSC_Hours   < 10) hourText = "0" + hourText
      if (NTSC_Minutes < 10) minText  = "0" + minText
      if (NTSC_Seconds < 10) secText  = "0" + secText
      if (NTSC_Frames  < 10) fraText  = "0" + fraText
    
      theForm.NtscCode.value = hourText + ":" + minText + ":" + secText + ":" + fraText
    }
    
    function CalculateTimeCode(){
    if (isNaN(theForm.frameCount.value )) {
      theForm.reset();
      }
      else {
      CalculateNTSC ()
      CalculateSMPTE30DF ()
      CalculatePal ()
      CalculateSMPTE30 ()
      CalculateFilm24 ()
      CalculateFilm32PullDown ()
    
      theForm.NtscCode.select()
      }
    }
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <DIV align=center>
    <CENTER>
    <TABLE id=AutoNumber2 style="BORDER-COLLAPSE: collapse" borderColor=#111111
    cellSpacing=0 cellPadding=0 border=0>
      <TBODY>
      <TR>
        <TD width="100%">
          <FORM name=theForm onsubmit="CalculateTimeCode();return false;">
          <FIELDSET
          style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"><LEGEND
          align=center>Frame to Timecode Conversion</LEGEND>
          <DIV align=center>
          <CENTER>
          <TABLE id=AutoNumber1 style="BORDER-COLLAPSE: collapse"
          borderColor=#111111 cellSpacing=0 cellPadding=0 border=0>
            <TBODY>
              <TR>
                <TD width="100%" colSpan=2>
                  <HR>
                    <P align=center>Enter Frame Number<NOBR> </NOBR></P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT onfocus=this.select(); onchange=CalculateTimeCode();
                  name=frameCount><NOBR><INPUT onclick=CalculateTimeCode(); type=button value=Convert name=Button><INPUT type=reset value=Reset name=B1></NOBR></P>
                  <HR>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center><NOBR>NTSC</NOBR></P>
                </TD>
                <TD width="50%">
                  <P align=center>SMPTE 30DF</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=NtscCode><INPUT value=00:00:00:00 name=Smpte30DfCode></P>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center><NOBR>PAL</NOBR></P>
                </TD>
                <TD width="50%">
                  <P align=center>SMPTE 30</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=PalCode><INPUT value=00:00:00:00 name=Smpte30Code></P>
                </TD>
              </TR>
              <TR>
                <TD width="50%">
                  <P align=center>Film 24</P>
                </TD>
                <TD width="50%">
                  <P align=center>Film 23.976</P>
                </TD>
              </TR>
              <TR>
                <TD width="100%" colSpan=2>
                  <P align=center><INPUT value=00:00:00:00 name=Film24Code><INPUT value=00:00:00:00 name=Film32Code></P>
                </TD>
              </TR>
            </TBODY></TABLE></CENTER></DIV></FIELDSET></FORM></TD></TR></TBODY>
              </TABLE>
              </CENTER>
              </DIV>
    </BODY>
    </HTML>
    The difference from before is that (in ConvertSMPTE30DF) it specificly checks for illegal 10 values in the minutes position and forces them to 9.

    Enjoy.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!