Increasing cache size for playing large MP3 files on loop

124 views
Skip to first unread message

Sean Topping

unread,
Apr 16, 2021, 7:24:30 PM4/16/21
to Chromium-dev
Use case: We want to play a 1-hour MP3 file on loop (possibly for up to 8 hours) without having to re-download the audio segments multiple times. In desktop Chrome, I noticed that it will only cache about 20 minutes of audio data, so that when the track loops it has to re-download again from the beginning. After 8 loops, this amounts to almost 500MB of data downloaded. Alternatively, caching the whole MP3 would only download 60MB. Some questions:

1. Is there a way to configure the cache size for a specific renderer in C++? I'm not too familiar with the file download -> media buffer data path, but in theory if we can just keep the entire file in memory for this renderer, this would be sufficient.
2. In general, how does sub-resource caching work in Chromium? Any good resources or pointers? I found the following doc, but it's a little light on details with respect to media playback: https://www.chromium.org/developers/design-documents/network-stack/disk-cache

Nick Harper

unread,
Apr 16, 2021, 7:44:44 PM4/16/21
to seant...@google.com, Chromium-dev
Instead of relying on Chrome caching behavior, would it work to download the mp3 file using fetch, use AudioContext.decodeAudioData to decode the audio data and store it in a buffer owned by your JS code, and then play that buffer on loop?

This approach would also seem to be more likely to work cross-platform instead of relying on implementation details of a particular User-Agent.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/c8d4df63-155b-4623-9336-940cefc328b3n%40chromium.org.

Dale Curtis

unread,
Apr 16, 2021, 7:47:33 PM4/16/21
to nha...@chromium.org, Sean Topping, Chromium-dev
decodeAudioData will decode everything in memory which is a bit excessive. I'd instead recommend using Media Source Extensions and just buffering the compressed audio data in JavaScript. See https://developers.google.com/web/fundamentals/media/mse/seamless-playback for a related example.

- dale

Reply all
Reply to author
Forward
0 new messages