ruuda / hound

A wav encoding and decoding library in Rust
https://codeberg.org/ruuda/hound
Apache License 2.0
491 stars 65 forks source link

Advice on Creating WAV Header for Large File Multipart Upload #73

Open jsonpoindexter opened 9 months ago

jsonpoindexter commented 9 months ago

Hello,

I'm working with the Hound library to implement uploading a large WAV file via multipart upload to a storage service. I've got everything working except for one key aspect: creating the WAV header.

Scenario: I'm concatenating several smaller WAV files (referred to as 'parts') into a larger file for upload. Given the final file's size can exceed 2GB, and aiming for memory efficiency, I plan to upload each part sequentially using a multipart upload API. The challenge arises with the WAV format's requirement for the 'data chunk size' in the header, as the total size isn't known upfront during the initial upload.

Hound offers an into_header_for_infinite_file method, which seems like a workaround. However, its documentation suggests it's more suited for streaming contexts, potentially leading to 'non-standard' WAV files.

Current Approach: With access to the total duration (in ms) of the intended final output, I've devised a custom create_wav_header method for the initial part's upload but remain open to more standard solutions.

Questions:

Technical Context:

Appreciate any insights or advice on this matter. Thanks!