-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
✨ Add record / save path #893
Comments
Thanks for the feature request, that's a pretty valid enhancement. I'd imagine the user being responsible for creating all of the paths and making sure VisionCamera has permission to create a file there? |
Here are the comments the other SDK I am using is making:
And I am supplying something like this:
The SDK adds .mov/mp4 automatically based on filetype/codec. And my VIDEO_TMP_DIR is
To your question: |
+1 on this. I have faced issues in the past with losing pictures after a crash because React Native iOS clears the tmp directory upon each cold boot. Since then I have always moved every capture to a permanent directory immediately after capture, but this can add a slight delay which I'd rather avoid. Another reason is I'd like to generate my own file names instead of mrousavyXXXXXXXXX.jpg as they show up in certain file browsers, so currently I have to do another file operation to rename the file. |
@mrousavy I'm willing to help out with this, giving your approval and kind of a guide. I need this anyway :) |
Sure:
Test both with and without |
We need some kind of error handling as well, so e.g.
On Android, add here: https://github.com/mrousavy/react-native-vision-camera/blob/main/android/src/main/java/com/mrousavy/camera/Errors.kt |
I'm happy to work on this next week sometime if @garyhlusko can't. |
Hi, did this enhancement ever get done? I am loving the vision camera but have hit a dead end re: using the results as its not possible to even read the photo/video files created using Expo FileSystem. FileSystem.getInfoAsync works but copyASync does not (file "isn't readable"). Any workaround's suggestions greatly appreciated. |
I'm having the same problem @GreenCurveDev has. I cannot even do |
@GreenCurveDev if you can use |
Thanks mortenmo, to work around this I prefixed the file paths with file:// but it definitely felt wrong - I will try your suggestion. |
Is this still in progress? Did either of you guys get to work on it? @alexstanbury @garyhlusko I would use react-native-fs however i'm recording large videos which may be too large for the initial write to internal storage. Another useful alternative would be to get some kind of access to chunks of data. Any thoughts on this kind of functionality @mrousavy ? |
Yea, this is WIP - need V3 for this. If you wanna see this faster, consider sponsoring the V3 efforts :) [email protected] |
Was this ever completed? |
This comment was marked as spam.
This comment was marked as spam.
Same here, with expo I get: "Caused by: File '///private/var/mobile/Containers/Data/Application/C998E08F-86F2-4413-BC87-FBB59CAC675E/tmp/9B75D8FA-2216-4E1D-B1A6-822806D3E4DC.jpeg' is not readable" I'm unable to read the file in any way, other than getting info. Further, I cant use RNFS because it doesnt support expo. I tried prepending the file path with file:// like @GreenCurveDev mentioned but its not working for me at all. Does anyone have a working example for expo?
|
For those stuck on expo, the only way I've managed is to use fetch as per the docs. Unfortunately this means no immediate cleanup of the temp file but it'll do
|
@mrousavy Is this still WIP? The tmp and expo-file-system don't get along very well. Would this be something a donation page could help make happen? |
Nope not WIP - I didn't implement this anymore because V3 (or now V4) was already huge and this was low priority for me since it always just worked for me with tmp files. But yea I could create a donations page and start building this. I think the implementation plan for me would be to just add a path parameter to takePhoto, takeSnapshot and startRecording - file name itself is still generated randomly, and it will throw if the path is invalid. |
Guten Tag, Hans here. Note New features, bugfixes, updates and other improvements are all handled mostly by |
Added a polar bade to this issue - $400 is a fair goal for this, I don't think it takes too long. Could be done in less than a week |
@mrousavy Sounds good! Perhaps I'm completely missing something, but could you post the link to the donations page? Thanks! |
This might be user error on my end, but I cloned the repo so I could test locally, and npm install fails: npm error code ERESOLVE |
You need to use |
Hmm. Tried to do that but still having issues; can't resolve the path to react-native-vision-camera package on pod install. If it's working for you and others, it's probably an issue on my end switching to yarn from npm. I'm not very familiar with yarn |
To run VisionCamera example do this:
Then open |
Are you sure you installed pods then? These two files have been added and will only be available after you installed pods. ( |
Ah this error is because a But yea sure I'll just try to release a beta for you to test in your app |
Aha! Ok, after removing that file, it compiled and installed. Example app seems to be running fine! |
Done and released in 4.5.1!! 💪 :) Thanks for the sponsoring @gwashburne ❤️ |
@mrousavy I just tried 4.5.1. what are the possible reason that this error comes
My code is simple const data = await camera.current.takePhoto({
path: `${ReactNativeBlobUtil.fs.dirs.CacheDir}/image.jpeg`,
}); |
The path should be a directory, not a file url. |
Thanks @mrousavy , yes that is working. |
You're welcome! Thanks for getting this done so fast and helping me out with testing! |
awesome! :) |
Can confirm this works nicely with expo too! |
great to hear! |
Thanks so much for getting this done! Would it be too much to ask that we are also able to provide the file name ourselves, as a separate option? It could be used in combination with the path parameter or standalone. I need my captured images to follow a certain naming convention, so I can't benefit from the performance/convenience benefit of this change because I still need to touch the file system to do the rename. |
Out of curiousity - why would you need your filenames to have a different name? How is that affecting the user of your app? |
I use a timestamp for the filename to be able to quickly run certain analytical tasks on the images captured. |
@mrousavy Got a bit of a problem when running the release version: |
It's something about production vs debug compiling. Works as expected if I switch back to debug |
@gwashburne I had a similar error and then realized that the folder I was transferring to did not exist and it would not automatically create one just by specifying the path, so I now check and create the folder if it does not exist before taking a photo. Did not yet try in production build... |
Thanks @emilje! That was exactly the issue. Got it fixed! |
@alexstanbury @alexrififi @samuel-andres I have created a new fork/branch to add this feature. If you'd like to help out with testing it, I'd much appreciate it! I think it's ready, but was hoping for feedback before I make the PR. It's available here |
What feature or enhancement are you suggesting?
I think it would be nice to define where the file should be saved. Currently it's being saved in the /tmp/ folder.
While this is not an issue but more a convenience and speed thing, (I am using FileSystem.copyAsync from expo to create a copy of it, since I am not allowed to "moveAsync" (permission issue?)
I would love to be able to define a save path, which Expo's FileSystem has access to.
Why I am asking for it? Because it's unreliable when the OS clears the tmp folder. I currently generated 16 GB of video files in my tests and there is no way for me to delete those. I think the end user will eventually delete our app if they can't free up space.
What Platforms whould this feature/enhancement affect?
iOS, Android
Alternatives/Workarounds
There are no workarounds. I tried to delete the files with
FileSystem.deleteAsync
but it always ends up with "file is not deleteable/moveable".The copies of the files I create though, which live in FileSystems documentDirectory, are move- and deleteable.
I am using a video editor sdk which also has the ability to define the save path and its working pretty good and reliable.
Additional information
Upvote & Fund
The text was updated successfully, but these errors were encountered: