You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Click the first button, which will try to make a recording with a length of zero. Check the logs for the path of the output audio file, which will be an empty file (0 bytes). Expected behavior: the file should instead be a valid audio file with a length of zero (or near zero).
If you have ffprobe available on your system's path, the program will print the length of the audio file. If the file is empty, ffprobe will fail, and its output will be empty.
Logs from me using this app to generate a zero-length recording
flutter: Started recording with a duration of 0:00:00.000000
flutter: Stopping recording at 35 milliseconds...
flutter: Finished stopping at 293 milliseconds.
flutter: You can find your audio file at C:\Users\Jozz\Documents\record_start_stop_empty_file_repro\599614901.m4a
flutter: Duration between .start() being called and .stop() being called was 0:00:00.035000
flutter: Duration between .start() being called and .start() finishing was 0:00:00.035000
flutter: Duration between .start() finishing and .stop() being called was 0:00:00.000000
flutter: Duration between .start() finishing and .stop() finishing was 0:00:00.258000
flutter: Duration between .start() being called and .stop() finishing was 0:00:00.293000
flutter: Running ffprobe: ffprobe -i C:\Users\Jozz\Documents\record_start_stop_empty_file_repro\599614901.m4a -show_entries format=duration -sexagesimal -v quiet -of csv=p=0
flutter: ffprobe failed to run. Is the file empty?
flutter:
If not using the provided repro project, code similar to this will probably repro the issue:
recorder
.start(
constRecordConfig(encoder:AudioEncoder.aacLc),
path: audioPath,
)
.then((_) => recorder.stop()); // Calls stop as soon as start is done.
Workaround
Since the audio file is empty, it's easy to determine that the file is not valid audio. Personally, I just check the audio file is empty before trying to process it.
The text was updated successfully, but these errors were encountered:
andrewkolos
changed the title
Calling stop too quickly after start generates an empty (0 byte) file instead of a zero-length audio file
Calling stop too quickly after start generates an empty (0 byte) file
Dec 22, 2023
Something I forgot to add is that this can happen even with non-zero-length recording sessions, as long as the duration is short enough. For example, calling stop ~50ms after start will still produce an empty file. I wonder if audio data is being lost?
Feel free to tweak the provided repro code to try this with different durations.
@andrewkolos I suppose the callback to fill audio data had no chance to be called before you stopped the recording so soon.
From here, internally there's a Finalize method called to fill headers and properly place end marker. In such case, I guess the writer doesn't know what to do and so does nothing...?
Well, in short, I need to investigate.
@akshatbaranwal Please a proper separated issue, this has nothing related with the current one.
Package version: 5.0.4
Environment
Windows 11 Pro
Version 22H2 (OS Build 22621.2861)
Starting a recording and quickly stopping it (within a small fraction of a second) risks creating a completely empty file.
To Reproduce
Repro project: https://github.com/andrewkolos/_repro_start_and_stop_record/tree/main/start_and_stop_empty_file
If using this project:
flutter run -d windows
ffprobe
available on your system's path, the program will print the length of the audio file. If the file is empty,ffprobe
will fail, and its output will be empty.Logs from me using this app to generate a zero-length recording
If not using the provided repro project, code similar to this will probably repro the issue:
Workaround
Since the audio file is empty, it's easy to determine that the file is not valid audio. Personally, I just check the audio file is empty before trying to process it.
The text was updated successfully, but these errors were encountered: