Important alert: (current site time 7/16/2013 5:30:34 AM EDT)
 

VB icon

Adam's Video Bitrate Calculator v3.4

Email
Submitted on: 11/6/2006 8:12:11 AM
By: Adam *  
Level: Intermediate
User Rating: By 1 Users
Compatibility: Delphi 7
Views: 9137
(About the author)
 
     This program was designed to be used as a Video Bitrate Calculator for determining the maximum quality possible based on the file size required, the audio quality and the length of the video/movie.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
!**************************************
! Name: Adam's Video Bitrate Calculator v3.4
! Description:This program was designed to be used as a Video Bitrate Calculator for determining the maximum quality possible based on the file size required, the audio quality and the length of the video/movie.
! By: Adam *
!
! Side Effects:do not enter letters into the input boxes...
!
!This code is copyrighted and has! limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1785&lngWId=7!for details.!**************************************

unit Bitrate_Calc;
interface
uses
	Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, ShellAPI, StdCtrls, ExtCtrls, ComCtrls, Math, XPMan;
const
 WM_NOTIFYICON = WM_USER+333;
type
	TOperation = (NoOperation, Add, Subtract, Multiply,
 	Divide, RaiseToPower, IntModulus, IntDivide);
	TVBC = class(TForm)
		Button1: TButton;
		Button2: TButton;
		Button3: TButton;
		Button4: TButton;
		Button5: TButton;
		Button6: TButton;
		Button7: TButton;
		Button8: TButton;
		Button9: TButton;
		Button0: TButton;
		ButtonDecimal: TButton;
		ButtonClear: TButton;
		ButtonAdd: TButton;
		ButtonSub: TButton;
		ButtonEqual: TButton;
ButtonDivide: TButton;
		ButtonMultiply: TButton;
		ButtonSin: TButton;
		ButtonCos: TButton;
		ButtonTan: TButton;
ButtonInverse: TButton;
		ButtonSquare: TButton;
		ButtonRoot: TButton;
		ButtonFactorial: TButton;
		ButtonPi: TButton;
		ButtonDIV: TButton;
ButtonMOD: TButton;
		ButtonPlusMinus: TButton;
ButtonRaiseToPower: TButton;
EditBox: TMemo;
Label1: TLabel;
Time: TLabel;
NormCalc1: TImage;
NormCalc2: TImage;
GroupBox2: TGroupBox;
GroupBox4: TGroupBox;
Image3: TImage;
MBLabel: TLabel;
SBox: TEdit;
MBCheck: TRadioButton;
GBCheck: TRadioButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
GroupBox6: TGroupBox;
VBLabel: TLabel;
GroupBox3: TGroupBox;
Image2: TImage;
EstTime: TLabel;
mpgLabel2: TLabel;
mpgLabel1: TLabel;
mpgLabel4: TLabel;
mpgLabel3: TLabel;
mpgLabel5: TLabel;
mpgLabelTime: TLabel;
fpsbox1: TComboBox;
fpsbox2: TComboBox;
Normal: TRadioButton;
HH: TRadioButton;
P: TRadioButton;
HT: TRadioButton;
HD: TRadioButton;
GroupBox5: TGroupBox;
Image1: TImage;
Audiodrp: TComboBox;
Timer1: TTimer;
Timer2: TTimer;
Open: TOpenDialog;
Button10: TButton;
XPManifest1: TXPManifest;
AdamAbout: TLabel;
Timer3: TTimer;
hrsEdit: TEdit;
UpDownhrs: TUpDown;
hrsLabel: TLabel;
minEdit: TEdit;
UpDownmin: TUpDown;
minLabel: TLabel;
secEdit: TEdit;
UpDownsec: TUpDown;
secLabel: TLabel;
Timer4: TTimer;
DiscEdit: TEdit;
UpDown1: TUpDown;
DiscDrpDwn: TComboBox;
Label2: TLabel;
mpgLabel6: TLabel;
mpgLabel7: TLabel;
Label3: TLabel;
SSaver: TComboBox;
		procedure Button1Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
		procedure ButtonDecimalClick(Sender: TObject);
		procedure ButtonClearClick(Sender: TObject);
		procedure ButtonAddClick(Sender: TObject);
		procedure ButtonEqualClick(Sender: TObject);
		procedure ButtonSubClick(Sender: TObject);
		procedure ButtonMultiplyClick(Sender: TObject);
		procedure ButtonDivideClick(Sender: TObject);
		procedure ButtonPlusMinusClick(Sender: TObject);
procedure ButtonMODClick(Sender: TObject);
procedure ButtonDIVClick(Sender: TObject);
		procedure ButtonSinClick(Sender: TObject);
		procedure ButtonTanClick(Sender: TObject);
		procedure ButtonCosClick(Sender: TObject);
		procedure ButtonPiClick(Sender: TObject);
		procedure ButtonInverseClick(Sender: TObject);
		procedure ButtonRootClick(Sender: TObject);
		procedure ButtonSqrClick(Sender: TObject);
procedure ButtonRaiseToPowerClick(Sender: TObject);
		procedure ButtonFactorialClick(Sender: TObject);
		procedure FormKeyPress(Sender: TObject; var Key: Char);
		procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure CalcShow(Sender: TObject);
procedure CalcHide(Sender: TObject);
procedure AboutClick(Sender: TObject);
procedure RunningTime(Sender: TObject);
procedure Timer4Timer(Sender: TObject);
	public
		{ Public declarations }
Time1:integer;
TrayIcon: TNotifyIconData;
HMainIcon: HICON;
Procedure ClickTrayIcon(var msg: TMessage); message WM_NOTIFYICON;
Procedure MinimizeClick(Sender:TObject);
	private
		{ Private declarations }
 	Button: TButton;
		CurrentOperation: TOperation;
		Result: Double;
		Number: Double;
		NumberInDisplay: Double;
		FirstDigit: Boolean;
		DecimalPlaces: Integer;
		FirstNumber: Boolean;
		procedure UpdateDisplay(NumberToShow: Double);
		procedure ClearDisplay();
		procedure ProcessCalculation();
		procedure PrepareForUserInput();
		procedure PrepareForBinaryOperator();
		procedure PrepareForUnaryOperator();
	end;
var
	VBC: TVBC;
implementation
uses AboutForm;
{$R *.DFM}
resourcestring
	ErrorDivisionByZero	= 'Cannot Divide by Zero!';
	ErrorOverflow				= 'Number too Large';
	ErrorResultOverflow	= 'Overflow Error in the resulting number';
	ErrorNegativeRoot		= 'Cannot Square rooting a negative number';
Function CalcFractionalPart(Places: Integer):Double;
Var FractionalValue:Double;
 Radix:integer;
Begin
 FractionalValue:=1.0;
 for Radix:=1 to Places do
 FractionalValue:=FractionalValue / 10.0;
 CalcFractionalPart:=FractionalValue;
End;
Procedure TVBC.UpdateDisplay(NumberToShow: Double);
Var TempString:string;
Begin
 NumberInDisplay := NumberToShow;
 If DecimalPlaces > 1 then
 TempString:=FloatToStrF(NumberToShow, ffFixed, 15, DecimalPlaces - 1)
 else
 TempString:=FloatToStr(NumberToShow);
 If StrPos(PChar(TempString), '.') = nil then
 TempString:=TempString + '.';
 EditBox.Clear;
 EditBox.Text:=TempString;
End;
Procedure TVBC.ClearDisplay();
Begin
 Result:=0.0;
 Number:=0.0;
 CurrentOperation:=NoOperation;
 FirstDigit:=True;
 FirstNumber:=True;
 DecimalPlaces:=0;
 UpdateDisplay(Result);
End;
Procedure TVBC.FormCreate(Sender: TObject);
Begin
 fpsbox1.ItemIndex:=15;
 fpsbox2.ItemIndex:=15;
 DiscDrpDwn.ItemIndex:=0;
 Audiodrp.ItemIndex:=5;
 SSaver.ItemIndex:=0;
 Button:=Tbutton.Create(self);
 ClearDisplay();
 HMainIcon:=LoadIcon(MainInstance, 'MAINICON');
 Shell_NotifyIcon(NIM_DELETE, @TrayIcon);
 with trayIcon do
 Begin
 cbSize:=sizeof(TNotifyIconData);
 Wnd:=handle;
 uID:=123;
 uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
 uCallbackMessage:=WM_NOTIFYICON;
 hIcon:=HMainIcon;
 szTip:='Adam''s Video Bitrate Calculator v3.4';
 End;
 Application.OnMinimize:=MinimizeClick;
End;
Procedure TVBC.PrepareForUserInput();
Begin
 FirstDigit:=True;
 DecimalPlaces:=0;
End;
Procedure TVBC.PrepareForBinaryOperator();
Begin
 If FirstNumber then
 Begin
 FirstNumber:=False;
 If CurrentOperation = NoOperation then
 Begin
Result:=Number;
 End;
 End
 else
 ProcessCalculation();
End;
Procedure TVBC.PrepareForUnaryOperator();
Begin
 If FirstNumber then
		 CurrentOperation:=NoOperation;
End;
Procedure TVBC.Button1Click(Sender: TObject);
Begin
 If Sender = Button1 then
 Button:=Button1
 else
 If Sender = Button2 then
 Button:=Button2
 else
 If Sender = Button3 then
 Button:=Button3
 else
 If Sender = Button4 then
 Button:=Button4
 else
 If Sender = Button5 then
 Button:=Button5
 else
 If Sender = Button6 then
 Button:=Button6
 else
 If Sender = Button7 then
 Button:=Button7
 else
 If Sender = Button8 then
 Button:=Button8
 else
 If Sender = Button9 then
 Button:=Button9
 else
 If Sender = Button0 then
 Button:=Button0;
 If FirstDigit then
 Begin
 Number:=StrToInt(Button.Caption);
 UpdateDisplay(Number);
 FirstDigit:=False;
 End
 else
 Begin
 If DecimalPlaces >= 1 then
 Begin
Number:=Int(Abs(Number)) + Frac(Abs(Number)) + (CalcFractionalPart(DecimalPlaces) * StrToInt(Button.Caption));
Inc(DecimalPlaces);
UpdateDisplay(Number);
 End
 else
 Begin
try
 Number:=(abs(Number) * 10) + StrToInt(Button.Caption);
 UpdateDisplay(Number)
except
 Begin
 ShowMessage(ErrorOverflow);
 ClearDisplay();
 End;
End;
 End;
 End;
End;
Procedure TVBC.ButtonDecimalClick(Sender: TObject);
Begin
 If DecimalPlaces <= 1 then
 Begin
 If FirstDigit then
 Begin
Number:=0.0;
UpdateDisplay(Number)
 End;
 DecimalPlaces:=1;
 FirstDigit:=False
 End;
End;
Procedure TVBC.ButtonPlusMinusClick(Sender: TObject);
Begin
 PrepareForUnaryOperator();
 Number:=-1 * NumberInDisplay;
 UpdateDisplay(Number);
 PrepareForUserInput();
End;
Procedure TVBC.ButtonClearClick(Sender: TObject);
Begin
 ClearDisplay();
End;
Procedure TVBC.ProcessCalculation();
Var TempResult:Double;
Begin
 try
case CurrentOperation of
Add:
Begin
 try
TempResult:=Result + Number;
Result:=TempResult;
UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
Subtract:
Begin
 try
TempResult:=Result - Number;
Result:=TempResult;
UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
Divide:
Begin
 If IsZero(Number) then
 ShowMessage(ErrorDivisionByZero)
 else
 Begin
 try
 TempResult:=Result / Number;
 Result:=TempResult;
 UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
 End;
End;
Multiply:
Begin
 try
TempResult:=Result * Number;
Result:=TempResult;
UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
 		RaiseToPower:
Begin
 try
TempResult:=Power(Result, Number);
Result:=TempResult;
UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
IntDivide:
Begin
 If Trunc(Number) = 0 then
 ShowMessage(ErrorDivisionByZero)
 else
 Begin
 try
 TempResult:=Trunc(Result) DIV Trunc(Number);
 Result:=TempResult;
 UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
 End;
End;
IntModulus:
Begin
 If Trunc(Number) = 0 then
 ShowMessage(ErrorDivisionByZero)
 else
 Begin
 try
 TempResult:=Trunc(Result) MOD Trunc(Number);
 Result:=TempResult;
 UpdateDisplay(Result);
 except
ShowMessage(ErrorResultOverflow);
 End;
 End;
End;
NoOperation:
Begin
 Result:=Number;
 PrepareForUserInput();
 FirstNumber:=True;
End;
 End;
 except
 on EIntOverflow do
ShowMessage(ErrorResultOverflow);
 on EOverflow do
ShowMessage(ErrorResultOverflow);
 on EZeroDivide do
				ShowMessage(ErrorDivisionByZero);
 on EMathError do
 		ShowMessage('Unexplained Math Error!');
 End;
End;
Procedure TVBC.ButtonEqualClick(Sender: TObject);
Begin
 ProcessCalculation();
 PrepareForUserInput();
 FirstNumber:=True;
End;
Procedure TVBC.ButtonAddClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=Add;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonSubClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=Subtract;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonDivideClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=Divide;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonMultiplyClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=Multiply;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonMODClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=IntModulus;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonDIVClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=IntDivide;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonRaiseToPowerClick(Sender: TObject);
Begin
 PrepareForBinaryOperator();
 CurrentOperation:=RaiseToPower;
 PrepareForUserInput();
End;
Procedure TVBC.ButtonPiClick(Sender: TObject);
Begin
 PrepareForUserInput();
 Number:=Pi;
 UpdateDisplay(Number);
End;
Procedure TVBC.ButtonSinClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 try
TempResult:=Sin(NumberInDisplay);
PrepareForUserInput();
Number:=TempResult;
UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow)
 End;
End;
Procedure TVBC.ButtonTanClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 try
TempResult:=Tan(NumberInDisplay);
PrepareForUserInput();
Number:=TempResult;
UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
Procedure TVBC.ButtonCosClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 try
TempResult:=Cos(NumberInDisplay);
PrepareForUserInput();
Number:=TempResult;
UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
Procedure TVBC.ButtonInverseClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 TempResult:=NumberInDisplay;
 If IsZero(TempResult) then
 ShowMessage(ErrorDivisionByZero)
 else
 Begin
 try
 TempResult:=1.0 / TempResult;
 PrepareForUserInput();
 Number:=TempResult;
 UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow);
 End;
 End;
End;
Procedure TVBC.ButtonRootClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 TempResult:=NumberInDisplay;
 If TempResult < 0.0 then
 ShowMessage(ErrorNegativeRoot)
 else
 Begin
 try
 TempResult:=Sqrt(TempResult);
 PrepareForUserInput();
 Number:=TempResult;
 UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow);
 End;
		End;
End;
Procedure TVBC.ButtonSqrClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 try
TempResult:=Sqr(NumberInDisplay);
PrepareForUserInput();
Number:=TempResult;
UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
Function Factorial(n : Double) : Double;
Begin
 If n <= 1.0 then
 Result:=1.0
 else
 try
Result:=n * Factorial(n - 1.0);
 except
Result:=0;
 End;
End;
Procedure TVBC.ButtonFactorialClick(Sender: TObject);
Var TempResult:Double;
Begin
 PrepareForUnaryOperator();
 try
TempResult:=Factorial(NumberInDisplay);
PrepareForUserInput();
Number:=TempResult;
UpdateDisplay(Number);
 except
ShowMessage(ErrorResultOverflow);
 End;
End;
Procedure TVBC.FormKeyPress(Sender: TObject; var Key: Char);
Begin
 case Key of
 '1': Button1.Click;
 '2': Button2.Click;
 '3': Button3.Click;
 '4': Button4.Click;
 '5': Button5.Click;
 '6': Button6.Click;
 '7': Button7.Click;
 '8': Button8.Click;
 '9': Button9.Click;
 '0': Button0.Click;
 '.': ButtonDecimal.Click;
 '+': ButtonAdd.Click;
 '-': ButtonSub.Click;
 '/': ButtonDivide.Click;
 '*': ButtonMultiply.Click;
 '=': ButtonEqual.Click;
 End;
End;
Procedure TVBC.Timer1Timer(Sender: TObject);
Var hrs, min, sec, b, c, e, f, n, y:integer;
 GB, Size, Total, fps:double;
 Audio, d, Length, fpsrate1, fpsrate2:string;
 a, x:real;
Begin
 If hrsEdit.Text='' then
 hrs:=0;
 If hrsEdit.Text='0' then
 hrs:=0;
 If hrsEdit.Text='1' then
 hrs:=1;
 If hrsEdit.Text='2' then
 hrs:=2;
 If hrsEdit.Text='3' then
 hrs:=3;
 If hrsEdit.Text='4' then
 hrs:=4;
 If hrsEdit.Text='5' then
 hrs:=5;
 If hrsEdit.Text='6' then
 hrs:=6;
 If hrsEdit.Text='7' then
 hrs:=7;
 If hrsEdit.Text='8' then
 hrs:=8;
 If hrsEdit.Text='9' then
 hrs:=9;
 If hrsEdit.Text='10' then
 hrs:=10;
 If minEdit.Text='' then
 min:=0;
 If minEdit.Text='0' then
 min:=0;
 If minEdit.Text='1' then
 min:=1;
 If minEdit.Text='2' then
 min:=2;
 If minEdit.Text='3' then
 min:=3;
 If minEdit.Text='4' then
 min:=4;
 If minEdit.Text='5' then
 min:=5;
 If minEdit.Text='6' then
 min:=6;
 If minEdit.Text='7' then
 min:=7;
 If minEdit.Text='8' then
 min:=8;
 If minEdit.Text='9' then
 min:=9;
 If minEdit.Text='10' then
 min:=10;
 If minEdit.Text='11' then
 min:=11;
 If minEdit.Text='12' then
 min:=12;
 If minEdit.Text='13' then
 min:=13;
 If minEdit.Text='14' then
 min:=14;
 If minEdit.Text='15' then
 min:=15;
 If minEdit.Text='16' then
 min:=16;
 If minEdit.Text='17' then
 min:=17;
 If minEdit.Text='18' then
 min:=18;
 If minEdit.Text='19' then
 min:=19;
 If minEdit.Text='20' then
 min:=20;
 If minEdit.Text='21' then
 min:=21;
 If minEdit.Text='22' then
 min:=22;
 If minEdit.Text='23' then
 min:=23;
 If minEdit.Text='24' then
 min:=24;
 If minEdit.Text='25' then
 min:=25;
 If minEdit.Text='26' then
 min:=26;
 If minEdit.Text='27' then
 min:=27;
 If minEdit.Text='28' then
 min:=28;
 If minEdit.Text='29' then
 min:=29;
 If minEdit.Text='30' then
 min:=30;
 If minEdit.Text='31' then
 min:=31;
 If minEdit.Text='32' then
 min:=32;
 If minEdit.Text='33' then
 min:=33;
 If minEdit.Text='34' then
 min:=34;
 If minEdit.Text='35' then
 min:=35;
 If minEdit.Text='36' then
 min:=36;
 If minEdit.Text='37' then
 min:=37;
 If minEdit.Text='38' then
 min:=38;
 If minEdit.Text='39' then
 min:=39;
 If minEdit.Text='40' then
 min:=40;
 If minEdit.Text='41' then
 min:=41;
 If minEdit.Text='42' then
 min:=42;
 If minEdit.Text='43' then
 min:=43;
 If minEdit.Text='44' then
 min:=44;
 If minEdit.Text='45' then
 min:=45;
 If minEdit.Text='46' then
 min:=46;
 If minEdit.Text='47' then
 min:=47;
 If minEdit.Text='48' then
 min:=48;
 If minEdit.Text='49' then
 min:=49;
 If minEdit.Text='50' then
 min:=50;
 If minEdit.Text='51' then
 min:=51;
 If minEdit.Text='52' then
 min:=52;
 If minEdit.Text='53' then
 min:=53;
 If minEdit.Text='54' then
 min:=54;
 If minEdit.Text='55' then
 min:=55;
 If minEdit.Text='56' then
 min:=56;
 If minEdit.Text='57' then
 min:=57;
 If minEdit.Text='58' then
 min:=58;
 If secEdit.Text='59' then
 sec:=59;
 If secEdit.Text='' then
 sec:=0;
 If secEdit.Text='0' then
 sec:=0;
 If secEdit.Text='1' then
 sec:=1;
 If secEdit.Text='2' then
 sec:=2;
 If secEdit.Text='3' then
 sec:=3;
 If secEdit.Text='4' then
 sec:=4;
 If secEdit.Text='5' then
 sec:=5;
 If secEdit.Text='6' then
 sec:=6;
 If secEdit.Text='7' then
 sec:=7;
 If secEdit.Text='8' then
 sec:=8;
 If secEdit.Text='9' then
 sec:=9;
 If secEdit.Text='10' then
 sec:=10;
 If secEdit.Text='11' then
 sec:=11;
 If secEdit.Text='12' then
 sec:=12;
 If secEdit.Text='13' then
 sec:=13;
 If secEdit.Text='14' then
 sec:=14;
 If secEdit.Text='15' then
 sec:=15;
 If secEdit.Text='16' then
 sec:=16;
 If secEdit.Text='17' then
 sec:=17;
 If secEdit.Text='18' then
 sec:=18;
 If secEdit.Text='19' then
 sec:=19;
 If secEdit.Text='20' then
 sec:=20;
 If secEdit.Text='21' then
 sec:=21;
 If secEdit.Text='22' then
 sec:=22;
 If secEdit.Text='23' then
 sec:=23;
 If secEdit.Text='24' then
 sec:=24;
 If secEdit.Text='25' then
 sec:=25;
 If secEdit.Text='26' then
 sec:=26;
 If secEdit.Text='27' then
 sec:=27;
 If secEdit.Text='28' then
 sec:=28;
 If secEdit.Text='29' then
 sec:=29;
 If secEdit.Text='30' then
 sec:=30;
 If secEdit.Text='31' then
 sec:=31;
 If secEdit.Text='32' then
 sec:=32;
 If secEdit.Text='33' then
 sec:=33;
 If secEdit.Text='34' then
 sec:=34;
 If secEdit.Text='35' then
 sec:=35;
 If secEdit.Text='36' then
 sec:=36;
 If secEdit.Text='37' then
 sec:=37;
 If secEdit.Text='38' then
 sec:=38;
 If secEdit.Text='39' then
 sec:=39;
 If secEdit.Text='40' then
 sec:=40;
 If secEdit.Text='41' then
 sec:=41;
 If secEdit.Text='42' then
 sec:=42;
 If secEdit.Text='43' then
 sec:=43;
 If secEdit.Text='44' then
 sec:=44;
 If secEdit.Text='45' then
 sec:=45;
 If secEdit.Text='46' then
 sec:=46;
 If secEdit.Text='47' then
 sec:=47;
 If secEdit.Text='48' then
 sec:=48;
 If secEdit.Text='49' then
 sec:=49;
 If secEdit.Text='50' then
 sec:=50;
 If secEdit.Text='51' then
 sec:=51;
 If secEdit.Text='52' then
 sec:=52;
 If secEdit.Text='53' then
 sec:=53;
 If secEdit.Text='54' then
 sec:=54;
 If secEdit.Text='55' then
 sec:=55;
 If secEdit.Text='56' then
 sec:=56;
 If secEdit.Text='57' then
 sec:=57;
 If secEdit.Text='58' then
 sec:=58;
 If secEdit.Text='59' then
 sec:=59;
 Length:=(IntToStr((hrs*3600)+(min*60)+sec));
 If Audiodrp.Text='80 Kbps' then
 Audio:=(IntToStr(80));
 If Audiodrp.Text='96 Kbps' then
 Audio:=(IntToStr(96));
 If Audiodrp.Text='128 Kbps' then
 Audio:=(IntToStr(128));
 If Audiodrp.Text='160 Kbps' then
 Audio:=(IntToStr(160));
 If Audiodrp.Text='192 Kbps' then
 Audio:=(IntToStr(192));
 If Audiodrp.Text='224 Kbps' then
 Audio:=(IntToStr(224));
 If Audiodrp.Text='256 Kbps' then
 Audio:=(IntToStr(256));
 If Audiodrp.Text='320 Kbps' then
 Audio:=(IntToStr(320));
 If DiscDrpDwn.Text='789 MB (1 VCD)' then
 Begin
 DiscEdit.Enabled:=True;
 If DiscEdit.Text='1' then
 Begin
SBox.Text:='789';
Size:=789;
MBCheck.Visible:=True;
GBCheck.Enabled:=True;
 End;
 If DiscEdit.Text='2' then
 Begin
SBox.Text:='1578';
Size:=1578;
MBCheck.Visible:=True;
GBCheck.Enabled:=True;
 End;
 If DiscEdit.Text='3' then
 Begin
SBox.Text:='2367';
Size:=2367;
MBCheck.Visible:=True;
GBCheck.Enabled:=True;
 End;
 If DiscEdit.Text='4' then
 Begin
SBox.Text:='3156';
Size:=3156;
MBCheck.Visible:=True;
GBCheck.Enabled:=True;
 End;
 If DiscEdit.Text='5' then
 Begin
SBox.Text:='3945';
Size:=3945;
MBCheck.Visible:=True;
GBCheck.Enabled:=True;
 End;
 End;
 If DiscDrpDwn.Text='Custom...' then
 Begin
 If GBCheck.Checked then
 Begin
SBox.Text:='789';
DiscEdit.Text:='1';
GBCheck.Checked:=False;
MBCheck.Checked:=True;
 End;
 If SBox.Text='' then
 Begin
SBox.Text:='0';
y:=0;
 End;
 DiscEdit.Enabled:=False;
 Size:=(StrToInt(SBox.Text));
 GBCheck.Enabled:=False;
 End;
 If RadioButton1.Checked=True then
 Begin
 mpgLabel1.Visible:=True;
 mpgLabel2.Visible:=True;
 mpgLabel3.Visible:=True;
 mpgLabel4.Visible:=True;
 mpgLabel5.Top:=84;
 mpgLabel6.Visible:=True;
 mpgLabel7.Visible:=True;
 mpgLabelTime.Top:=84;
 fpsbox1.Visible:=True;
 fpsbox2.Visible:=True;
 EstTime.Visible:=True;
 Normal.Visible:=False;
 HH.Visible:=False;
 P.Visible:=False;
 HT.Visible:=False;
 HD.Visible:=False;
 If Length=(IntToStr(0)) then
 Begin
hrsEdit.Text:='1';
minEdit.Text:='30';
secEdit.Text:='0';
ShowMessage('Cannot divide by zero');
 End
 else
 Total:=(Size*1024-((StrToInt(Length))*((StrToInt(Audio)) / 8))) / (StrToInt(Length))*8;
 a:=(0.9894);
 x:=(Round((Total * a))*1.007);
 y:=(Round(x));
 VBLabel.Caption:=(FloatToStr(y)) + ' KBits/s';
 End;
 If RadioButton2.Checked=True then
 Begin
 mpgLabel1.Visible:=False;
 mpgLabel2.Visible:=False;
 mpgLabel3.Visible:=False;
 mpgLabel4.Visible:=False;
 mpgLabel5.Top:=102;
 mpgLabel6.Visible:=False;
 mpgLabel7.Visible:=False;
 mpgLabelTime.Top:=102;
 fpsbox1.Visible:=False;
 fpsbox2.Visible:=False;
 EstTime.Visible:=False;
 Normal.Visible:=True;
 HH.Visible:=True;
 P.Visible:=True;
 HT.Visible:=True;
 HD.Visible:=True;
 If Length=(IntToStr(0)) then
 Begin
hrsEdit.Text:='1';
minEdit.Text:='30';
secEdit.Text:='0';
ShowMessage('Cannot divide by zero');
 End
 else
 If Normal.Checked=True then
 Begin
Total:=8*((Size*1024)-(StrToInt(Length))*56) / (StrToInt(Length));
a:=(0.9);
x:=(Round((Total * a))*1.85);
y:=(Round(x));
 End;
 If HH.Checked=True then
 Begin
Total:=8 * ((Size*1024) - (StrToInt(Audio))) / (StrToInt(Length));
a:=(0.5);
x:=(Round((Total * a))*0.335);
y:=(Round(x));
 End;
 If P.Checked=True then
 Begin
Total:=8 * ((Size*1024) - (StrToInt(Audio))) / (StrToInt(Length));
a:=(0.9);
x:=(Round((Total * a))*0.83);
y:=(Round(x));
 End;
 If HT.Checked=True then
 Begin
Total:=8 * ((Size*1024) - (StrToInt(Audio))) / (StrToInt(Length));
a:=(0.9894);
x:=(Round((Total * a))*0.89);
y:=(Round(x));
 End;
 If HD.Checked=True then
 Begin
Total:=8 * ((Size*1024) - (StrToInt(Audio))) / (StrToInt(Length));
a:=(0.9894);
x:=(Round((Total * a))*2.95);
y:=(Round(x));
 End;
 VBLabel.Caption:=(FloatToStr(y)) + ' KBits/s';
 End;
 If MBCheck.Checked then
 Begin
 SBox.Text:=(FloatToStr(Size));
 SBox.Enabled:=True;
 MBLabel.Caption:='MB';
 End;
 If GBCheck.Checked then
 Begin
 GB:=Size / 1024;
 SBox.Text:=(FloatToStr(GB));
 SBox.Enabled:=False;
 MBLabel.Caption:='GB';
 End;
 If fpsbox1.Text='10 fps' then
 Begin
 fpsrate1:=(IntToStr(10));
 mpgLabel2.Caption:='Frame Rate: 10 fps';
 End;
 If fpsbox1.Text='11 fps' then
 Begin
 fpsrate1:=(IntToStr(11));
 mpgLabel2.Caption:='Frame Rate: 11 fps';
 End;
 If fpsbox1.Text='12 fps' then
 Begin
 fpsrate1:=(IntToStr(12));
 mpgLabel2.Caption:='Frame Rate: 12 fps';
 End;
 If fpsbox1.Text='13 fps' then
 Begin
 fpsrate1:=(IntToStr(13));
 mpgLabel2.Caption:='Frame Rate: 13 fps';
 End;
 If fpsbox1.Text='14 fps' then
 Begin
 fpsrate1:=(IntToStr(14));
 mpgLabel2.Caption:='Frame Rate: 14 fps';
 End;
 If fpsbox1.Text='15 fps' then
 Begin
 fpsrate1:=(IntToStr(15));
 mpgLabel2.Caption:='Frame Rate: 15 fps';
 End;
 If fpsbox1.Text='16 fps' then
 Begin
 fpsrate1:=(IntToStr(16));
 mpgLabel2.Caption:='Frame Rate: 16 fps';
 End;
 If fpsbox1.Text='17 fps' then
 Begin
 fpsrate1:=(IntToStr(17));
 mpgLabel2.Caption:='Frame Rate: 17 fps';
 End;
 If fpsbox1.Text='18 fps' then
 Begin
 fpsrate1:=(IntToStr(18));
 mpgLabel2.Caption:='Frame Rate: 18 fps';
 End;
 If fpsbox1.Text='19 fps' then
 Begin
 fpsrate1:=(IntToStr(19));
 mpgLabel2.Caption:='Frame Rate: 19 fps';
 End;
 If fpsbox1.Text='20 fps' then
 Begin
 fpsrate1:=(IntToStr(20));
 mpgLabel2.Caption:='Frame Rate: 20 fps';
 End;
 If fpsbox1.Text='21 fps' then
 Begin
 fpsrate1:=(IntToStr(21));
 mpgLabel2.Caption:='Frame Rate: 21 fps';
 End;
 If fpsbox1.Text='22 fps' then
 Begin
 fpsrate1:=(IntToStr(22));
 mpgLabel2.Caption:='Frame Rate: 22 fps';
 End;
 If fpsbox1.Text='23 fps' then
 Begin
 fpsrate1:=(IntToStr(23));
 mpgLabel2.Caption:='Frame Rate: 23 fps';
 End;
 If fpsbox1.Text='24 fps' then
 Begin
 fpsrate1:=(IntToStr(24));
 mpgLabel2.Caption:='Frame Rate: 24 fps';
 End;
 If fpsbox1.Text='25 fps' then
 Begin
 fpsrate1:=(IntToStr(25));
 mpgLabel2.Caption:='Frame Rate: 25 fps';
 End;
 If fpsbox1.Text='26 fps' then
 Begin
 fpsrate1:=(IntToStr(26));
 mpgLabel2.Caption:='Frame Rate: 26 fps';
 End;
 If fpsbox1.Text='27 fps' then
 Begin
 fpsrate1:=(IntToStr(27));
 mpgLabel2.Caption:='Frame Rate: 27 fps';
 End;
 If fpsbox1.Text='28 fps' then
 Begin
 fpsrate1:=(IntToStr(28));
 mpgLabel2.Caption:='Frame Rate: 28 fps';
 End;
 If fpsbox1.Text='29 fps' then
 Begin
 fpsrate1:=(IntToStr(29));
 mpgLabel2.Caption:='Frame Rate: 29 fps';
 End;
 If fpsbox1.Text='30 fps' then
 Begin
 fpsrate1:=(IntToStr(30));
 mpgLabel2.Caption:='Frame Rate: 30 fps';
 End;
 If fpsbox2.Text='10 fps' then
 Begin
 fpsrate2:=(IntToStr(10));
 mpgLabel7.Caption:='Processing Rate: 10 fps';
 End;
 If fpsbox2.Text='11 fps' then
 Begin
 fpsrate2:=(IntToStr(11));
 mpgLabel7.Caption:='Processing Rate: 11 fps';
 End;
 If fpsbox2.Text='12 fps' then
 Begin
 fpsrate2:=(IntToStr(12));
 mpgLabel7.Caption:='Processing Rate: 12 fps';
 End;
 If fpsbox2.Text='13 fps' then
 Begin
 fpsrate2:=(IntToStr(13));
 mpgLabel7.Caption:='Processing Rate: 13 fps';
 End;
 If fpsbox2.Text='14 fps' then
 Begin
 fpsrate2:=(IntToStr(14));
 mpgLabel7.Caption:='Processing Rate: 14 fps';
 End;
 If fpsbox2.Text='15 fps' then
 Begin
 fpsrate2:=(IntToStr(15));
 mpgLabel7.Caption:='Processing Rate: 15 fps';
 End;
 If fpsbox2.Text='16 fps' then
 Begin
 fpsrate2:=(IntToStr(16));
 mpgLabel7.Caption:='Processing Rate: 16 fps';
 End;
 If fpsbox2.Text='17 fps' then
 Begin
 fpsrate2:=(IntToStr(17));
 mpgLabel7.Caption:='Processing Rate: 17 fps';
 End;
 If fpsbox2.Text='18 fps' then
 Begin
 fpsrate2:=(IntToStr(18));
 mpgLabel7.Caption:='Processing Rate: 18 fps';
 End;
 If fpsbox2.Text='19 fps' then
 Begin
 fpsrate2:=(IntToStr(19));
 mpgLabel7.Caption:='Processing Rate: 19 fps';
 End;
 If fpsbox2.Text='20 fps' then
 Begin
 fpsrate2:=(IntToStr(20));
 mpgLabel7.Caption:='Processing Rate: 20 fps';
 End;
 If fpsbox2.Text='21 fps' then
 Begin
 fpsrate2:=(IntToStr(21));
 mpgLabel7.Caption:='Processing Rate: 21 fps';
 End;
 If fpsbox2.Text='22 fps' then
 Begin
 fpsrate2:=(IntToStr(22));
 mpgLabel7.Caption:='Processing Rate: 22 fps';
 End;
 If fpsbox2.Text='23 fps' then
 Begin
 fpsrate2:=(IntToStr(23));
 mpgLabel7.Caption:='Processing Rate: 23 fps';
 End;
 If fpsbox2.Text='24 fps' then
 Begin
 fpsrate2:=(IntToStr(24));
 mpgLabel7.Caption:='Processing Rate: 24 fps';
 End;
 If fpsbox2.Text='25 fps' then
 Begin
 fpsrate2:=(IntToStr(25));
 mpgLabel7.Caption:='Processing Rate: 25 fps';
 End;
 If fpsbox2.Text='26 fps' then
 Begin
 fpsrate2:=(IntToStr(26));
 mpgLabel7.Caption:='Processing Rate: 26 fps';
 End;
 If fpsbox2.Text='27 fps' then
 Begin
 fpsrate2:=(IntToStr(27));
 mpgLabel7.Caption:='Processing Rate: 27 fps';
 End;
 If fpsbox2.Text='28 fps' then
 Begin
 fpsrate2:=(IntToStr(28));
 mpgLabel7.Caption:='Processing Rate: 28 fps';
 End;
 If fpsbox2.Text='29 fps' then
 Begin
 fpsrate2:=(IntToStr(29));
 mpgLabel7.Caption:='Processing Rate: 29 fps';
 End;
 If fpsbox2.Text='30 fps' then
 Begin
 fpsrate2:=(IntToStr(30));
 mpgLabel7.Caption:='Processing Rate: 30 fps';
 End;
 b:=(StrToInt(fpsrate1))*(StrToInt(length)) div (StrToInt(fpsrate2));
 c:=3600;
 fps:=b div c;
 n:=(Round(fps));
 d:=(IntToStr(b - (3600 * n)));
 e:=(StrToInt(d)) div 60;
 f:=(StrToInt(d)) - (60 * e);
 If n<2 then
 Begin
 If n=0 then
 Begin
EstTime.Caption:='Finish Time: ' + (IntToStr(n)) + ' hrs ' + (IntToStr(e)) + ' mins ' + (IntToStr(f)) + ' sec';
 End
 else
 EstTime.Caption:='Finish Time: ' + (IntToStr(n)) + ' hr ' + (IntToStr(e)) + ' mins ' + (IntToStr(f)) + ' sec';
 End
 else
 EstTime.Caption:='Finish Time: ' + (IntToStr(n)) + ' hrs ' + (IntToStr(e)) + ' mins ' + (IntToStr(f)) + ' sec';
 If VBC.Width>432 then
 Begin
 If Time.Width<193 then
 Begin
GroupBox6.Width:=201;
VBLabel.Alignment:=taRightJustify;
If y<1 then
Begin
VBLabel.Caption:='0 KBits/s';
End;
If y>999 then
Begin
VBLabel.Left:=GroupBox6.Left + 45;
End;
If y>9999 then
Begin
VBLabel.Left:=GroupBox6.Left + 33;
End;
If y>=20000 then
Begin
GroupBox6.Width:=VBC.Width - Time.Width-21;
hrsEdit.Text:='1';
minEdit.Text:='30';
secEdit.Text:='0';
DiscEdit.Text:='2';
VBLabel.Left:=GroupBox6.Left + 14;
ShowMessage('The current settings that you have chosen...' + #10 + #10 +
(IntToStr(hrs)) + ' hrs ' + (IntToStr(min)) + ' min ' + (IntToStr(sec)) + ' sec ' + #10 +
DiscEdit.Text + ' × ' + DiscDrpDwn.Text + #10 +
Audiodrp.Text + #10 + #10 +
'has given a calculated bitrate of ' + (FloatToStr(y)) + ' KBits/s' + #10 +
'This bitrate is not advisable for a mpg or avi file');
End;
 End;
 End;
 If VBC.Width<432 then
 Begin
 If Time.Width>193 then
 Begin
GroupBox6.Width:=VBC.Width - Time.Width-36;
VBLabel.Alignment:=taRightJustify;
If y<1 then
Begin
VBLabel.Caption:='0 KBits/s';
End;
If y>999 then
Begin
GroupBox6.Width:=VBC.Width - Time.Width-36;
VBLabel.Left:=GroupBox6.Left + 38;
End;
If y>9999 then
Begin
GroupBox6.Width:=VBC.Width - Time.Width-36;
VBLabel.Left:=GroupBox6.Left + 26;
End;
If y>=20000 then
Begin
GroupBox6.Width:=VBC.Width - Time.Width-36;
hrsEdit.Text:='1';
minEdit.Text:='30';
secEdit.Text:='0';
DiscEdit.Text:='2';
VBLabel.Left:=GroupBox6.Left + 14;
ShowMessage('The current settings that you have chosen...' + #10 + #10 +
(IntToStr(hrs)) + ' hrs ' + (IntToStr(min)) + ' min ' + (IntToStr(sec)) + ' sec ' + #10 +
DiscEdit.Text + ' × ' + DiscDrpDwn.Text + #10 +
Audiodrp.Text + #10 + #10 +
'has given a calculated bitrate of ' + (FloatToStr(y)) + ' KBits/s' + #10 +
'This bitrate is not advisable for a mpg or avi file');
End;
 End;
 End;
End;
Procedure TVBC.Timer2Timer(Sender: TObject);
Var s:string;
 h, m:real;
Begin
 Timer2.Tag:=Timer2.Tag-1;
 s:=IntToStr(Time1 - Timer2.Tag);
 m:=(StrToInt(s)) div 60;
 h:=m / 60;
 mpgLabelTime.Caption:=(FloatToStr(h)) + ' hrs ' + (FloatToStr(m)) + ' min ' + s + ' sec';
 If s=(IntToStr(61)) then
 Begin
 Timer2.Tag:=0;
 Timer2.Tag:=Timer2.Tag-1;
 s:=IntToStr(Time1 - Timer2.Tag);
 mpgLabelTime.Caption:=(FloatToStr(h)) + ' hrs ' + (FloatToStr(m)) + ' min ' + s + ' sec';
 End;
End;
Procedure TVBC.MinimizeClick(Sender:TObject);
Begin
 Shell_NotifyIcon(NIM_Add, @TrayIcon);
 hide;
 If IsWindowVisible(Application.Handle) then
 ShowWindow(Application.Handle, SW_HIDE);
End;
Procedure TVBC.ClickTrayIcon(var msg: TMessage);
Begin
 Case msg.lparam of
 WM_LBUTTONUP, WM_LBUTTONDBLCLK:
 Begin
 Application.Restore;
 Shell_NotifyIcon(NIM_Delete, @TrayIcon);
 If WindowState = wsMinimized then
 WindowState:=wsNormal;
 visible:=true;
 SetForegroundWindow(Application.Handle);
 End;
 End;
End;
Procedure TVBC.Timer3Timer(Sender: TObject);
Var input, output:real;
Begin
 DateSeparator:=' ';
 ShortDateFormat:='dddd, dd/mmmm,/yyyy -';
 Time.Caption:=DateTimeToStr(Now);
 If SSaver.Text='Enabled' then
 Begin
 SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, 0);
 End;
 If SSaver.Text='Disabled' then
 Begin
 SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, nil, 0);
 End;
 {input:=(StrToInt(Edit1.Text));
 output:=input / 10;
 Edit2.Text:=(FloatToStr(output));}
End;
Procedure TVBC.CalcShow(Sender: TObject);
Begin
 ClearDisplay();
 VBC.Constraints.MinWidth:=568;
 VBC.Constraints.MaxWidth:=568;
 ButtonEqual.Default:=True;
End;
Procedure TVBC.CalcHide(Sender: TObject);
Begin
 VBC.Constraints.MinWidth:=430;
 VBC.Constraints.MaxWidth:=430;
 ClearDisplay();
End;
Procedure TVBC.Button10Click(Sender: TObject);
Var DVD:string;
Begin
 Open.Execute;
 DVD:=Open.FileName;
 ShellExecute(0, 'open', PChar(DVD), PChar(DVD), nil, SW_SHOW );
End;
Procedure TVBC.AboutClick(Sender: TObject);
Begin
 About.Show;
End;
Procedure TVBC.RunningTime(Sender: TObject);
Begin
 Timer2.Enabled:=True;
 mpgLabel5.Cursor:=crDefault;
End;
Procedure TVBC.Timer4Timer(Sender: TObject);
Var hrs, min, sec:integer;
Begin
 If hrsEdit.Text='' then
 Begin
 hrsEdit.Text:='0';
 hrs:=0;
 End;
 If minEdit.Text='' then
 Begin
 minEdit.Text:='0';
 min:=0;
 End;
 If secEdit.Text='' then
 Begin
 secEdit.Text:='0';
 sec:=0;
 End;
End;
End.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.