Hi maddev-group & Rob, I'd like to know the easiest way to decode partial files, for example only the first 30 seconds.
for constant bitrate layer 3 encodings, the first 30 seconds can be calculated by time = (size * 8) / (bitrate * 1000)? [from the dev-archive you posted in response to Joe Drew's post: Seeking, frames and time] but to get the bitrate, you have to read @ least one frame and from them can calculate the # of frames necessary for 30seconds ?
to make things more tricky ... in reading the CBR layer 3 frames you have to read into the subsequent frames to really know if a current frame has ended or not.
I know most of the incremental file descriptor reading action happens "decode_input_read()" ...so if i manage to calculate the # of Frames that correspond to 30 seconds of pcm, what structures do i need to set to stop decoding after the #of frames has been reached? MAD_FLOW_IGNORE?
so the more general question is what is the best way for CBR and VBR layer 3 encodings to decode just the first 30 seconds to pcm? especially without having to scan through the whole file ...
thanks a lot, iroro
-- --o0o------------------------------------------------------o0o-- minimis optime peractis, maxima bene agentur --o0o------------------------------------------------------o0o--
On Thu, 2002-03-21 at 20:53, iroro wrote:
so the more general question is what is the best way for CBR and VBR layer 3 encodings to decode just the first 30 seconds to pcm? especially without having to scan through the whole file ...
MAD makes it easy. Use the mad_timer functionality and the duration field of the mad_frame structure; every time you receive a frame in your header callback, add duration to your running total. (mad_timer_add) Once that equals or exceeds 30 seconds, return MAD_FLOW_STOP from the header function, and you'll immediately stop the decoding process.