ASFView may complain some audio samples’ presentation time is incorrect if you open an ASF file using it. There are many different reasons can cause incorrect presentation time issue, if you wrote own encoder application based on Format SDK, you may take a look this case:
Does the encoder re-package audio sample? One scenario could be the encoder read wma samples from source by using Format SDK and combine some of them into a big buffer as a sample for some reasons. How does the encoder calculate presentation for the re-packaged sample? Every wma sample read from source has a presentation stamp, when the encoder combines them into one sample, what’s the presentation time it assigns to the combined sample?
I didn’t really see the case I described above, I just found some encoders calculate incorrect presentation time and it looks like those encoders need to re-package wma sample and/or re-encode wma samples. Below is a workaround in pseudo code may help to get around the problem, but I cannot guarantee it always works. If anyone wrote an encoder and encounter similar incorrect presentation time issue and my workaround isn’t helpful, I’d like to take a look.
Note, the workaround is only for wma sample, if the problem you actually encounter is wmv sample, please DON'T USE the workaround.
var1 = 0;
buffer_sample_size = pBuffer->GetSize();
block_align_size = GetBlockAlignSize();
average_byte_per_second = GetABPS();
last_present_time = GetLastPresentTime();
while ( var1< buffer_sample_size)
{
next_present_time = last_present_time + (var1*1000)/average_byte_per_second;
if ( (buffer_sample_size - var1) > block_align_size )
var1 = var1 + block_align_size;
}
else
var1 = buffer_sample_size - block_align_size;
Last_present_time = next_present_time;
next_present_time = next_present_time + 10;
WriteStreamSample (next_present_time,.…);