VideoHelp Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Member vhelp's Avatar
    Join Date
    Mar 2001
    Location
    New York
    Search Comp PM
    i'm trying to calculate the duration in microseconds (µs) the same way that virtualdub (information screen) calculates it but am having trouble getting the algo to properly show 33667µs.

    29.970 fps = 33667µs
    23.976 fps = 41708µs
    25.000 fps = 40000µs
    ..

    given dwScale=1001 (for video/interlace) and dwRate=30000 written to the avi header comes out wrong:

    1001 * 30.000 = 33.3667
    1000 * 29.970 = 33.3667
    1001 * 29970 = 0.0334
    1000 * 29970 = 0.0334

    i know i can just hold the values in a list internally but i need it to calculate in case the framerate is different and wouldn't be in a list.

    this is for a raw bmp2avi app i'm working on and want to show this value in the gui when the user sets the parameters up. thank you.

    Last edited by vhelp; 22nd Mar 2013 at 22:57.
    Quote Quote  
  2. Why don't you just look at the VirtualDub source? And µs is microseconds (1/1000000), not milliseconds (1/1000). It looks to me like it's simply scale/rate * 1000000. I think "29.970 fps = 33667µs" is a typo on your part:

    Click image for larger version

Name:	info.png
Views:	557
Size:	24.8 KB
ID:	16866

    That was from a file with rate=30000, scale=1001. 1001 / 30000 * 1000000 = 33367 rounded to the nearest microsecond.
    Last edited by jagabo; 22nd Mar 2013 at 21:24.
    Quote Quote  
  3. Member vhelp's Avatar
    Join Date
    Mar 2001
    Location
    New York
    Search Comp PM
    [solved]

    thank you for the tip, jagabo. i knew i would have to trial and error until i finally figured it out.

    Code:
    procedure TForm1.cbxFrameRateChange(Sender: TObject);
    begin
      case cbxFrameRate.ItemIndex of
        2: sb1.Panels[0].Text := inttostr(round( (100100/24000000)*10000000 ))+'µs'; //film,  41708µs
        5: sb1.Panels[0].Text := inttostr(round( (100101/30000000)*10000000 ))+'µs'; //video, 33367µs
      end;
    end;
    Quote Quote  



Similar Threads

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