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
241 stars 202 forks source link

On macOS, cannot record PCM 16 bits LE; getting pcm_f32le instead #397

Open jmgeffroy opened 2 months ago

jmgeffroy commented 2 months ago

Package version 5.1.2

Environment

Describe the bug

When I try to record with the AudioEncoder.pcm16bits encoder, I get pcm_f32le instead. I am just using the example app, where I changed the AudioEncoder from AudioEncoder.aacLc to AudioEncoder.pcm16bits

To verify the file I use ffprobe, which comes with ffmpeg.

To Reproduce

Steps to reproduce the behavior:

  1. Open the example project
  2. In AudioRecorder replace AudioEncoder.aacLc by AudioEncoder.pcm16bits
  3. Launch the app on a Mac
  4. Record
  5. Test the file with ffprobe

ffprobe gives the following output:

ffprobe version 7.0.2 Copyright (c) 2007-2024 the FFmpeg developers
  built with Apple clang version 15.0.0 (clang-1500.3.9.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/7.0.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, wav, from '/Users/jmgeffroy/Library/Containers/com.llfbandit.example/Data/Documents/audio_1725985905974.m4a':
  Duration: 00:00:02.28, bitrate: 1425 kb/s
  Stream #0:0: Audio: pcm_f32le ([3][0][0][0] / 0x0003), 44100 Hz, mono, flt, 1411 kb/s

Expected behavior

The output file should be pcm_s16le, not 32 bits pcm_f32le.

llfbandit commented 2 months ago

Thanks for the report. Yes this is a know issue. macOS doesn't care of given settings (partially) with PCM. This was discovered and discussed here #280.