On Sun, 2010-01-10 at 16:27 -0800, Sean McAllister wrote:
> How consistent are the sizes of audio packets that come out of an audio
> decoder?  I'm seeing packets that
> are consistently 4800 samples, but I'm curious if this is something that's
> reliable or if it can vary packet-to-packet (eg: if it's a VBR codec).
> I'm basically curious whether, if I know the packet size, and number of
> packets, I can turn that into a time in seconds.
> 
> Sean
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user

That depends on the codec. Check out AVCodecContext::frame_size. If it
is greater than one (1) then each packet contains a constant amount of
samples. If not, then you probably have a PCM or other special codec,
which means no guarantees.

I suspect you're better off relying on the timestamps given by the
demuxer, unless you don't have one. Otherwise just use the number of
samples given so far, with time_base equal to the one your decoder uses
(48 kHz for instance). I wouldn't rely on frame_size, even if
consistent.

Ah, and also note that you can get more than one frame of audio from
each packet if the return value of avcodec_decode_audio3() is less than
the size of the packet.

/Tomas

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to