Hi all.
RE: Calculating "Hours/Mins" in a new tool, vbitcalc = DONE.
RE: Calculating Bitrate final MB or GB in a new tool, vbitcalc = DONE.
CHANGE LOG
01.26.05
* ADDed - 'size GB' feature .. (ie, 4059GB) field to bitrate box.
* ADDed - 'min' feature .. (ie, 2.51h:m) field.
* FIXED - hour/min bug. .. Was just haunting me.
.
.
I need help in calculating Minutes from Hours (ie, 1.30 vs. 1.50hr) in
an app I'm designing, and the problem I'm having is the way the Minutes are
calculated, from the hours. It's a little confusing but I'll try my best to explain.
Actually, the idea came up to incorporate this into a tool (something I've
ben slowly sculpturing) after reading a couple of threads and the issues
regarding bitrates, (the Minutes vs. Hours is my problem) I was invisioning the
times displaying in my tool as 1hr 40min ( or 1.40 ) that's when the idea
came to incorporate this as a feature in my tool, so that I can see both
time formats, because my's could really use the help.
Right now, inside the tool, I have it display like this:
90min / 1.50hr = 1 1/2 hrs
120min / 2.00hr = 2 hrs
150min / 2.50hr = 2 1/2 hrs
I want it to look like this:
90min / 1.30
120min / 2.00
150min / 2.30
I need to get the right side of the decimal ( ie, 2.50hr ) to change to .30
(for 30 minutes, or 1 hour and 30 minutes. As the user (me) goes up/down the scale,
the minutes change, on the right side. So, when I reach 2 hours, my time will
now display as 2.00, and so on.. 2.01; 2.02; 2.05; 2.10 etc etc)
The code I'm using (very rough, but works perfectly so far) is:
to give me 176min / 2.93hr, which I want to make, 176min / 2.51 insteadCode:tb1 := trackbar1.Position; st_minutes.Caption := floatTostr(tb1) + 'min / ' + floatTostrf((tb1/60),ffFixed,4,2)+'hr';
In one thread I read this evening, about bitrates based on a 2hr 51min capture,
(based on my tools calculations) it derived bitrate for 2hr 51min was: 3142
No overage was factor in here. I haven't decided on the method to use just yet.
Plus, I'm not sure which to use for best results.
(see pic above)
.
Inside the tool, I have a scale that the user (myself) can drag up/down and
watch the bitrates (and other info) change - WYSIWYG style.
.. Its not a perfect tool, but it sure helps me real quick when I'm reading the
.. posts here and trying to follow allow (but w/ my own tool) w/ a few other tids.
Thanks for any assist/suggestions,
-vhelp 3050
+ Reply to Thread
Results 1 to 7 of 7
-
-
If I understand correctly what you need then the code you need will look like:
Dim MinValue as integer
Dim HourValue as integer
Dim Duration as integer
Dim DurationFormated as string
Duration = 90
HourValue = Int(Duration / 60)
MinValue = Duration - HourValue * 60
DurationFormated = Format(HourValue,"#0") & "." & format(MinValue,"#0")The more I learn, the more I come to realize how little it is I know. -
I would have thought what you need to do was calculate the hours an minutes seperateley.
MyHours = Totalminutes/60 (integer arithmetic, ignore remainders)
MyMinutes = Totalminutes - (Hours * 60).
(or Totalminutes MOD 60)
You now have two numbers, whole hours and remaining minutes. You just need to format them into a string for display.There are 10 kinds of people in this world. Those that understand binary... -
Hi guys.
Thanks for your suggestions. I haven't tried them yet. I'm really too busy
with reading the forum posts (my hobby as become more reading lately)
and I'm also busy composing too many responses here, ( another)
I forgot to mention, I'm using Delph 6, but I'm sure that shouldn't matter too
much (I also know vb/vba etc)
Another item for the tool ..
I also want to add another "video info" item in my tool above, to where the
"bitrate required" is dispalyed at the bottom of the tool, to show the actual
calculated size in MB or GB required with a given bitrate.. So, for instance,
in the example above (my pic of the tool) the bitrate calculated was 3142,
but I'd like to add in a 3142 / 3.9G to this field, but I forgot how
to calculate that, so expect the 3.9g to be wrong.
.
I saw something detailing it a little bit, on doom9, but it was too confusing to
implement in my tool, so I'm looking around some more. If anyone knows of how to
implement the calculation (based off the above tool) I would very much appreciate it.
I know it's on here somewhere beried in these forums, but I wound't know where to
start the search. Anyways.. I hope someone can shed some light on it. Thanks.
.. I like the tool so far, and it really helps me when I'm reading some
.. posts and can whip out my tool (hehe) and plug in a few values, and get
.. more info than is pertaining to the posts I'm reading.
.. - - so far, the numbers seem to add up, according to the posts I've read
.. to date. That makes me feel real good about the tool.
.. ( well, the above did make sense to me)
But, I'll keep you guys posted w/ my latest results w/ this tool.
Thanks again guys.
-vhelp 3052 -
Ok. I finally squeezed time in to the two code-snip suggestions provided earlier
by SaSi and Bugster. Thanks to both for your efforts. I really appreciate it.
@ Bugster
I like your code snip because it was smaller and seemed to look like what I
needed to work inside my routine, but for some reason, it just wouldn't work
that way it thought it would in the tool. Anyways.
.. a few moreand ..
The short is, I had inter-placed some other variable in the code-snip and
it was part of the cause for throwing off the correct results. After much
debuggin (lots of it) I finall managed to make it work inside the tool.
The code snip from SaSi had finally worked with a few minor cosmetics.
Good work SaSi. Thanks again.
Here is the snip from my routine, case anyone else would ever needs to snip
some here or there in *their own* creations..
** Delphi 6 code snip **
Code:var MinValue: real; HourValue: real; Duration: real; . . duration := tb1; // TB1=trackbar control.. hourValue := int(duration / 60); minValue := duration - hourValue * 60; edit1.text := floatTostr((minValue)); st_minutes.Caption := floatTostr(tb1) + 'min / ' + floatTostrf((hourvalue),ffFixed,4,0) + '.'+ floatTostr((minValue))+'hr';
point across pretty clearly now. You should see the new version at
the top of the page (page 1)
--> to all,
Thanks to everyone for you helpful assistance. (Don't 4get my other issue
now.. bitrate)
Cheers,
-vhelp 3053 -
RE: finding SIZE from calc'ed bitrate..
to show the actual calculated size in MB or GB required with a
given bitrate..
(actually in a thread/topic, and RAILheadDesign.com and I had asked questions on)
over here:
* Bitrate Calculator Question...
Wow. took me all evening/night to find this answer. Pfew!!
You can view the revised tool at the top of this page (page 1)
Oh yeah.. thanks Jim
Thanks all, for your assistance,
-vhelp 3055
Similar Threads
-
Am I calculating resolution correctly?
By alcOre in forum Newbie / General discussionsReplies: 2Last Post: 24th Sep 2009, 07:37 -
Calculating Video Length
By scan in forum Newbie / General discussionsReplies: 3Last Post: 1st Nov 2008, 12:33 -
Math: Equation / Formula questions
By vhelp in forum ProgrammingReplies: 7Last Post: 27th Jul 2008, 16:06 -
math problem help?
By lordsmurf in forum Off topicReplies: 4Last Post: 25th Feb 2008, 23:52 -
How to burn a 157 mins. video on a 120 mins. dvd
By Gerald Sr. in forum Authoring (DVD)Replies: 2Last Post: 20th Jan 2008, 02:19