Informative export process with accurate estimates #735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request significantly enhances the user experience of the video export process in the desktop editor. Previously, exporting a video provided no feedback, making the application appear unresponsive and providing inaccurate estimates for file size and export time.
This change introduces a real-time, event-driven progress system and a more robust, calculation-based estimation engine. The user is now presented with:
More reliable estimates for export time and file size.
A real-time progress bar and percentage indicator during the export.
A clear success message upon completion, including a convenient button to open the exported file directly.
Improved error handling and cancellation capabilities.
Key Changes
Refactored Estimation Logic (get_export_estimates):
The function no longer uses brittle, hardcoded "magic numbers" for different resolutions.
Size Estimation: It now calculates the video bitrate based on a quality factor per megapixel, adjusting for framerate. This provides a much more accurate file size estimate that scales correctly for any video dimension.
Time Estimation: It now estimates processing time based on the total pixels to be rendered per second, providing a more realistic forecast of the export duration.
Robust Progress Handling (export_video):
The on_progress callback passed to the exporter now checks if the IPC channel to the frontend is still open.
If the frontend closes (e.g., the user quits the app), the callback returns false, signaling the cap_export crate to gracefully cancel the ongoing export process. This prevents orphaned ffmpeg processes.
Reactive Frontend (Not included in this PR, but enabled by these changes):
The backend now provides all the necessary events (export_progress, export_finished) and accurate data for the frontend to build a rich, informative UI for the export dialog.