Skip to content

Conversation

@felire
Copy link
Contributor

@felire felire commented Jun 12, 2025

What

This PR Adds the onBytesWrittenVideo callback in order to receive the bytes of the video while it is being recorded.

Changes

IOS

  • Implementing DispatchSourceTimer on Ios in order to read the file size from the FileSystem every 400 ms, that will be executed after the video has started and when finished the timer is cleaned.
  • Adding onBytesWrittenVideoEvent as RCTDirectEventBlock in order to send events to JS in RCTViewManager

Android

  • Creating BytesWrittenVideoEvent class
  • Adding onBytesWrittenVideo on the getExportedCustomDirectEventTypeConstants and all the logic to treat that as an Event and send data to JS
  • Send the data directly from VideoRecordEvent.Status as it is available there

TSX/TS

  • Adding types and JS Docs
  • Adding the onBytesWrittenVideo and destructuring the NativeEvent to just expose (bytes: number) => void

Docs

  • Add an example on video page

Tested on

  • iPhone 8
  • Samsung Galaxy S24 FE

Related issues

@vercel
Copy link

vercel bot commented Jun 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 1:23am

@mrousavy
Copy link
Owner

cool!

Comment on lines 147 to 149
DispatchQueue.main.async {
onBytesWritten(bytes)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to run on the main queue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't needed, I removed the execution on the main queue

@vercel
Copy link

vercel bot commented Dec 11, 2025

@frodriguez-hu is attempting to deploy a commit to the mrousavy's Team Team on Vercel.

A member of the Team first needs to authorize it.

@mrousavy mrousavy merged commit cc58a67 into mrousavy:main Dec 15, 2025
1 check failed
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.

3 participants