-
Notifications
You must be signed in to change notification settings - Fork 251
Description
Package version
5.0.4
Environment
- OS: MacOS 14.3
Describe the bug
Currently only tested on MacOS. When recording to file with .wav encoding set, the resulting file is consistently ~2.34x larger than expected (duration, bitrate, #channels have been defined), and does not have valid header data. When parsed out the first 44 bytes of the output file reads:
RIFF
(#number of bytes in the file) WAVE JUNK 0 0 0 0 0 0
, a number of empty entries, and lastly followed by a 0
.
In this case, the recording was set to 2000 ms and was expected to see a file size of 176kb but output to 411604. The ratio of file size difference is consistent with longer files as well.
I am not certain where the code for writing the recorded data to file is located, as I was not able to find it following the method calls. I saw in the web folder there is a pcm and wav_encoder file with methods to write proper but it does not seem to be called in the record-to-file 'start' call pathway nor does the wav_encoder's expected output match what I am seeing written to file.
Add your record configuration RecordConfig(...)
code related to record
used is as follows:
import 'package:flutter/foundation.dart';
import 'package:audiotestproject/components/data/global.dart';
import 'package:record/record.dart';
final x = Singleton();
void playLogic() async {
final AudioRecorder audioRecorder = AudioRecorder();
const config = RecordConfig(encoder: AudioEncoder.wav, bitRate: 705600, numChannels: 1);
await audioRecorder.start(config, path: '/Users/austibwu/Documents/record_project/assets/wave_in.wav');
await x.player.resume();
var status = x.player.onPlayerComplete;
status.listen((event) async {
print('Recorded file path: ${await audioRecorder.stop()}');
});
}
To Reproduce
Steps to reproduce the behavior:
Rudimentary implementation of records package as seen above, no modifications to basic recorder instance beyond path and recording config.
Expected behavior
correctly formatted .wav header data written as seen in record_web/lib/encoder/wav_encoder.dart
or similar, and volume of data in the body matching the expected output for the given duration, bitdepth, #channels, and sampling rate.
Additional context
I'm a bit confused on the excess file size because the .wav file still plays out to the correct duration.
It doesn't seem like this is a shared experience so I'm wondering if I have done something wrong in my implementation, or simply missed a folder in the package.