Reputation: 9685
I need to process large audio files in segments. Instead of downloading the full file and the extracting a timeframe, I'd like to only download the required segment (e.g. seconds 25 to 35).
As the API does not support this out of the box, what is the best way of only download segments of an audio file?
Upvotes: 0
Views: 249
Reputation: 1882
Reading from seconds its not supported, as Google Storage does not read the file and interpret it.
You can do segments of bytes. This is called reading ranges of bytes, which is supported in Cloud Storage.
You have to add a header Range: bytes=20-2000
as documented [1].
In nodejs you would do something like this [2]
const logFile = myBucket.file('access_log');
logFile.createReadStream({
start: 20,
end: 2000
})
[1] https://cloud.google.com/storage/docs/xml-api/reference-headers#range
Upvotes: 1