[camera] add custom path ouput to recording#11774
Conversation
…ple file saving functionality.
…icationSupportsIndirectInputEvents in Info.plist
…roject configuration and dependencies.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for a custom videoOutputPath to the startVideoRecording API across Android, iOS, Windows, and Web platforms. The changes include updates to the camera_platform_interface, native implementation logic for path validation, and a new interactive example app. Technical feedback identifies several improvement opportunities: the Android example should use path_provider instead of hardcoded paths, and the UI should be updated to reflect that content:// URIs are not supported. Additionally, the reviewer recommended properly managing TextEditingController lifecycles, using locale-aware string conversions in Java, fixing a potential logic error in the Swift path validation, and integrating the new demo into the existing example app structure rather than replacing the main entry point.
…urces/camera_avfoundation/DefaultCamera.swift Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…r/plugins/camera/Camera.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…o/flutter/plugins/camerax/RecorderProxyApi.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…eb support from video recording example
… and standardizing app entry point
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for a custom videoOutputPath in the startVideoRecording method across the Android, iOS, and Windows implementations of the camera plugin. The changes include updates to the platform interface, implementation of path validation logic on both Dart and native sides, and the addition of a new example demonstrating the feature. Feedback identifies that the web implementation currently ignores the new parameter and that the example UI documentation incorrectly suggests support for multiple file extensions despite the implementation strictly enforcing .mp4. Additionally, inconsistent SDK and Flutter version constraints were noted in the web package compared to other packages in the pull request.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for a custom video output path (videoOutputPath) to the startVideoRecording method across the Flutter camera plugin and its federated platform implementations (Android, iOS, and Windows). It includes platform-specific validation logic to ensure output paths are not directories, have valid parent directories, and end with the .mp4 extension. Additionally, a comprehensive video recording example app has been added to demonstrate this feature. Feedback on the changes highlights a type mismatch in the example app's validation helper, potential memory leaks from unhandled asynchronous initialization when widgets unmount, and a bug in the Windows path parsing logic when a parent directory contains a dot.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for a custom videoOutputPath to the startVideoRecording method across the federated camera packages, including Android, iOS, Web, and Windows implementations. It updates the platform interface, implements platform-specific path validation, adds unit and integration tests, and introduces a new video recording example app. The review feedback highlights three key improvements: ensuring the previous CameraController is properly disposed in the example app to prevent resource leaks, correcting path generation logic in the example app for Android and iOS, and deleting any pre-existing file at the destination path on iOS to prevent AVAssetWriter initialization failures.
…iter initialization failure by deleting existing files on iOS
…oss camera packages
bparrishMines
left a comment
There was a problem hiding this comment.
@Mairramer What's the use case you want to solve by adding this feature? From my understanding, it should currently be possible for the app to rename the file to change it's location without copying.
The issue linked mentions being able to save to an external SD card and finding the file if the app crashes during recording, but I dont think this PR would fix these.
Thanks for the review! If we record a video to the internal cache and then try to Regarding the SD card: apps still have direct write access to their app-specific folders on external SD cards (for example, the second directory returned by Regarding the crash recovery scenario mentioned in flutter/flutter#91680, you're absolutely right that the MP4 may end up corrupted after a crash, especially if the final The main issue today is that the native layer generates a random temporary filename, and Dart only receives that path after By providing the output path upfront, the application always knows where the recording is being written. After a restart, developers can at least locate the interrupted file, attempt MP4 recovery if possible, or simply clean up the orphaned file to avoid unnecessary storage leaks. Let me know if this makes sense or if I should adjust anything in the implementation. |
|
Regarding crash recovery: On iOS, we could use movieFragmentInterval, which allows the movie file to be fragmented periodically and can help reduce data loss in crash scenarios. On Android, as far as I know, there is no equivalent native solution available. We would probably need a custom implementation using MediaMuxer or something similar to periodically fragment or remux the recording stream, but that’s not something I’d really like to introduce at the moment. |
This PR introduces the ability to save videos to custom locations, taking into account the limitations and behavior of each platform.
Due to platform-specific security restrictions and limitations:
/storage/emulated/0/Download/video.mp4without issues.On My iPhone -> Camera Example -> Movies.Closes flutter/flutter#91680
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2