• Roman Beranek's avatar
    cafenc: fill in avg. packet size later if unknown · ed240db9
    Roman Beranek authored
    Frame size of Opus stream was previously presumed here to be 960 samples
    (20ms), however sizes of 120, 240, 480, 1920, and 2880 are also allowed.
    It can also alter on a per-packet basis and even multiple frames may be
    present in a single packet according to the specification, for the sake
    of simplicity however, let us assume that this doesn't occur.
    
    Because the mFramesPerPacket field, representing the number of samples
    per packet in the ffmpeg terminilogy, is the key factor in calculating
    packet durations and all that follows from that (index, bitrate, ...),
    it is crucial to get right.
    
    Therefore, if the packet size is not available ahead of time (as it is in
    the case of Opus), calculate an average from the stream duration once we
    know how many packets there are and update the filed in the header.
    ed240db9
cafenc.c 9.64 KB