Skip to content

web support#617

Draft
g-apparence wants to merge 120 commits intoweb_supportfrom
master
Draft

web support#617
g-apparence wants to merge 120 commits intoweb_supportfrom
master

Conversation

@g-apparence
Copy link
Copy Markdown
Collaborator

Description

  • handle web

g-apparence and others added 30 commits June 12, 2025 21:08
…is disabled or returns UIDeviceOrientationUnknown
Modify getJpegOrientation to fallback orientation when motion sensor is disabled or returns UIDeviceOrientationUnknown
Fix(ios) setRecordingAudioMode not competed
Fix(ios) orientation when device lock orientation
🖌️ Swap red and blue channels in .jpeg method of BGRA8888 function
- Multiple global key issue fixed by replacing previewWidgetKey  with UniqueKey in
lib/src/widgets/preview/awesome_preview_fit.dart
fix: Audio input on multiple video recordings on iOS
…ng camera switch

When switching cameras during video recording, the setSensor method was
incorrectly setting audioIsDisconnected=YES even though only the video
input was being changed. This caused:
1. Audio timestamps to be incorrectly offset (audio wasn't interrupted)
2. Video timestamps to NOT be compensated for the gap during camera switch
3. Result: Video gets stretched over the gap, audio finishes before video

The fix changes to setVideoIsDisconnected=YES which correctly triggers
timestamp gap compensation in VideoController.m's captureOutput method:
- When videoIsDisconnected=YES, the next video sample calculates the gap
- videoTimeOffset accumulates this gap duration
- All subsequent video samples subtract this offset, closing the gap
- Audio continues unaffected at normal speed
- Result: Audio and video stay in sync

Root cause analysis:
- Video input is removed and replaced during camera switch (brief gap)
- Audio input continues uninterrupted
- Original bug: audioIsDisconnected=YES was set (wrong stream)
- First fix attempt: Removed both flags (didn't compensate video gap)
- Correct fix: Set videoIsDisconnected=YES to compensate video gap

Co-Authored-By: Claude <[email protected]>
When switching cameras during video recording, the new camera device
would use its default FPS instead of the custom FPS specified in
CupertinoVideoOptions. This caused audio/video desync because:

1. Recording starts with Camera A at custom FPS (e.g., 24fps)
2. Camera switches to Camera B
3. Camera B uses default FPS (e.g., 30fps)
4. More frames arrive than the video writer expects
5. Video duration extends while audio stays constant
6. Result: Audio finishes before video (desync)

The fix adds updateCaptureDevice: method to VideoController that:
- Updates the capture device reference after camera switch
- Re-applies custom FPS if recording is in progress

This is called from SingleCameraPreview's setSensor: method after
initializing the new camera preview.
…issue

When audio is set up on-demand during the first recording start, there's a
delay before audio samples begin flowing. This causes the AVAssetWriter to
start its session with video-only timestamps, leading to audio/video desync.

By pre-warming audio input/output when the camera preview starts, both
audio and video streams are already flowing when recording begins,
ensuring proper synchronization from the first frame.

This fixes the issue where the first recording has audio desync but
subsequent recordings work correctly.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add onFirstFrameReceived callback to signal when camera is actually delivering frames
- Modify start() to use dispatch_semaphore to wait for first frame (2s timeout)
- Pre-warm audio input/output during camera start to avoid cold-start delay
- Remove hardcoded 300ms delays in Dart code, replacing with native first-frame wait
- Change state to VideoCameraState only after camera is confirmed running

This fixes the issue where the first recording after fresh app launch would
have ~4 seconds of frozen video at the start and audio finishing early.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…disconnect-flag

fix(ios): Set videoIsDisconnected instead of audioIsDisconnected during camera switch
fix(ios): Re-apply custom FPS settings when switching cameras during recording
…g-sync

fix(ios): Fix audio/video desync on first recording after app launch
… launch"

This reverts merge commit 7ba9752 (PR #631).

The audio pre-warming and first-frame semaphore synchronization introduced
in PR #631 causes an intermittent bug where recorded videos have no audio.
The audio stream does not reliably warm up and attach to recordings when
set up eagerly during camera initialization.

Reverting restores the original on-demand audio setup behavior which
produces reliable audio in recordings.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Revert "fix(ios): Fix audio/video desync on first recording after app launch"
  When pausing and resuming the app, CameraX rebinds the camera at 1x
  zoom but the Dart-side zoom state was not updated, causing the zoom
  indicator to show a stale value. Extracted setZoomToOneX() into
  SensorConfig for reuse and call it on app resume to keep the indicator
  in sync with the native preview.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.