HTML5 audio - currentTime attribute inaccurate?

前端 未结 2 1463
孤独总比滥情好
孤独总比滥情好 2020-12-30 11:56

I\'m playing around a bit with the HTML5 tag and I noticed some strange behaviour that has to do with the currentTime attribute.

2条回答
  •  悲&欢浪女
    2020-12-30 12:23

    After hours of battling this mysterious issue, I believe I have figured out what is going on here. This is not a question of .ogg vs .mp3, this is a question of variable vs. constant bitrate encoding on mp3s (and perhaps other file types).

    I cannot take the credit for discovering this, only for scouring the interwebs. Terrill Thompson, a gentlemen and scholar, wrote a detailed article about this problem back on February 1st, 2015, which includes the following excerpt:

    Variable Bit Rate (VBR) uses an algorithm to efficiently compress the media, varying between low and high bitrates depending on the complexity of the data at a given moment. Constant Bit Rate (CBR), in contrast, compresses the file using the same bit rate throughout. VBR is more efficient than CBR, and can therefore deliver content of comparable quality in a smaller file size, which sounds attractive, yes?

    Unfortunately, there’s a tradeoff if the media is being streamed (including progressive download), especially if timed text is involved. As I’ve learned, VBR-encoded MP3 files do not play back with dependable timing if the user scrubs ahead or back.

    I'm writing this for anyone else who runs into this syncing problem (which makes precise syncing of audio and text impossible), because if you do, it's a real nightmare to figure out what is going on.

    My next step is to do some more testing, and finally to figure out an efficient way to convert all my .mp3s to constant bit rate. I'm thinking FFMPEG may be able to help, but I'll explore that in another thread. Thanks also to Loilo for originally posting about this issue and Brad for the information he shared.

提交回复
热议问题