Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording is broken if using an audio sample rate is set to 44.1 kHz #1363

Closed
zachsimone opened this issue Dec 20, 2023 · 1 comment · Fixed by #1365
Closed

Recording is broken if using an audio sample rate is set to 44.1 kHz #1363

zachsimone opened this issue Dec 20, 2023 · 1 comment · Fixed by #1365
Milestone

Comments

@zachsimone
Copy link
Contributor

zachsimone commented Dec 20, 2023

Describe the bug

When using the recording + resampling feature, it appears as though the metadata for the audio (and possibly the audio itself) is incorrect. This results in a recording that appears in the iOS camera roll as significantly longer than it actually is e.g. a recording of 1-2 minutes is showing as 6hr48m. It is not actually that long, but it's what the metadata says. The audio is also missing (or at least is corrupt).

This is only an issue in the recorded file when the audio bitrate is set to 44.1 kHz. It's fine when set to 48 kHz. I have a hunch the issue might only occur when the audio is being resampled to something other than the device mic default of 48 kHz, but haven't tested that theory.

To Reproduce

  1. Start recording on a stream startRecording(self)
  2. Set the sample rate to 44100 on the stream's audio settings
  3. Stream for a short period of time (e.g. 30 seconds)
  4. Stop the live stream and the recording
  5. Handle func recorder(_ recorder: IORecorder, finishWriting writer: AVAssetWriter) callback by writing the recording to the device camera roll (using the PHPhotoLibrary.shared().performChanges... code from the documentation example
  6. Look in camera roll, and see a recording with incorrect metadata (significantly longer video duration than expected, and no working audio)

Expected behavior

Would expect the metadata for duration to match what was actually recorded, and for the audio to have been recorded as well.

Currently the audio is not recorded, the file metadata (specifically duration) is incorrect.

Version

1.7.2

Smartphone info.

  • iPad Pro (11-inch) (2nd generation) running iOS 17.2
  • iPhone 15 Pro running iOS 17.3.

Additional context

Using the built-in mic on both devices mentioned above, and it's probably relevant to note that we're using the public func append(_ sampleBuffer: CMSampleBuffer) method for sending both audio and video sample buffers to the RTMP(s) stream, and not the attachCamera or attachAudio methods.

Happy to provide additional information, testing, etc. Just let me know what's required. Thanks :)

Screenshots

The recording was probably 1-2 minutes in actuality, yet note the metadata saying it was almost 7 hours.

IMG_0601

IMG_0602

Relevant log output

No response

@shogo4405 shogo4405 added this to the 1.7.3 milestone Jan 1, 2024
@zachsimone
Copy link
Contributor Author

@shogo4405 Really appreciate this fix, thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants