Sample accurate mp3 seeking
Home
FAQ
Contact
Sign in
Search
microsoft.public.win32.programmer.directx.audio only
Advanced search
POPULAR GROUPS
perl.cpan.testers
alt.marketplace.online.ebay
alt.forsale
alt.ads.forsale
alt.bestjobsusa.computer
alt.bestjobsusa.computer.jobs
us.jobs.offered
alt.bestjobsusa.jobs.offered
us.jobs
nyc.jobs
more...
Up
Sample accurate mp3 seeking
Group:
microsoft.public.win32.programmer.directx.audio
·
Group Profile
Author:
BlaithÃn Kennedy
BlaithÃn Kennedy
Date:
Jan 21, 2008 07:01
Hi All,
I have spent some time looking into a problem that I need to solve for the
application I am working on. I need to be able to seek sample accurately
within both CBR and VBR mp3 files. From what I read this meant I needed to
write my own MP3 parser. I have not worked with DirectShow for very long and
I have no filter writing experience. I downloaded source for a couple of
freely available parsers and did my best to make the changes I thought I
needed to the code.
Taking “GDCL Sample MPEG-1 Parser” as a base, (available on Geraint Davies
website) I made some changes my parser only needs to deal with audio so I
have only one output pin whose media type is MEDIATYPE_Audio. The first thing
I did was made sure I could connect my parsers input pin to the “File Source
(Async.)” and the parser output pin connected to a number of different mp3
decoders which I had downloaded.
In my parsers CompleteConnect function I wrote code to parse the entire mp3
file and fill a struct with information I retrive from the file, namely the
location in bytes within the file of each frame header, the size of the frame
and the actual time this represents.
In my parsers Receive function I call IMediaSample::GetSize to get the
length of the buffer available to me and I retrevie a pointer to buffer
itself by calling IMediaSample::GetPointer then within a while loop I use the
information from the struct containing the frame header details to read frame
after frame of data from the source file into this buffer. This buffer
doesn’t always have room for an exact number of frames so I fill it with as
many frames as I can and then break out of the while loop and call
DeliverData passing it the actual number of bytes that have been written to
the buffer.
When my parser seeks it takes the tStart time passed to the Seek function
and converts this to a file location based on the information in the struct
containing the frame header information.
Within GraphEdit I can use my parser to play mp3 files and if I seek to a
new start time the file continues to play I have also forced Winamp to use my
parser and one of the many decoders on my system and it also seems to behave
as it always did. I thought that it would now be possible to use my parser
and any decoder in the way I wanted which is to decode blocks of audio one at
a time. If these blocks start and end points were continuous in time I
thought they would meet seamlessly. However this is not what I am seeing,
when I do this I find that at the start of ever block, I either have a few
garbage samples or a small block of silence. If anyone can shed some light on
this I would be eternally greatful and if anyone is willing to check my
source or can point me in the direction of parser source that does what I
want even better.
Thanks in advance for any help or advice.
Blaithín
5
Comments
diggit!
del.icio.us!
reddit!