Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I read the bits of a binary file?

Status
Not open for further replies.

breveR

Programmer
Nov 16, 2001
18
0
0
US
I need a script to be able to read certain bits of a file opened in binary mode. This is to take place on my web page.

(Host=Win2k, no PHP, custom modules or dlls)

Ok, the real reason is to be able to read the actual bits, (not bytes) that indicate what the bitrate and frequency are in an mp3 file posted on my web page, and list them on my webpage. Simply hard coding the given bitrate, frequency of the mp3 file on the page is not an option.

Ive looked into asp-vbscripts and it appears not to be possible without the aid of custom dlls (Which my host will not support)

Is this possible to do with CGI, Perl or anything else?

Thanks
 
Hi breveR,

It sounds like you want to look into the 'pack' and 'unpack' functions.

Hope this helps,
Grant.
 
Download and install the MP3::Info module. It's so easy to use it hurts.
Code:
use MP3::Info;

my $file = 'your_favorive.mp3';
my $mp3 = get_mp3info($file);
print "Bitrate for $file: $mp3->{BITRATE}\n";
The %$mp3 hash contains other useful tidbits, too.

jaa
 
Im bran spankin new to Perl, heres what I figured out so far.

I downloaded and installed ActivePerl 5.6.1 build 633, tested with the command line "perl example.pl" It is working.

I also set up a new virtual directory in IIS called "PerlScript", pointed it to my c:\Perl\eg\aspSamples. Tested this by running " This works great.

I went ahead and downloaded MP3-Info-1.01.tar.gz which contains:
Info.pm
Makefile.PL
MANIFEST
MP3Info.pm
mp3tag.PL
mp3tocddb.PL
README
test.pl
test1.mp3
test2.mp3

This is where I get lost. I do not know how to install this module. Also I do not know how to effectivly use this module in a webpage.asp. whats the next steps?

A great many thanks in advance of your advice. :)
 
If you have ActivePerl install then you can run the built-in perl package manager, ppm.
From the command line (dos prompt) type 'ppm' and this will launch the ppm shell. Run
Code:
PPM> install MP3-Info

and will download and install everything for you.

jaa
 
Tried it.

PPM interactive shell (2.1.6) - type 'help' for available commands.
PPM> install mp3-info
Install package 'mp3-info?' (y/N): y
Installing package 'mp3-info'...
Error installing package 'mp3-info': Could not locate a PPD file for package mp3-info
PPM>

No PPD files came with the mp3-info package to begin with. Im just wondering, even if I get this going on my localhost will it run out there on my regular host?
 
It's case sensitive. So you have to type
Code:
PPM> MP3-Info

As for running on your 'regular' host, the module will probabaly have to be installed on it, too. If you aren't the administrator you can install it in a private directory or ask the host admin to install it for you.

jaa
 
Um, I guess it's not case sensitive. It's been a while since I used Perl on windows and ppm. I forget (if i ever knew) what the missing PPD file error message means. I'll do some reasearch and let you know unless someone else knows a solution.

jaa
 
It works here.
I used to have this problem too and I specified the
'--location' option and then the url
You could also try:
perl -MCPAN -e "install MP3::Info"
Mind that you use :: in place of - here
 
Ok Well for some reason, this dosnt work for me at work, but it does work at home. But, being that im a Perl newbie, Im still a bit confused as to how to get this going in an asp page. can someone please show me a working example of some PerlScript in an asppage useing the MP3-info ?
Thanks a million
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top