Kali Griffin wrote:
> 
> how can I read the mp3 data outputted by lame frame by frame?  I noticed
> in common.c that all the bits are stuffed into a bit stream and then
> shoved down the pipe, I couldnt figure out though, before that point, when
> each frame was formed?  My point in doing so:  I want to serve the
> microsoft media client.  they require that the frames are all of uniform
> size and that there is some funky header preceding each mp3 frame. that is
> why I need the individual frames.  and also, where can I find out the
> individual frame sizes in bytes?  I emailed mark taylor already regarding
> individual frame size uniformity, and he told me that I just need to set
> the padding bit to 0 in order to have uniform frames, will this cause
> problems of any sort?  thanks a bunch yall.
> -kali
> 
> --
> MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )


The following is a quick script to try to find headers from
a file (I believe only for MPEG I Layer 3, there are slightly
different headers for MP II Layer 3, MPI Layer 2, etc.
This doesn't prove you found a header, only that it could be
a header.  If you look at the output, it should be easy to figure
out where the headers are, as they should occur at the same
interval, so you can then add to this script something that
buffers several frames, syncs the beginning, and then tells
you the info you need.

#!/usr/bin/python

# (C) 1999 under GPL, hack away.  Bill Eldridge

import sys
#myin=open('MAN00.mp3','r')
myin=open(sys.argv[1],'r')
mybuf=myin.read(4)
fpos=0


print "Pos","b1","ver","lay","prot","bit","samp","pad\n"

while 1:
    if ((ord(mybuf[0]) & 0xFF == 0xFF) and (ord(mybuf[1]) & 0xE0 ==
0xE0)):
        print fpos,ord(mybuf[1]),
              (ord(mybuf[1]) & 0x18) >> 3,
              (ord(mybuf[1]) & 0x06) >> 1,
              ord(mybuf[1]) & 0x01,
              (ord(mybuf[2]) & 0xF0) >> 4,
              (ord(mybuf[2]) & 0x0C) >> 2,
              (ord(mybuf[2]) & 0x02) >> 1

        fpos=fpos+1
        myin.seek(fpos) 
        mybuf=myin.read(4)

--
Bill Eldridge
Radio Free Asia
[EMAIL PROTECTED]
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to