File: divxcomp.pl

package info (click to toggle)
divxcomp 0.1-9
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 84 kB
  • sloc: perl: 59; makefile: 9
file content (104 lines) | stat: -rwxr-xr-x 3,214 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/perl -w

#############################################################################
# Copyright (C) 2002 Marc Leeman <mleeman@users.sourceforge.net>
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
#############################################################################

use Tk;
use Tk::BrowseEntry;

my $Version = "0.1";

sub divxcompute;

my $main = MainWindow->new();
$main->configure(-title=>"Calculate DivX bitrate $Version", -background=>'grey');
$main->geometry('+100+300');

my $top = $main->Frame(
                        )->pack(-expand=>1,-side => 'top', -fill => 'both');

my $cdlength = $top->Frame(
			)->pack(-expand=>1,-side => 'top', -fill => 'both');

my $movielength = $top->Frame(
			)->pack(-expand=>1,-side => 'top', -fill => 'both');
			
my $mp3bitrate = $top->Frame(
			)->pack(-expand=>1,-side => 'top', -fill => 'both');

my $result= $top->Frame(
			)->pack(-expand=>1,-side => 'top', -fill => 'both');

my $buttons = $top->Frame(
			)->pack(-expand=>1,-side => 'top', -fill => 'both');

my $cdlengthlabel = $cdlength->Label(-text => 'CD Length/File Size',
					)->pack(-side=>'left');

my $cdlengthentry = $cdlength->Entry(-width=>10,
					-background => 'white',
					-relief=>'sunken',
					)->pack(-side=>'right');

$cdlengthentry->insert('end',"700");

my $movielengthlabel = $movielength->Label(-text => 'DVD Movie Length (min)',
					)->pack(-side=>'left');

my $movielengthentry = $movielength->Entry(-width=>10,
					-background => 'white',
					-relief=>'sunken',
					)->pack(-side=>'right');
$movielengthentry->insert('end',"120");					

		
my $mp3bitrateentry = $mp3bitrate->BrowseEntry(-label => 'MP3 bitrate (kbps)',
				-choices => [qw(32 40 48 56 64 80 96 112 128 160 192 224 256 320)],
				-listwidth => 25,
				-variable => \$kbps)->pack();

my $resultFixed = $result->Label(-text => 'DivX bitrate',
                                        )->pack(-side=>'left');

my $bitrate = $result->Label(-text => 'undefined',
                                        )->pack(-side=>'right');

my $compute= $buttons->Button(-text=>'Calculate',
				-command=>\&divxcompute,
				)->pack(-side=>'left');

my $end = $buttons->Button(-text=>'Close',
				-command=>sub{exit(0)},
				)->pack(-side=>'right');


sub divxcompute{
	$ml = $movielengthentry->get();
	$cdl = $cdlengthentry->get();
	my $final = (((($cdl*1024*8)/1000)*1024)-($kbps*$ml*60))/($ml*60);
	
	if($final =~ /(^\d+)(:?.\d+)?/){
		$bitrate->configure(-text=>"$1");
	}
	else{
		$bitrate->configure(-text=>"Illegal Result");
	}
};

MainLoop();