Reputation: 21
I have 3 min audio file in AWS S3. I have no idea how to read the first 30 seconds of audio from that file.
Upvotes: 0
Views: 446
Reputation: 18809
Assuming you are using the boto you can give a range of bytes that should be fetched for the object.
Look at get_object at: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html
Range (string) --
Downloads the specified range bytes of an object. For more information about the HTTP Range header, see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 .
Note
Amazon S3 doesn't support retrieving multiple ranges of data per GET request.
So you would have to take a guess on what would range would constitute the first 30 seconds of an audio file. This will depend on the audio file details like type of file, compression algo, bitrate etc.
Also not an expert on audio compression but the "decoder" that you use should be able to handle partial streams.
To answer you question you can fetch partial files from S3.
Upvotes: 1