Rodrigo Gómez
2003-Sep-11 15:31 UTC
[vorbis-dev] "wrong" total time from ov_time_total
Hello there. I'm finding that ov_time_total doesn't return the "expected" value for some files I'm encoding. How do I know that? Well... in the encoder, when I push the "record" button I store the time when I did it, and when I push the stop button I store also that time. I would expect that the time returned by ov_time_total would be some ms less than finish_time - start_time, but, in some cases, it is up to 5 minutes less. The strange thing: It doesn't seem to loose data. I mean, I can hear to the audio and hear that everything that it's supposed to be it's there, but the time says different. So, it's ov_time_total accurate? I'm having some other more serious problems, as I store events that are time related, and I need to seek to that specific times. What I have done to "solve" this problem is get a "time factor" (expected_time/ov_time_total) and apply it to seek and so on, but I'm not happy with this, as I would like to know the cause, and not only solve an effect of the problem. This problems seems to be more present when saving non 44.1 Khz audio, for example, 8,820 Hz or so. I haven't tryed with sample rates above 44,100 Hz. Does something special has to be used to record audio at different sample rates? I'm correctly passing the sample rate and the number of channels to the encoder. I'm using ov_time_total like this: total_length = ov_time_total(&oggvorbis_file, -1); Thanks, and regards Rodrigo Gómez <p><p>--- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Michael Smith
2003-Sep-11 19:30 UTC
[vorbis-dev] "wrong" total time from ov_time_total
On Friday 12 September 2003 08:31, Rodrigo Gómez wrote:> Hello there. > > I'm finding that ov_time_total doesn't return the "expected" value for some > files I'm encoding. How do I know that? Well... in the encoder, when I push > the "record" button I store the time when I did it, and when I push the > stop button I store also that time. I would expect that the time returned > by ov_time_total would be some ms less than finish_time - start_time, but, > in some cases, it is up to 5 minutes less. The strange thing: It doesn't > seem to loose data. I mean, I can hear to the audio and hear that > everything that it's supposed to be it's there, but the time says > different. > > So, it's ov_time_total accurate? I'm having some other more serious > problems, as I store events that are time related, and I need to seek to > that specific times.There may have been bugs in this function, i think, in some previous versions - but they resulted in completely wrong results, not slightly wrong ones. So you're not seeing that - and ov_time_total() will not give 'slightly wrong' results, ever.> > What I have done to "solve" this problem is get a "time factor" > (expected_time/ov_time_total) and apply it to seek and so on, but I'm not > happy with this, as I would like to know the cause, and not only solve an > effect of the problem. > > This problems seems to be more present when saving non 44.1 Khz audio, for > example, 8,820 Hz or so. I haven't tryed with sample rates above 44,100 Hz. > Does something special has to be used to record audio at different sample > rates? I'm correctly passing the sample rate and the number of channels to > the encoder.The most likely (I think) reason for this is that your sample clock (presumably on some actual audio hardware) is drifting - it's pretty common for them to be slightly off, but if you're seeing large differences it may be that your hardware is particularly bad. ov_time_total() relies on the sample rate - so if you've told the encoder that you're recording at 8820 Hz, but the _actual_ clock is, say, 8825 Hz, then it'll be marginally wrong. This is a hardware defect, not a software one - the only thing you can do is try to make your software determine the "actual audio clock". Mike --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.