[Ffmpeg-devel] Buffering audio data in case of overflow
Sat May 6 17:40:06 CEST 2006
Cyril Zorin wrote:
> I'm working on a decoder where the source media format provides more
> than a frame's worth of audio with a frame chunk. In other words, an
> incoming "frame", which is composed of audio and video, will have
> __one__ video frame's worth of data, but potentially N audio frames'
> worth of audio. This means that I can't quite push it all to ffmpeg,
> because ffmpeg defines AVCODEC_MAX_AUDIO_FRAME_SIZE.
> How is this situation generally handled? Are there any existing codecs
> that need to solve this problem? Right now I'm thinking to manually
> buffer the audio, but perhaps there's a better way?
Does the first decoded audio frame contain more than 192000 bytes
(AVCODEC_MAX_AUDIO_FRAME_SIZE) in total? That can handle more than 2
seconds of CD-standard audio. But if so, that requires special handling.
It is not uncommon for a file to contain a prebuffer for 0.5-1 second of
audio data to correspond to the first video frame. The way to handle
this is to set the frame timestamps correctly and send them to the
playback engine. The playback engine worries about keeping the sync.
Note that ffplay is not the most reliable program for keeping sync, though.
More information about the ffmpeg-devel