llfbandit / record

Audio recorder from microphone to a given file path. No external dependencies, MediaRecorder is used for Android an AVAudioRecorder for iOS.
https://pub.dev/packages/record
233 stars 196 forks source link

can not record on mac #405

Open ynmm222 opened 1 day ago

ynmm222 commented 1 day ago

Describe the bug

I download the latest version of record, and the run the default example app in simulator, then I got below logs.

it do generate a .m4a file in my mac, but the audio file seems to be bad, can not be played by the audio player. btw, there is one thing I can confirm is that I did't change any thing in the example app.

flutter: [ id: MicrophoneBuiltIn flutter: label: MicrophoneBuiltIn flutter: ] flutter: Recorded file path: /Users/shaoyong/Library/Developer/CoreSimulator/Devices/0DF74983-2EBA-4573-B69C-A9B96EB05F07/data/Containers/Data/Application/11593D03-811C-44F5-8655-103CAFACD45A/Documents/audio_1727677882805.m4a flutter: \^[[31mAudioPlayers Exception: AudioPlayerException( DeviceFileSource(path: /Users/shaoyong/Library/Developer/CoreSimulator/Devices/0DF74983-2EBA-4573-B69C-A9B96EB05F07/data/Containers/Data/Application/11593D03-811C-44F5-8655-103CAFACD45A/Documents/audio_1727677882805.m4a, mimeType: null), PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null)<…> [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null) [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null) [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null)

Package version record 5.1.2

Environment [✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale zh-Hans-CN) • Flutter version 3.22.3 on channel stable at /Users/shaoyong/Documents/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b0850beeb2 (3 months ago), 2024-07-16 21:43:41 -0700 • Engine revision 235db911ba • Dart version 3.4.4 • DevTools version 2.34.3 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/shaoyong/Library/Android/sdk • Platform android-35, build-tools 35.0.0 • ANDROID_HOME = /Users/shaoyong/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.92.0) • VS Code at /Users/shaoyong/Documents/download/Visual Studio Code.app/Contents • Flutter extension version 3.94.0

[✓] Connected device (4 available) • iPhone 11 Pro (mobile) • 0DF74983-2EBA-4573-B69C-A9B96EB05F07 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.60

[✓] Network resources • All expected network resources are available.

ynmm222 commented 1 day ago

on the play screen, I can see that the record duration always be 0.0.

tgalery commented 1 day ago

From your logs it looks like the mimetype for the player is set to null. Have you tried passing the correct type ? It might be a codec issue !

ynmm222 commented 11 hours ago

set mimeType does not help.

thing changes after I do the following:

  1. reinstall the cocoapods, sudo gem install cocoapods
  2. make a .zshenv file in home directory
  3. export PATH=$HOME/.gem/bin:$PATH now, I can record audio on physical iPhone or android device, but still fail on my mac.